开发者

how to get current latitude & longitude

How to get current latitude & longitude without

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLL开发者_高级运维ocation *)oldLocation {

} 

using this method

and if i used this function , how much distance i have to travel.... so that this method will be called by corelocation framework or can i call this function programmatic ....


The CLLocationManager is the interface you must use in order to get information about the location of the device.

You can initialise and begin getting location updates whenever you like. The CLLocationManager will notify your delegate whenever a new location is received.

locationManager = [[CLLocationManager alloc] init]; 
locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
locationManager.distanceFilter = DISTANCE_FILTER_VALUE;
locationManager.delegate = self; 
[locationManager startUpdatingLocation];


Note that when you try to get the values while using a simulator and do:

nsLog(locationManager.location.coordinate.latitude); // it will give you zero

And if you use the mapkit to get the lat and long it will give you the coordinates of apple main office (If im not mistaken).

I thought that it take so much time before it actually gets your location but when I try to run it in the actual device it prompts the allow device to get current location immediately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜