如何通过调整缩放级别将所有坐标包含在 MapBox 中?

How can I include all the coordinates in the MapBox by adjusting the zoom level?

我用过的代码是:

let bounds = MGLCoordinateBounds(
    sw: CLLocationCoordinate2D(latitude: 40.7115, longitude: 10.3725),
    ne: CLLocationCoordinate2D(latitude: 40.7318, longitude: 10.4222))
    mapView.setVisibleCoordinateBounds(bounds, animated: false)

我有 3 个注释,我想通过调整缩放级别在 mapBox 中看到这 3 个注释。请帮我找出来。

MGLMapView 上有您可以使用的方法:

func showAllAnnotations() {
    guard let annotations = mapView.annotations else { return }

    // Either this...
    mapView.showAnnotations(annotations, edgePadding: UIEdgeInsets(top: 40, left: 35, bottom: 35, right: 35), animated: true)
    // or this.
    mapView.showAnnotations(annotations, animated: true)
}