Reputation: 925
I have
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);
}
}
I need to load about 100 000 points.
And I have another overlay that will create polygon (100 000 polygons)
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());
}
}
On zoom level 5 I load first overlay, then on zoom 8 I load second overlay.
How can I speed my application?
Upvotes: 0
Views: 216
Reputation: 57672
Draw the Overlay on one bitmap and use that bitmap instead the redraw of each polygon.
You just need to calculate the scaling of your bitmap according your zoom level.
Upvotes: 1