I'm trying to just draw visible OverlayItems, thats why I determine the maps visible rect but I'm not able to determine the Rect where the Canvas will draw the OverlayItem.
Thats what I did till now (method in itemized overlay).. but the getClipBounds() doesn't return the correct Rect
@Override
public void draw(Canvas canvas, MapView map, boolean shadow) {
if (getMapBounds().intersect(canvas.getClipBounds())) {
super.draw(canvas, map, false);
}
}
I don't want to draw other OverlayItems, i want to know if my canvas draw something within the visible rects of the map view Because if not i don't draw this canvas This is done to speed up the mapview that has nearly 2000 overlay items
I now did this by iterating over the items and checking wether they are on the map or not Just like this:
@Override
public void draw(Canvas canvas, MapView map, boolean shadow) {
for (int i = 0; i < mOverlays.size(); i++) {
if (isLocationVisible(mOverlays.get(i).getPoint())) {
super.draw(canvas, map, false);
}
}
}