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

Let MGLMapViewDelegate cancel region changes #2457

Closed
1ec5 opened this issue Sep 29, 2015 · 6 comments
Closed

Let MGLMapViewDelegate cancel region changes #2457

1ec5 opened this issue Sep 29, 2015 · 6 comments
Labels
feature iOS Mapbox Maps SDK for iOS

Comments

@1ec5
Copy link
Contributor

1ec5 commented Sep 29, 2015

-[MGLMapViewDelegate mapView:regionWillChangeAnimated:] should return a Boolean, so that delegates can cancel impending viewport changes by return NO. If the viewport change was initiated programmatically, perhaps the return value should be ignored, but it should at least be honored for viewport changes initiated by gesture recognizers.

/cc @friedbunny @incanus

@1ec5 1ec5 added feature iOS Mapbox Maps SDK for iOS labels Sep 29, 2015
@1ec5
Copy link
Contributor Author

1ec5 commented Nov 20, 2015

Instead of overloading -mapView:regionWillChangeAnimated:, I think it would be better to have a -mapView:shouldChangeToCamera:animated: that takes an additional MGLMapCamera object, so that the implementer can make an informed decision about the animation that will take place. Or, following NSAnimationDelegate in AppKit, we could pass in an MGLMapAnimation object that encapsulates all the known information about an animation: its start and endpoints as well as the action that triggered the animation.

@1ec5
Copy link
Contributor Author

1ec5 commented Nov 20, 2015

#3090 would serve as a model for this method.

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 21, 2015

On iOS, the map view would ideally allow the user to pan to a disallowed region but quickly snap back to within the allowed region as soon as the gesture is complete. So if -mapView:shouldChangeToCamera:animated: returns NO, the transition should continue but a bounce-back transition should be queued up, to be run immediately after the disallowed change.

@Zakay
Copy link

Zakay commented Feb 29, 2016

+1 This is a great addition!

@dsmitchell
Copy link

Hey, I'm new here. As a possible variation/update to this proposal, UIScrollView has a delegate method called: - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
withVelocity:(CGPoint)velocity
targetContentOffset:(inout CGPoint *)targetContentOffset

which lets the implementor provide a replacement offset to complete the animation with. What if the implementor can provide an alternate MGLCamera to animate to?

@1ec5
Copy link
Contributor Author

1ec5 commented Jul 5, 2016

For starters, I’ve implemented the simplest possible API in #5584.

The camera-redirecting API proposed in #2457 (comment) would be more complex both to implement and use effectively, but I’m not opposed to that design if we can make it work. The current mbgl transform API is the limiting factor right now.

@1ec5 1ec5 modified the milestone: ios-v3.3.1 Jul 6, 2016
1ec5 added a commit that referenced this issue Jul 10, 2016
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
1ec5 added a commit that referenced this issue Jul 19, 2016
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
1ec5 added a commit that referenced this issue Oct 17, 2016
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
1ec5 added a commit that referenced this issue Dec 14, 2016
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
fabian-guerra pushed a commit that referenced this issue Jan 27, 2017
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
fabian-guerra pushed a commit that referenced this issue Feb 2, 2017
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
fabian-guerra pushed a commit that referenced this issue Feb 7, 2017
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
fabian-guerra pushed a commit that referenced this issue Feb 8, 2017
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
fabian-guerra pushed a commit that referenced this issue Feb 9, 2017
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
fabian-guerra pushed a commit that referenced this issue Feb 9, 2017
Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.
fabian-guerra pushed a commit that referenced this issue Feb 9, 2017
* [ios, macos] Added delegate method to restrict movement

Added a way for the delegate to restrict where the user can move within the map using gestures.

Fixes #2457.

* [ios] Added support to restrict movement in pinch/rotate gestures

* [ios] Added support to restrict movement in double tap/quick zoom/two finger drag gestures

* [ios] fixed camera reset before two finger drag gesture is complete

* [ios] fixed camera comparison in double tap gestures

* [ios] Changelog update

* [macos] Changelog updated

* [ios, macos] Changelog cleanup

* [ios, macos] Added documentation to clarify performance impact

* [ios] clarified variable name

* [ios] blocking gestures implementation changed to a predictive approach

* [ios] gesture delegate methods refactoring

* [ios] Removed duplicated methods, improved code readability

* [ios] code refactoring to clarify the conditions to execute a gesture
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

No branches or pull requests

3 participants