Question

I would like to display annotation callouts automatically after a specific zoom level. However, I do not want to have all the annotation callouts, but only those which are being shown in the screen.

Was it helpful?

Solution

To display annotation callout of those that are visible on screen just the code below should do the trick, as it relies on the selectAnnotation method of MKMapView, of course, after detecting the desired zoom level:

for (MKAnnotation *annotation in mapView.annotations) {
   if ( MKMapRectContainsPoint(mapView.visibleMapRect, MKMapPointForCoordinate(annotation.coordinate)) ) {
       [mapView selectAnnotation:annotation animated:YES];
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top