iPhone current user location coordinates showing as (0,0)

Posted by ennuikiller on Stack Overflow See other posts from Stack Overflow or by ennuikiller
Published on 2009-09-19T20:50:18Z Indexed on 2010/05/02 5:07 UTC
Read the original article Hit count: 332

Filed under:
|
|

I'm trying to get the users current latitude and longitude with this viewDidLoad method. The resulting map is correctly indicating the current location however the NSLog consistently shows:

2009-09-19 16:45:29.765 Mapper[671:207] user latitude = 0.000000
2009-09-19 16:45:29.772 Mapper[671:207] user longitude = 0.000000

Anyone know what I am missing here? Thanks in advance for your help!

- (void)viewDidLoad {
    [super viewDidLoad];
    [mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    [mapView setShowsUserLocation:YES];

    CLLocation *userLoc = mapView.userLocation.location;
    CLLocationCoordinate2D userCoordinate = userLoc.coordinate;

    	NSLog(@"user latitude = %f",userCoordinate.latitude);
    	NSLog(@"user longitude = %f",userCoordinate.longitude);






}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about mapkit