I have about 400 MKAnnotationView´s that loads simultaneously into the MKMapView.
I understand that this isn't any good, it is a little bit slow, and I want to do it the "correct" way.
I zoom my map by a center coordinate:
MKCoordinateSpan span;
span.latitudeDelta = 0.8;
span.longitudeDelta = 0.8;
MKCoordinateRegion region;
region.span = span;
region.center = self.selectedCounty.coordinate;
[mapView setRegion:region animated:TRUE];
I only want to load the annotations that could be visible in that region.
I have a custom MKAnnotation called simply "Annotation" with a CLLocationCoordinate2D- and title-property.
I simply want to load the annotation for the "visible area" on the MKMapView so not all the annotation loads at the same time. And when the "visible area" on the MKMapView changes, I of course want to load annotations for that area.
I know that MKMapView has a delegate method which runs when the region changes.
But how do I know what annotations I should load for that region?
MKMapRect visibleMapRect = mapView.visibleMapRect;
NSSet *visibleAnnotations = [mapView annotationsInMapRect:visibleMapRect];
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