I'm working on component using MKMapView. Map should double zoom on annotation tap. To do this, I try to reduce twice map region span, but sometimes it works incorrectly: Here peace of code:
MKCoordinateSpan newSpan = mapView.region.span;
NSLog(@"old: %f, %f", newSpan.latitudeDelta, newSpan.longitudeDelta);
newSpan = MKCoordinateSpanMake(newSpan.latitudeDelta / 2.0, newSpan.longitudeDelta / 2.0);
NSLog(@"new: %f, %f", newSpan.latitudeDelta, newSpan.longitudeDelta);
MKCoordinateRegion region = [mapView regionThatFits:MKCoordinateRegionMake(centerCoordinate, newSpan)];
NSLog(@"!!!! (%f, %f) (%f, %f)", region.center.latitude, region.center.longitude, region.span.latitudeDelta, region.span.longitudeDelta);
I take current span, reduce it and pass to regionThatFits. Sometimes results are:
old: 0.609257, 0.914612
new: 0.304629, 0.457306
!!!! (55.805472, 37.579371) (0.608178, 0.914612)
regionThatFits doubles span passed to it. So visual effect is centering of view annotation without zooming.
Any suggestions?