我开始使用MapBox iOS SDK https://www.mapbox.com/mapbox-ios-sdk.
有没有可能的方法通过坐标查询 MapView 并返回地形类型(水、土地)作为结果?
我一直在读API doc https://www.mapbox.com/mapbox-ios-sdk/api已经有一段时间了,但无法弄清楚。
我知道有(临时)解决方案 https://stackoverflow.com/questions/9644452/verify-if-a-point-is-land-or-water-in-google-maps可以使用 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>]
如果为空结果:没有水,如果多边形:水。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)