0

我有

 public class MyItemsOverlay extends ItemizedOverlay<OverlayItem>{
private List<OverlayItem> items=new ArrayList<OverlayItem>();
private Drawable marker=null;   
private StatusData data;    
private MapView mapView;
 private PopupPanel panel;

public MyItemsOverlay (Drawable defaultMarker, View view, LayoutInflater getLayoutInflater) {       
    super(defaultMarker);
      this.marker=defaultMarker;               
      mapView=(MapView) view.findViewById(R.id.mapview);
      panel=new PopupPanel(R.layout.details_popup,getLayoutInflater, mapView);
      data=new StatusData (mapView.getContext());
      items=  protectedZoneData.GetItems();  

      populate();
}

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


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

  @Override
    protected boolean onTap(int i) {

      OverlayItem item=getItem(i);
      GeoPoint geo=item.getPoint();       

      View view=panel.getView();

      ((TextView)view.findViewById(R.id.latitude))
        .setText(String.valueOf(geo.getLatitudeE6()/1000000.0));
      ((TextView)view.findViewById(R.id.longitude))
        .setText(String.valueOf(geo.getLongitudeE6()/1000000.0));
      ((TextView)view.findViewById(R.id.Name))
                              .setText(item.getTitle());
      ((TextView)view.findViewById(R.id.Description))
                              .setText(item.getSnippet());

      panel.show();
      hidePopup();
      return(true);
    }        

}

我需要加载大约 100 000 个点。

我还有另一个覆盖层可以创建多边形(100 000 个多边形)

public class MyPolygonOverlay  extends Overlay{

private StatusData data; 

private Projection projection;
ArrayList<ArrayList<GeoPoint>> geArrayList;

public MyPolygonOverlay(Context context, MapView mapView)
{
    data=new StatusData(context);

    projection=mapView.getProjection();
    geArrayList=data.GetPoyigonGeoPoints();


}

public void draw(Canvas canvas, MapView mapView, boolean shadow){
    super.draw(canvas, mapView, shadow);



    for (int i = 0; i < geArrayList.size(); i++) {
         Path path = new Path();
         ArrayList<GeoPoint> geoPoints=geArrayList.get(i);
         for (int j = 0; j <geoPoints.size(); j++) {

               GeoPoint gP1 =geoPoints.get(j);
               Point currentScreenPoint = new Point();

                Projection projection = mapView.getProjection();
                projection.toPixels(gP1, currentScreenPoint);

                if (j == 0){
                  path.moveTo(currentScreenPoint.x, currentScreenPoint.y);                    

                }                  
                else
                {
                  path.lineTo(currentScreenPoint.x, currentScreenPoint.y);
                }
            }
           canvas.drawPath(path, GetPaint());

}
}

在缩放级别 5 上加载第一个叠加层,然后在缩放 8 上加载第二个叠加层。

如何加快我的申请速度?

4

1 回答 1

1

在一个位图上绘制叠加层并使用该位图而不是重绘每个多边形。

您只需要根据缩放级别计算位图的缩放比例。

于 2012-09-03T18:22:50.820 回答