androidandroid-mapviewandroid-overlay

Clear and Add overlay on MapView crops the marker for a few seconds


I am developing a taxi pickup drop application. I need to provide a feature to provide alternative pickup and drop points. When I choose pickup point, I need select the pickup point on the mapview. For this I need the marker to change from drop drawable to pickup drawable.

I am using the following code to change the overlay

whichPoint = !whichPoint;
if (whichPoint == PICKUP) {
    map.getOverlays().clear();
    map.getOverlays().add(startLocation);
    map.getOverlays().add(locationOverlay);
} else if (whichPoint == DROP) {
    map.getOverlays().clear();
    map.getOverlays().add(endLocation);
    map.getOverlays().add(locationOverlay);
}

When I change the overlay, for a brief moment during the transition (3-4 seconds) I get a "half" image of the new overlay. Check the image below. How do I eliminate the transition display issue.

mapview with half red icon


Solution

  • I did not call populate after adding the overlay's. Also found out that clearing and adding overlays is a UI intensive task. Its better to add all your overlays and control the ontouch. That is what I did and it works well.