我是iOS開發新手。我有一個經度和緯度值。我想使用經緯度來獲取位置的名稱?在iOS中可能嗎?從經緯度的iOS位置
0
A
回答
2
是的,它可能叫做reverse geocoding。您需要先導入CoreLocation
框架,然後在iOS5(及更高版本)中使用CLGeocoder
。對於iOS4和低於其mkreversegeocoder
。以下是如何使用CLGeocoder獲取地址,只需將它提供給位置對象,剩下的就完成了。
[self.geoCoder reverseGeocodeLocation: locationManager.location completionHandler:
^(NSArray *placemarks, NSError *error) {
//Get nearby address
CLPlacemark *placemark = [placemarks objectAtIndex:0];
//String to hold address
NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
//Print the location to console
NSLog(@"I am currently at %@",locatedAt);
}];
的placemarks
陣列,你得到的是CLPlacemark
對象的實例。 IT讓您訪問 -
Accessing the Placemark Attributes
name property
addressDictionary property
ISOcountryCode property
country property
postalCode property
administrativeArea property
subAdministrativeArea property
locality property
subLocality property
thoroughfare property
subThoroughfare property
region property
0
是的。 iOS5及更高版本可以使用CLGeocoder
。
如果您必須支持以前的操作系統版本,則可以使用MKReverseGeocoder
。
0
除了MKReverseGeocoder,我建議你使用google api。我在我的應用程序中使用它,沒有崩潰和快速響應。
1
另一種簡單的方法是使用谷歌地圖的REST API,使Web服務調用到以下網址,它會返回一個包含JSON位置的詳細信息
http://maps.googleapis.com/maps/api/geocode/json?latlng=10.03,10.03&sensor=false
相關問題
- 1. iOS從郵政編碼查找位置(經度,緯度)
- 2. 從經緯度獲取位置名稱
- 3. 從經緯度獲取位置地址
- 4. 限制位置的經度和緯度
- 5. NullPointerException經度和緯度上的位置
- 6. 經度緯度點的奇怪位置
- 7. JSON經度緯度最近的位置
- 8. 位置的經度和緯度
- 9. IOS獲取位置與CLLocationManager從經緯度
- 10. 經緯度從位置A到位置B的路線圖
- 11. 當前位置,經度和緯度
- 12. 位置(經度,緯度)返回0
- 13. 錯誤位置緯度/經度
- 14. 獲取位置(經度和緯度)
- 15. IOS:緯度/經度矩形
- 16. 找到當前位置的經緯度
- 17. 附近地點的經緯度位置
- 18. 獲取當前位置的經緯度
- 19. 設置位置緯度/經度從edittext獲取值
- 20. 如何從android的位置服務獲取緯度和經度
- 21. 如何從緯度/經度獲取附近的位置?
- 22. 從已知位置確定預測的經度/緯度
- 23. 如何從googleapis中考慮緯度和經度的位置
- 24. 使用Javascript從位置獲取經度和緯度的函數
- 25. 從Geocoder獲取經度和緯度值的位置更新
- 26. android經緯度位置查找器
- 27. Android地理位置打印經緯度
- 28. jQuery GeoComplete - 初始位置經緯度
- 29. 獲得塔GSM位置經緯度LNG
- 30. 地理位置Null經緯度爲
mkreversegeocoder是舊的過時的API。你應該使用'CLGeocoder',請在有人低估 –
之前更正你的答案啊,謝謝你的評論。我會編輯我的答案。 – barley