Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Map针对ItemizeOverlay的低性能<;OverlayItem>;_Android_Performance - Fatal编程技术网

Android Map针对ItemizeOverlay的低性能<;OverlayItem>;

Android Map针对ItemizeOverlay的低性能<;OverlayItem>;,android,performance,Android,Performance,我有 公共类MyItemsOverlay扩展了ItemizeOverlay{ 私有列表项=新的ArrayList(); 私有可绘制标记=null; 私有状态数据; 私有地图视图; 私人Popupanel小组; 公共MyItemsOverlay(可绘制的defaultMarker、View视图、LayoutFlater GetLayoutFlater){ 超级(默认标记); this.marker=defaultMarker; mapView=(mapView)view.findViewById(

我有

公共类MyItemsOverlay扩展了ItemizeOverlay{
私有列表项=新的ArrayList();
私有可绘制标记=null;
私有状态数据;
私有地图视图;
私人Popupanel小组;
公共MyItemsOverlay(可绘制的defaultMarker、View视图、LayoutFlater GetLayoutFlater){
超级(默认标记);
this.marker=defaultMarker;
mapView=(mapView)view.findViewById(R.id.mapView);
面板=新的PopupPanel(R.layout.details\u弹出窗口、GetLayoutFlater、mapView);
数据=新状态数据(mapView.getContext());
items=protectedZoneData.GetItems();
填充();
}
@凌驾
受保护的OverlayItem createItem(int i){
返回(items.get(i));
}
@凌驾
公共整数大小(){
返回(items.size());
}
@凌驾
受保护的布尔onTap(int i){
OverlayItem item=getItem(i);
GeoPoint geo=item.getPoint();
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();
返回(真);
}        
}

我需要加载大约100000个点

我有另一个覆盖,将创建多边形(100000个多边形)

公共类MyPolygonOverlay扩展覆盖{
私有状态数据;
私人投影;
阵列列表;
公共MyPolygonOverlay(上下文上下文,MapView MapView)
{
数据=新状态数据(上下文);
projection=mapView.getProjection();
gearylist=data.GetPoyigonGeoPoints();
}
公共空白绘制(画布、地图视图、地图视图、布尔阴影){
super.draw(画布、地图视图、阴影);
对于(int i=0;i对于(int j=0;j在一个位图上绘制覆盖,并使用该位图代替每个多边形的重画


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

您好,我是android新手。您有我的示例吗?基本上,您只需要绘制位图并存储它。阅读一些相关教程或尝试一下:您只需创建一个位图,绘图应该是相同的……但位图会吃掉我的内存ory?性能主要是伴随着内存成本而来的。但一两个位图不应该对内存消耗产生如此大的影响。基本上,这是您唯一的选择(除了减少点数…)
 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);
    }        
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());

}
}