I'm trying to create android application uses Google maps API v2 and put overlay on map that contains bitmap. I used addGroundOverlay method which attaches bitmap to the overlay. But when new position comes from LocationManager I would like to modify bitmap (erase something and draw something else). There is one problem because according to the specification when I drew the bitmap on overlay I can't modify it. So I remove overlay and add it again with manipulated bitmap:
public void draw(Bitmap modifiedBmp) {
if (overlay != null) {
overlay.remove();
}
BitmapDescriptor descriptor = BitmapDescriptorFactory.fromBitmap(modifiedBmp);
overlay = map.addGroundOverlay(new GroundOverlayOptions().image(descriptor).positionFromBounds(bounds).zIndex(100));
}
Bitmap is previously modfied using
p.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
to erase some area of the bitmap and draw another one
But that solution has weak performance and what is worse bitmap reloading is visible on the map. Can someone indicate better solution for that problem?