(MapView и 1700 элементов наложения) .equals («Медленно»)

У меня есть MapView , и я накладываю на него 1700 точек, каждая с одинаковыми возможностями рисования, но с другой информацией . В настоящее время я использую детализированное наложение, чтобы добавить все наложения, а затем заполнить их после рыбалки. Это работает, но производительность низкая. Изменение уровня масштабирования и фокусировки резкое. Теперь, не лучше ли использовать ArrayItemizedOverlay , поскольку он такой же доступный, или карта будет такой же медленной?

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.app.Activity;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem; 

public class Points extends ItemizedOverlay <OverlayItem> {
    Context mContext; 
    private ArrayList mOverlays = new ArrayList();

    String newLine = String.format("%n");

    public Points(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
        // TODO Auto-generated constructor stub
    }

    @Override
    protected OverlayItem createItem(int i) {
        return (OverlayItem) mOverlays.get(i);
    }

    @Override
    public int size() {
        return mOverlays.size();
    }

    @Override
    public void draw(Canvas canvas,
            MapView mapView,
            boolean shadow) {
        if (!shadow)
            super.draw(canvas, mapView, shadow);
    }

    public void addOverlay(OverlayItem overlay) {   
        mOverlays.add(overlay);   
    }

    public void populateNow(){
        setLastFocusedIndex(-1);
        populate();
    }

    public Points(Drawable defaultMarker, Context context) {  
        super(boundCenterBottom(defaultMarker)); 
        mContext = context;
    }

    @Override
    protected boolean onTap(int index) { 
        Intent intent = new Intent();
        OverlayItem item = (OverlayItem) mOverlays.get(index); 
        AlertDialog.Builder dialog1 = new AlertDialog.Builder(mContext);  
        dialog1.setTitle(item.getTitle());  
        String info = item.getSnippet();
        String delims = "[$]";
        String [] tokens = info.split(delims);
        String info1 = tokens [0];
        String info2 = tokens[1];
        String delims2 = "[!]";
        String [] tokens2 = info1.split(delims2);
        double lat = Double.parseDouble(tokens2[0]);
        double lon = Double.parseDouble(tokens2[1]);
        final String location = tokens2[0]+","+tokens2[1];

        dialog1.setMessage(info2);

        dialog1.setPositiveButton("Navigate", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Nav(location);
            }
        });
        dialog1.setNegativeButton("Directions", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Direction(location);
            }
        }) ;

        dialog1.show(); 
        return true;
    }

    public void Nav(String location) {
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + location)); 
        mContext.startActivity(i);
    }

    public void Direction(String location) {
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?daddr=" + location)); 
        mContext.startActivity(i);
    }
}

Как я добавляю элементы:

mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.plug);
itemizedoverlay = new Points(drawable, this);

while (...) {
    point = new GeoPoint((int) (lat * 1000000), (int) (lon * 1000000));
    overlayitem = new OverlayItem(point, Station_Name, comb);
    itemizedoverlay.addOverlay(overlayitem);
}
7
задан Greg Bacon 7 February 2013 в 16:23
поделиться