Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Support for a customizable zoom gesture centering strategy. #5302

Merged
merged 2 commits into from
Jun 10, 2016

Conversation

revetkn
Copy link
Contributor

@revetkn revetkn commented Jun 9, 2016

We introduce a new MGLZoomGestureCentering enum and corresponding zoomGestureCentering property on MGLMapView.

Currently, Mapbox automatically adjusts the center of the map relative to the user's gesture location, but for some applications (e.g Uber, Lyft) it is preferable to keep the map center "locked" in response to zoom gestures.

Exisiting code will retain its current behavior without modification and will implicitly use the default value of MGLZoomGestureCenteringFollowsTouch. New code can specify MGLZoomGestureCenteringLockedInPlace to get the new "locked" behavior.

We introduce a new MGLZoomGestureCentering enum and corresponding zoomGestureCentering property on MGLMapView.

Currently, Mapbox automatically adjusts the center of the map relative to the user's gesture location, but for some applications (e.g Uber, Lyft) it is preferable to keep the map center "locked" in response to zoom gestures.

Exisiting code will retain its current behavior without modification and will implicitly use the default value of MGLZoomGestureCenteringFollowsTouch. New code can specify MGLZoomGestureCenteringLockedInPlace to get the new "locked" behavior.
@1ec5 1ec5 added feature iOS Mapbox Maps SDK for iOS labels Jun 9, 2016
@1ec5
Copy link
Contributor

1ec5 commented Jun 9, 2016

Besides the pinch/zoom gesture, the rotation, double-tap, two-finger tap, and double-tap-drag (“quickzoom”) gestures are also anchored to the user location when user tracking mode is on. Currently, these gesture recognizers make use of the -userLocationAnnotationViewCenter method or -locationInView: depending on the user tracking mode. I think we should make all these gestures respect the property you’ve added while simplifying the code: make them all use a new method, -anchorPointForGesture:, that uses either -userLocationAnnotationViewCenter or -locationInView: or -contentCenter depending on the user tracking mode and this new property.

An enum for this property is clearer than a simple Boolean. However, I wonder if it’s flexible enough for the use cases you describe. For example, what if the location you want to lock around is neither the user’s location nor the center of the view? It could be the selected annotation, for example. In that case, I think we could avoid adding a zoomGestureCentering property; instead, we’d have this (public) -anchorPointForGesture: method use -userLocationAnnotationViewCenter or -locationInView: as the individual gesture recognizers do now. Applications that need custom behavior, such as anchoring to the view’s inset center, could subclass MGLMapView and override -anchorPointForGesture: to suit their own needs. Does that sound reasonable?

@revetkn
Copy link
Contributor Author

revetkn commented Jun 9, 2016

What a fast and well-thought-out response...thank you. I agree that overriding a publicly-visible -anchorPointForGesture: method will give users more flexibility than having a fixed-value property. I'll go ahead and rework this pull request.

@revetkn
Copy link
Contributor Author

revetkn commented Jun 9, 2016

OK! Hopefully this is more in line with what you're thinking.

@1ec5 1ec5 merged commit b915f05 into mapbox:master Jun 10, 2016
@1ec5
Copy link
Contributor

1ec5 commented Jun 10, 2016

Perfect, thanks!

1ec5 added a commit that referenced this pull request Jun 10, 2016
1ec5 added a commit that referenced this pull request Jun 10, 2016
1ec5 added a commit that referenced this pull request Jun 10, 2016
1ec5 pushed a commit that referenced this pull request Jun 10, 2016
)

* [ios] Support for a customizable zoom gesture centering strategy.

We introduce a new MGLZoomGestureCentering enum and corresponding zoomGestureCentering property on MGLMapView.

Currently, Mapbox automatically adjusts the center of the map relative to the user's gesture location, but for some applications (e.g Uber, Lyft) it is preferable to keep the map center "locked" in response to zoom gestures.

Exisiting code will retain its current behavior without modification and will implicitly use the default value of MGLZoomGestureCenteringFollowsTouch. New code can specify MGLZoomGestureCenteringLockedInPlace to get the new "locked" behavior.

* [ios] Added -anchorPointForGesture: to MGLMapView

Cherry-picked from b915f05.
1ec5 added a commit that referenced this pull request Jun 10, 2016
@1ec5
Copy link
Contributor

1ec5 commented Jun 10, 2016

Updated changelog in 6998479. Cherry-picked to the v3.3.0 release branch in dd565b7 and 383df9d.

@1ec5 1ec5 added this to the ios-v3.3.0 milestone Jun 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants