There is one nagging bug, though: sometimes setting the map to a region will end up zoomed out too far. What appears to be happening, and has been confirmed by others in this thread over at stackoverflow, is that the span values are essentially doubled. A doubled span means a greater area is viewed, equating to a zoomed out view.
This bug didn't happen all the time, but recently it now happens to me ALL the time on the simulator. Others say the bug persists on the actual device as well.
Until Apple fixes this bug, I needed to provide a fix to get around this annoying defect. The error seems to be introduced when assigning the region to the map:
[self.mapView setRegion:myRegion animated:YES];
[self.mapView setRegion:myRegion animated:YES];
// did the span get screwed up?
if(self.mapView.region.span.latitudeDelta != myRegion.span.latitudeDelta ) {
NSLog(@"Span got doubled, adjusting");
// hack to fix span doubling bug
MKCoordinateRegion temp = MKCoordinateRegionMake(myRegion.center,
MKCoordinateSpanMake(myRegion.span.latitudeDelta/2.0,
myRegion.span.longitudeDelta/2.0));
[self.mapView setRegion:temp animated:YES];
}
I observe the same issue, however according to the test MapKit is not dobling span, it sets the region returned by regionThatFits. So this looks like an Apple issue.
ReplyDelete