Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all GMSMarker from mapview and remove all marker without using mapview.clear()

I have drawn path with marker in google map. So the path is static but marker needs to change their positions. How can I remove all markers without using mapview.clear(), because it will clear my path also from the map.

Any solution?

like image 734
Rushi trivedi Avatar asked Oct 11 '17 10:10

Rushi trivedi


People also ask

How to remove all markers from google map swift?

How do I reset a marker on Google Maps? You can delete the markers by removing them from the map and then setting the array's length to 0 , which removes all references to the markers.

How to remove marker from google map ios?

You can remove a marker from the map by setting the map property of the GMSMarker to nil . Alternatively, you can remove all of the overlays (including markers) currently on the map by calling the GMSMapView clear method.


1 Answers

I guess you will have to keep all markers in an array(eg. allMarkers). Then,

for marker in allMarkers {
    marker.map  = nil
}
like image 135
Nikhil Manapure Avatar answered Oct 13 '22 06:10

Nikhil Manapure