I placed 100 GMSMarkers on GMSMapView. How to remove all the GMSMarkers?
In Google Sdk Version 1.6 for iOS.
Marker array(in GMSMapView (Overlays) file) which will be holding the GMSMarkers list is deprecated. By using this i was removing all GMSMarker from GMSMapView.
Is there any other way to remove all GMSMarker from GMSMapView in iOS?
Use [mapView clear]
to achieve required functionality. :-)
Update:
Swift:
mapView.clear()
They deprecated those methods but you can use [mapView clear]
to remove all overlays from the map. This includes all markers, polylines and groundOverlays.
Hope it helps!
Add all markers into NSMutableArray, as you add them to the map. Then when you need to remove them, iterate through the array and set each marker's .map property to nil.
Swift 5.x
If someone is looking to clear only a particular marker
then you can use this:
marker.map = nil
If you want to remove everything from the map, like polyline
, marker
etc. then you can use
self.mapView.clear()
.
It will clear everything from the map.
斯威夫特 4.x
self.mapView.clear()
试试……
[self.MapView clear];
You can remove a marker from the map by setting the map property of the GMSMarker
to nil
.
marker.map = nil
Alternatively, you can remove all of the overlays (including markers) currently on the map by calling the GMSMapView
clear method.
mapView.clear()
Here is the official documentation: Remove a marker
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.