Repository navigation
Delegate method to restrict movement - #5584
Conversation
|
I think it’s too late for this feature to make the impending v3.3.0 final release, but we could easily backport it to v3.3.1 if it takes awhile to release v3.4.0. |
|
Note that this API does not affect programmatic movement of the viewport, such as via |
There was a problem hiding this comment.
Should we add the standard, “this method is called many times during gesticulation so you should keep it as lightweight as possible”?
|
This only seems to prevent simple pans, so far. With the new delegate method set to always return |
Oh, you’re right! I took care of all the gesture recognizers for macOS but forgot to follow up for iOS. |
|
Another caveat about this approach is that, if the delegate decides to block the camera change, the camera actually does change (even sending the |
|
👍 |
3366aa8 to
11253ec
Compare
11253ec to
ce3d847
Compare
|
Any chance to see this in v3.3.1 please? |
There was a problem hiding this comment.
This method is unnecessary; use self.zoomLevel instead.
There was a problem hiding this comment.
Use CLLocationDirection to represent the map’s rotation in degrees.
41c6a5b to
97e99e8
Compare
1ec5
left a comment
There was a problem hiding this comment.
Thanks for hanging in there – just a few nits related to coding style.
| // Calculates the final camera zoom, has no effect within current map camera. | ||
| MGLMapCamera *toCamera; | ||
| double zoom = log2(newScale); | ||
| toCamera = [self cameraByZoomingToZoomLevel:zoom aroundAnchorPoint:centerPoint]; |
There was a problem hiding this comment.
Declare and set toCamera on the same line.
| _mbglMap->moveBy({ delta.x, delta.y }); | ||
| [pan setTranslation:CGPointZero inView:pan.view]; | ||
|
|
||
| toCamera = [self cameraByPanningWithTranslation:delta panGesture:pan]; |
There was a problem hiding this comment.
Move the declaration of toCamera down to this line.
|
|
||
| // Calculates the final camera zoom, has no effect within current map camera. | ||
| MGLMapCamera *toCamera; | ||
| double zoom = log2(newScale); |
There was a problem hiding this comment.
Nit: declare this a few lines further up to avoid saying log2(newScale) twice.
|
|
||
| [self animateWithDelay:MGLAnimationDuration animations:^ | ||
|
|
||
| MGLMapCamera *toCamera = [self cameraByZoomingToZoomLevel:newZoom aroundAnchorPoint:gesturePoint]; |
There was a problem hiding this comment.
Nit: s/newZoom/self.zoomLevel + 1/
e6cec13 to
a3e7277
Compare
1ec5
left a comment
There was a problem hiding this comment.
One nit left, but otherwise this is good to go.
There was a problem hiding this comment.
This is redundant: !A || (A && C) is equivalent to !A || C.
My comments in #5584 (review) have been addressed; we’re OK with reporting metrics for aborted gestures; and @incanus’ nits have been addressed as well.
Added a way for the delegate to restrict where the user can move within the map using gestures. Fixes #2457.
… finger drag gestures
a3e7277 to
f9fe145
Compare
f9fe145 to
082e898
Compare
Added a way for the delegate to restrict where the user can move within the map using gestures. This approach allows the developer to restrict to a non-rectangular region or vary the region by zoom level or pitch as necessary, such as to prevent the user from seeing beyond a certain region regardless of the degree of tilt.
This PR intentionally keeps things simple to unblock some key use cases. Future improvements could include implementing a “rubber band” effect, allowing the delegate to “redirect” the camera to some other camera (#2457 (comment)), and automatically restricting the camera to downloaded regions (#5042).
Before we can land this feature:
Fixes #2457.
/cc @boundsj @frederoni @friedbunny