I have a map view with a large quantity of annotations (3000+), when the user is zoomed to a reasonable level all is well and fast.
Although when the user zooms out and
As I understand your code, you are hiding all the annotations' views if the mapView is zoomed out more than a certain specified value.
It seems to me that something more like the following would be better:
- (void)mapView: (MKMapView*)_mapView regionDidChangeAnimated: (BOOL)animated
{
if (_mapView.region.span.latitudeDelta > .010 && self.mapViewsHidden == NO) {
for (MapAnnotation* annotation in _mapView.annotations) {
[[_mapView viewForAnnotation: annotation] setHidden: YES];
}
[self.warningLabel setHidden: NO];
[self setMapViewsHidden: YES];
}
else if (_mapView.region.span.latitudeDelta <= .010 && self.mapViewsHidden == YES) {
for (MapAnnotation* annotation in _mapView.annotations) {
[[_mapView viewForAnnotation: annotation] setHidden: NO];
}
[self.warningLabel setHidden: YES];
[self setMapViewsHidden: NO];
}
}
With the above, in most cases the only thing this code does is a couple of if checks.
Another solution would be to remove the annotations when they shouldn't show on the map. Personally, I think this would be better, that way the code doesn't have to create views for annotations that haven't been shown on the map yet.