我想根据纬度和经度获取企业名称。还有其他 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/