ios - MapBox 水域/陆地检测

标签 ios objective-c map detection mapbox

我开始使用 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/

相关文章:

iPhone 相机和照片编辑选项 - 自定义应用程序集成

ios - 计算 Firebase 数据库子项并显示

ios - 在malloc_error_break中设置一个断点进行调试

c++ - 引用作为 std::map 中的键

ios - 如何知道您构建的 iOS 应用程序是否适用于 64 位。

ios - didSelectRowAtIndexPath返回界限索引

objective-c - 基于 View "Source List"NSOutlineView 字体平滑问题

ios - 带有 UI 对象的 NSArray(性能)

php - 获取 map 的所有键,例如 $_POST

c++ - C++ 中多种数据类型的通用容器