You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We encountered problem that we cannot adjust or track gesture while it is in progress as we cannot track it. We suggest to add new method func gestureManager(_ gestureManager: GestureManager, didChange gestureType: GestureType). It will allow to track gesture progress and update other views or map, if we want specific behaviour like zoom only to centre.
Why
In mapbox 6 there was "regionIsChanging" delegate which we used and anchorPoint method for gestures where we could adjust centre point when user performs a gesture. In new version there no such methods or they are not as obvious to use. We need this, for example, to update angle slider when user rotate map with pinch gesture and also to update map centre while zooming with pinch so map won't move (forbid pan gesture while zooming)
The text was updated successfully, but these errors were encountered:
anchorPoint method for gestures is being added in #1122
to observe camera changes during a gesture, you can add an onEvery(.cameraChanged) listener when the gesture begins and cancel it when the gesture ends.
Something like this…
final class ViewController: UIViewController {
var mapView: MapView!
var cameraChangedCancelable: Cancelable?
override func viewDidLoad() {
super.viewDidLoad()
mapView = MapView(frame: view.bounds)
mapView.gestures.delegate = self
view.addSubview(mapView)
}
}
extension ViewController: GestureManagerDelegate {
func gestureManager(_ gestureManager: GestureManager, didBegin gestureType: GestureType) {
cameraChangedCancelable = mapView.mapboxMap.onEvery(.cameraChanged, handler: { [weak self] _ in
guard let self = self else { return }
// do something with camera state here
print("camera: \(self.mapView.cameraState)")
})
}
func gestureManager(_ gestureManager: GestureManager, didEnd gestureType: GestureType, willAnimate: Bool) {
if !willAnimate {
cameraChangedCancelable?.cancel()
}
}
func gestureManager(_ gestureManager: GestureManager, didEndAnimatingFor gestureType: GestureType) {
cameraChangedCancelable?.cancel()
}
}
New Feature
We encountered problem that we cannot adjust or track gesture while it is in progress as we cannot track it. We suggest to add new method
func gestureManager(_ gestureManager: GestureManager, didChange gestureType: GestureType)
. It will allow to track gesture progress and update other views or map, if we want specific behaviour like zoom only to centre.Why
In mapbox 6 there was "regionIsChanging" delegate which we used and anchorPoint method for gestures where we could adjust centre point when user performs a gesture. In new version there no such methods or they are not as obvious to use. We need this, for example, to update angle slider when user rotate map with pinch gesture and also to update map centre while zooming with pinch so map won't move (forbid pan gesture while zooming)
The text was updated successfully, but these errors were encountered: