When I load my mapView I have only one tick – user location. After some actions I’m adding more pins. But focus is still in user location. I want to magnify the image in order to see all targets. How can I do this?
My code:
-(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
if (views.count == 1) {
MKAnnotationView *annotationView = [views objectAtIndex:0];
id<MKAnnotation>mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 500, 500);
[mapView setRegion:region animated:YES];
} else {
for (NSUInteger i = 0; i<views.count; i++) {
[mapView addAnnotation:[views objectAtIndex:i]];
}
}
}
MkCoordinateRegion has a member called span. In order to zoom in/out , you have to play with that value:
Hope this helps.
Cheers!