I am using GoogleMap-IOS-1.8.1 SDK for displaying a map. I have to draw a GMSPolyline on the map. After a particular event I have to remove all GMSPolyline paths except for markers. I'm not sure of the best way to do that. The GoogleMaps documentation for iOS describe two methods to sue.
1. [mapView_ clear];
2. Set the GMSPolyline map property to nil
Here the first approach removes all Markers and Overlays as well. This isn't exactly what I want. And for 2nd one it doesn't seem like the best method to save all of the GMSPolyline object references and then go back and set them all to nil.
Is there a better way to do accomplish this task, or is this the only proper / correct way to do this?
I was hoping for something like the following.
for (GMSPolyline *polylineToremove in mapView_.polyline)
{
[mapView_ removeOverlay:overlayToRemove];
}
Removing a polyline You can remove a polyline from the map by setting your GMSPolyline 's map property to nil .
You do need to do as you've said - store a reference to all of the polylines you've added (eg in an array), and then loop over them and set their map
property to nil.
You just need to set GMSPolyline map property to nil.
GMSPolyline *polyline;
polyline.map = nil;
Just use below properly of Google Map:
mapView.clear()
Clears all markup that has been added to the map, including markers, polylines and ground
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