我是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