How can I detect a change in zoom level in mapbox map?

1.5k views Asked by At

I am trying to change certain properties of a map and of things on a map when as the user zooms in or out certain distances. How can this be achieved? I have tried:

func mapView(_ mapView: MGLMapView, didChange mode: MGLUserTrackingMode, animated: Bool) {
    print(mode, "This is the mode")
    print(mapView.centerCoordinate, "This is the map view ")
}

But That did not seem to print anything inside the method when I moved around.

1

There are 1 answers

0
Shamas S On BEST ANSWER

You can use the delegate method for this. mapView:regionDidChangeAnimated:

A complete list is mentioned here.

func mapViewRegionIsChanging(_ mapView: MGLMapView) {
    print(mapView.zoomLevel, " Cenetr -<<<<")
}