我开始使用 MapBox iOS SDK .
有什么方法可以通过坐标查询 MapView 并返回地形类型(水域、陆地)作为结果?
我一直在阅读 API doc现在已经有一段时间了,但无法弄清楚。 我知道有 (interim) solutions可以使用 Google 网络服务,但我需要它才能离线工作。
虽然我不受 MapBox 的约束(但我喜欢它),但感谢您的任何提示!
最佳答案
无需深入研究运行时样式(请参阅我的其他答案,错误引导):使用 mapView.visibleFeatures(at: CGPoint, styleLayerIdentifiers: Set<String>)
的非常简单的方法javascript API 的等价物是 queryRenderedFeatures
.
func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool)
{
let features = mapView.visibleFeatures(at: mapView.center, styleLayerIdentifiers: ["water"])
print(features)
}
四处移动时的示例输出:
[]
[]
[]
[<MGLMultiPolygonFeature: 0x170284650>]
如果结果为空:没有水,如果多边形:水。
关于ios - MapBox 水域/陆地检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19775585/