swift - 使用 Swift 的 CoreLocation 获取最近的企业名称

标签 swift gps mapkit cllocation reverse-geocoding

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

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

但这只给我提供了街道号码,而不是企业的实际名称,例如“Costco”或其他真正的名称。

最佳答案

您可以使用来自 CLPlacemark兴趣领域信息,如文档中所示:

Examples of an area of interest are the name of a military base, large national park, or an attraction such as the Eiffel Tower, Disneyland, or Golden Gate Park

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

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

关于swift - 使用 Swift 的 CoreLocation 获取最近的企业名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41354744/

相关文章:

ios - MKMapView:如何将 MKUserLocationView(蓝点)置于最前面?

深色模式下的 iOS 13 UIBarButtonItem 颜色

ios - 在使用 Core Data 解包 Optional 值时意外发现 nil

java - GPS 和地理定位如何在 Android 设备上发挥作用

android - NMEA 语句 - PGLOR、GNGSA 和 QZGSA

ios - Iphone map 套件 : displaying a image on a map

ios - 快速背景颜色动画循​​环

swift - 如果声明在公共(public)职能中不起作用? [Swift 3.0 - Xcode]

ios - 指定任务之间的时间 - iOS

iphone - 使 map 图钉从簇中分散开来