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

问题描述 投票:-1回答:1

我使用的代码是:

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个注释。请帮我找出来。

annotations coordinates zoom mapbox
1个回答
2
投票

你可以使用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)
}
© www.soinside.com 2019 - 2024. All rights reserved.