Forked from Proper-Job/gist:e11cca67e77285566d4d
Last active
August 29, 2015 14:20
-
-
Save gotomanners/dca360cc762852a7b1d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated | |
{ | |
if (!self.manuallyChangingMap) { | |
BOOL updateRegion = NO; | |
MKCoordinateRegion restrictedRegion = [self restrictedRegion]; | |
if ((mapView.region.span.latitudeDelta > restrictedRegion.span.latitudeDelta * 4) || (mapView.region.span.longitudeDelta > restrictedRegion.span.longitudeDelta * 4) ) { | |
updateRegion = YES; | |
} | |
if (fabs(mapView.region.center.latitude - restrictedRegion.center.latitude) > restrictedRegion.span.latitudeDelta) { | |
updateRegion = YES; | |
} | |
if (fabs(mapView.region.center.longitude - restrictedRegion.center.longitude) > restrictedRegion.span.longitudeDelta) { | |
updateRegion = YES; | |
} | |
if (updateRegion) { | |
self.manuallyChangingMap = YES; | |
[mapView setRegion:region animated:YES]; | |
self.manuallyChangingMap = NO; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment