How can I center a UIMapView around an array of MKAnnotation?
+1
A:
First find the minimum and maximum latitude and longitude from your array of annotations. Then you can set the region:
MKCoordinateRegion extents;
extents.center.latitude = (maxLat + minLat)/2.0;
extents.center.longitude = (maxLong + minLong)/2.0;
extents.span.latitudeDelta = (maxLat - minLat);
extents.span.longitudeDelta = (maxLong - minLong);
MKCoordinateRegion fittedRegion = [mapView regionThatFits:extents];
[mapView setRegion:fittedRegion animated:YES];
aBitObvious
2010-10-28 17:22:27
Thank you, I hoped there was something built in MKMapView. But ok thanks you again
Christophe Debove
2010-10-28 19:49:17