Reputation: 5044
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.
Upvotes: 4
Views: 5066
Reputation: 29161
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 (?)
Upvotes: 2
Reputation: 547
This will work
NSArray *pointsArray = [mapView overlays];
[mapView removeOverlays:pointsArray];
Upvotes: 10