【问题标题】:Get name of closest business using Swift's CoreLocation使用 Swift 的 CoreLocation 获取最近的企业名称
【发布时间】:2016-12-28 02:53:30
【问题描述】:

我想根据经度和纬度获取商家的名称。还有其他 API 可以做到这一点,例如 Google Places,但如果我能提供帮助,我宁愿在我的应用程序中不要有额外的依赖项。有没有办法通过 Swift 中的 CoreLocation 来做到这一点?我知道您可以使用以下方法从纬度和经度中获取地址“名称”:

let geocoder = CLGeocoder()
geocoder.reverseGeocodeLocation(location) { (placemarks, error) in
    placemarks?.first?.name
}

但这只是给了我门牌号,而不是像“Costco”这样的公司的实际名称或它的真正名称。

【问题讨论】:

    标签: swift gps mapkit cllocation reverse-geocoding


    【解决方案1】:

    您可以使用 CLPlacemark 中的 Areas of Interest 信息,如文档中所示:

    感兴趣区域的示例是军事基地的名称,大型 国家公园,或埃菲尔铁塔、迪斯尼乐园等景点, 或金门公园

    在这里查看:https://developer.apple.com/reference/corelocation/clplacemark/1423673-areasofinterest

    这里有所有可用的信息: https://developer.apple.com/reference/corelocation/clplacemark

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-20
      • 2022-08-14
      • 1970-01-01
      • 1970-01-01
      • 2011-05-05
      • 2022-11-29
      • 2018-02-05
      相关资源
      最近更新 更多