I have these two methods that I use to lock onto the user’s location in Maps, and it works perfectly…
However, I guess it works too well lol, whenever I the user moves the map to look else where on the map… It forces the user back to the spot were the current location is at.
So I guess my question is, how can i disable the lock to user location, after the user scrolls in the map.
- (void)viewDidLoad {
// more code here that i didn't post
[self.mapView.userLocation addObserver:self
forKeyPath:@"location"
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
context:NULL];
}
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if ([self.mapView showsUserLocation]) {
MKCoordinateRegion region;
region.center = self.mapView.userLocation.coordinate;
MKCoordinateSpan span;
span.latitudeDelta = 1; // Change these values to change the zoom
span.longitudeDelta = 1;
region.span = span;
[self.mapView setRegion:region animated:YES];
}
}
Okay, so i think i figured it out… the way i am currently doing it above seems to be the hard way… in iOS 5 they allow use to use this method and it worked like a charm