Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear all the markers in v2 google map?

I need to clear all markers in v2 google map. And again need to add some markers. If anybody knows the answer kindly share your thoughts.

like image 592
Arunraj Jeyaraj Avatar asked Jun 19 '13 17:06

Arunraj Jeyaraj


1 Answers

You can either use googleMap.clear(), or you can store your Markers in a collection of some kind and remove them in a loop:

private ArrayList<Marker> mMarkers;
...
private void removeMarkers() {
    for (Marker marker: mMarkers) {
        marker.remove();
    }
    mMarkers.clear();
}
like image 177
Karakuri Avatar answered Sep 19 '22 15:09

Karakuri