Как я могу включить все координаты в MapBox, регулируя уровень масштабирования? - PullRequest
0 голосов
/ 05 марта 2019

Код, который я использовал:

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 аннотации, и я хочу увидеть 3 аннотации в mapBox, отрегулировав уровень масштабирования.Пожалуйста, помогите мне узнать это.

1 Ответ

0 голосов
/ 05 марта 2019

На 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)
}
...