How do I zoom an MKMapView to the users current location without CLLocationManager?
        Posted  
        
            by Danny Tuppeny
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Danny Tuppeny
        
        
        
        Published on 2010-03-18T22:13:04Z
        Indexed on 
            2010/03/29
            9:33 UTC
        
        
        Read the original article
        Hit count: 909
        
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?
© Stack Overflow or respective owner