Remove MKMapView overlay on the Push button

I have MKMapView with MKOverlay above it showing the user's location history. By clicking a button, how can I drop this overlay and remove it from view?

I tried [map removeOverlay:overlay]; but this does not work - it is still displayed.

+4
source share
2 answers

It will work

 NSArray *pointsArray = [mapView overlays]; [mapView removeOverlays:pointsArray]; 
+10
source

Just add that for my iPad application I need to add an extra line for the solution shown above:

  NSArray *pointsArray = [self.mapView overlays]; [self.mapView removeOverlays:pointsArray]; self.mapOverlayView = nil; 

Without setting mapOverlayView to nil, calling "removeOverlays" doesn't seem to do much (?)

+2
source

Source: https://habr.com/ru/post/1379534/


All Articles