I have a MKMapView
with a MKOverlay
over it showing the location history of the user. On a button press, how can I discard this overlay and remove it from view?
I have tried [map removeOverlay:overlay];
but that doesn't work - it still shows.
This will work
NSArray *pointsArray = [mapView overlays];
[mapView removeOverlays:pointsArray];
Just to add that, for my iPad application, I needed to add an extra line to the solution shown above:
NSArray *pointsArray = [self.mapView overlays];
[self.mapView removeOverlays:pointsArray];
self.mapOverlayView = nil;
Without setting mapOverlayView to nil, the "removeOverlays" call didn't seem to do much (?)
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