How do I retain zoom level and visible region for an MKMapView during orientation change?

61 views Asked by At

I am using MKMapView in one of my map. Let's say I zoom into see a region in portrait and after I change the orientation of the device, I want the map to show the same region before I do the rotation.

I have tried storing the Region and VisibleMapRect before the rotation (from the WillRotate method) and applying it back after the rotation finishes (in the DidRotate method).

But its not working as expected. Because in portrait orientation the visible region is more like a square, when I apply this visible region in landscape, some padding is added in both the sides to the map, since the map has more width now. So basically the visible region is increased more. Now again if I rotate the device to portrait, it tries to set this increased visible region, not the original square region.

0

There are 0 answers