MKMapView show incorrectly saved region

The issue here is when you set the region, the map zoom level “snaps” out to the nearest zoom threshold. (I suspect these zoom thresholds are the amounts of zoom you get when you double-tap or two-finger-tap)

So if the map is showing zoom level 1 for instance, and you set the region to that same span value thusly: region = [mapView region]; [mapView setRegion:region]; it will “snap” out to the nearest zoom level above level 1, i.e. level 2 and you will zoom out by about a factor of two.

The workaround for the original poster is to reduce the span values slightly before setting the region, so that when the view snaps out, it snaps out to the zoom level it was on, not the one above.

e.g.

region.span.latitudeDelta = [[NSUserDefaults standardUserDefaults] doubleForKey:@"map.location.span.latitude"] * 0.999;

region.span.longitudeDelta = [[NSUserDefaults standardUserDefaults] doubleForKey:@"map.location.span.longitude"] * 0.999;

If the user had been zooming with double-taps (and hence jumping from threshold to threshold) this works pretty well, returning them to the same view almost exactly.

However if they pinch-zoom and the view is halfway between the zoom thresholds it will still snap out to the next level. Not so good in that case but there is no fix as yet.

There are open bugs on Apple radar for this, hopefully it will be fixed in a future release.

Leave a Comment