How do I zoom an MKMapView to the users current location without CLLocationManager?
- by Danny Tuppeny
With the MKMapView there's an option called "Show users current location" which will automatically show a users location on the map.
I'd like to zoom into this location without adding a CLLocationManager (this seems silly if the map is already taking care of this).
The problem is, I can't find a nice event that fires when the map has figured out the users location, so I don't know where to put the code that will zoom/scroll.
I tried using the viewForAnnotation method like this:
- (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation class] == [MKUserLocation class] ) {
NSLog(@"UserLocation annotation");
return [map viewForAnnotation:annotation];
}
return nil;
}
However it doesn't fire if the users location is off the screen.
Is there a way to be notified when an MKMapView has got the user location so I can zoom in to it, or do I just have to add a CLLocationManager for this?