【问题标题】:Get current place name (in nsstring ) from the coordinates从坐标中获取当前地名(在 nsstring 中)
【发布时间】:2012-04-06 06:59:39
【问题描述】:

我有当前位置的坐标,但如何将这些坐标转换为地名?我不想显示地图视图。由于 MKReverseGeocoder 在 iOS 5 中已被弃用,有没有其他方法可以实现这一点。 提前致谢。

【问题讨论】:

    标签: objective-c ios cocoa-touch ipad coordinates


    【解决方案1】:

    您可以访问 Google Places Api

    http://maps.google.com/maps/geo?q=yourSearchName&output=xml

    这将提供有关所提供的搜索名称的详细信息。您可以解析 xml 并从该详细信息中获取纬度和经度,并可以对这些位置进行 pin 注释。

    输出也可以是 json 和 csv。

    一些可以提供帮助的代码

     NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",coordinate];   //coordinate=-30.347744,71.3737373
     NSString *locationString = [NSString  stringWithContentsOfURL:[NSURL URLWithString:urlString]];
     NSArray *listItems = [locationString componentsSeparatedByString:@","];
    

    参考谷歌 API Here

    【讨论】:

    • 谢谢,但有什么办法不使用 xml 或 json 和 csv?仅使用 iOS api。
    • 我认为 Apple 转移到了 CLGeocoder,而不是 MKReverseGeocoder。尝试使用它。 developer.apple.com/library/ios/#documentation/CoreLocation/…
    • 是否有任何示例代码?我见过 CLGeocoder,但我不知道如何实现它,我没有错,我们必须为此使用 map。
    • CLGeocoder 的示例代码可以在位置感知编程指南中找到。
    • 你能发布一些示例代码吗?我无法弄清楚位置感知编程指南中的代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多