When I set the display area on iOS 7 to LandscapeRight, everything works fine.
When I rotate the device in LandscapeLeft and load the same region, the map shifts on a wide scale and approaches the far. The zoom level must be multiplied by 100 to fix the problem, i.e. 50,000 becomes 5,000,000, and I need to subtract 23 from the lat and add 3 to the bosom, i.e. (41.0, 29.0) becomes (18.0, 32.0).
After some testing, I can fix such a problem for iOS 7 and iOS 6 (sorry, the iOS version checks it quickly and dirty)
if([[[UIDevice currentDevice] systemVersion] rangeOfString:@"7."].location != NSNotFound){ if(self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft){ CLLocationCoordinate2D startCoord = CLLocationCoordinate2DMake(41.0, 29.0); [_mapView setRegion:MKCoordinateRegionMakeWithDistance(startCoord, 5000000.0, 5000000.0) animated:NO]; }else if(self.interfaceOrientation == UIInterfaceOrientationLandscapeRight){ CLLocationCoordinate2D startCoord = CLLocationCoordinate2DMake(18.0, 32.0); [_mapView setRegion:MKCoordinateRegionMakeWithDistance(startCoord, 50000.0, 50000.0) animated:NO]; } }else{ MKCoordinateRegion region; region.center.latitude = topLeftCoord.latitude - (topLeftCoord.latitude - bottomRightCoord.latitude) * 0.3; region.center.longitude = topLeftCoord.longitude + (bottomRightCoord.longitude - topLeftCoord.longitude) * 0.7; region.span.latitudeDelta = fabs(topLeftCoord.latitude - bottomRightCoord.latitude) * span;
source share