Mapbox iOS:如何为 geometry/equivalent getCameraForGeometry 获取相机

Mapbox iOS: How get camera for geometry/equivalent for Android getCameraForGeometry

我正在尝试将地图集中在 FeatureCollection 中的某个要素上。在 Mapbox Android SDK 中,MapboxMap 上有一个名为 getCameraForGeometry 的方法,我可以在其中传递要素的几何形状并获得所需的地图位置。

如何为 iOS 版本的 Mapbox SDK 做同样的事情?

您可以使用 [MGLMapView camera:fittingShape:edgePadding:] or [MGLMapView cameraThatFitsShape:direction:edgePadding: 更改相机以包含特定的形状或功能。

如果您有想要显示的注释,也可以使用 [MGLMapView showAnnotations:animated:] 或相关方法之一。