views:

109

answers:

2

Hello,

On the first time the user tries to use the current location the map.userslocation property has coordinates of 0,0. The next time I load the view containing the map the users location is always found.

I am setting the map.showsUserLocation property to YES on viewDidLoad and when the map loads on the screen the blue dot is there but when I try to get the coordinates with map.userlocation.coorinate they are 0,0.

The program flow goes -(void) viewDidLoad: 1) set showUserLocation to YES 2) Set a timer to call a method 6 seconds later that grabs the users location from the map.userLocation property

-(void) getUsersLocation 1) print out the users location

This process works great after the first time I load the view, but the first time the view is laoded and the user has to grant permission to use their location the coordinates come back 0,0

Anybody have any idea why this happens and how I can work around it?

Thanks!

+2  A: 

rather than arbitrarily waiting six seconds, you should be implementing CLLocationManagerDelegate and noticing when

locationManager:didUpdateToLocation:fromLocation:

is called to give you the first location update, which might take more or less time than that.

David Maymudes
+1  A: 

David is right, but I've noticed that I do sometimes get that method called with a location of 0,0. You should ignore any such calls, unless you think your app may be being used in the sea off the west coast of Africa.

Jane Sales