Reputation:
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.
Upvotes: 2
Views: 1787
Reputation: 767
Swift 6
Using mapView.gestures.pinchGestureRecognizer
worked for me
override func viewDidLoad() {
super.viewDidLoad()
mapView.gestures.pinchGestureRecognizer.addTarget(self, action: #selector(handleZoom))
}
@objc private func handleZoom(_: UIBarButtonItem) {
// Do whatever you need to do when the zoom value changes
print(mapView.cameraState.zoom)
}
Upvotes: 0