UMAR-MOBITSOLUTIONS
UMAR-MOBITSOLUTIONS

Reputation: 77984

how to clear all map overlays or markers from google map in android?

I want to clear all map overlays or markers from google map and using following code

if(!mapOverlays.isEmpty())
     {
     mapOverlays.clear();

 }

which is giving me exception can any one guide me? am i right or wrong if i am wrong then kindly provide me the solution to my problem.

i want map clean if there is any marker on it.

any help would be appriciated.

Upvotes: 3

Views: 14869

Answers (2)

Kirill Volkov
Kirill Volkov

Reputation: 942

If you need to entirely clear map overlays you'd need to clear ListArray in class that extends ItemizedOverlay.

Something like this:

    mItemizedOverlay.clearOverlays();
    mMapView.getOverlays().clear();
    mMapView.invalidate();

Upvotes: 1

UMAR-MOBITSOLUTIONS
UMAR-MOBITSOLUTIONS

Reputation: 77984

mapView.invalidate();

i was missing to update map. now working fine. so the whole code look like

if(!mapOverlays.isEmpty()) 
     { 
     mapOverlays.clear(); 
     mapView.invalidate();

 }

Upvotes: 17

Related Questions