[英]How to get current location's longitude and latitude in iOS 4.0/4.2?
我有問題獲取當前位置iOS 4.0中的經度和緯度也嘗試在iOS 4.2中實際上我想在我的應用程序上繪制從當前位置到特定位置的路線,我在我的應用程序中嘗試了很多方法但我無法獲得結果
請回復任何人知道這個。
謝謝!! :)
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];
下載此示例
這個例子將顯示當前的lat long
您需要調用CLLocationManager(請參閱Apple文檔 )。 - startUpdatingLocation
和 - stopUpdatingLocation
是您將使用的主要方法之一。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.