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?
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.
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.
I guess you will have to keep all markers in an array(eg. allMarkers
). Then,
for marker in allMarkers {
marker.map = nil
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With