如何在iOS 4.0/4.2中获取当前位置的经度和纬度?

ALP*_*IYA 5 iphone objective-c cllocationmanager ios4 ios-4.2

我有问题获取当前位置iOS 4.0中的经度和纬度也尝试在iOS 4.2中实际上我想在我的应用程序上绘制从当前位置到特定位置的路线,我在我的应用程序中尝试了很多方法但我无法获得结果

请回复任何人知道这个.

谢谢!!:)

Bil*_*ess 16

CLLocationManager *lm = [[CLLocationManager alloc] init];
lm.delegate = self;
lm.desiredAccuracy = kCLLocationAccuracyBest;
lm.distanceFilter = kCLDistanceFilterNone; 
[lm startUpdatingLocation];

CLLocation *location = [lm location];

CLLocationCoordinate2D coord;
coord.longitude = location.coordinate.longitude;
coord.latitude = location.coordinate.latitude;
// or a one shot fill
coord = [location coordinate];
Run Code Online (Sandbox Code Playgroud)


Dro*_*oid 5

下载此示例

这个例子将显示当前的lat long