-
-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constrain panning on single-world map #3738
Constrain panning on single-world map #3738
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3738 +/- ##
==========================================
+ Coverage 86.36% 86.86% +0.49%
==========================================
Files 240 240
Lines 32262 32273 +11
Branches 1973 1963 -10
==========================================
+ Hits 27864 28033 +169
+ Misses 3458 3308 -150
+ Partials 940 932 -8 ☔ View full report in Codecov by Sentry. |
Thanks for taking the time to open this PR! |
Bottom line, code-wise this looks, but I think a bit more tests are needed here. |
In this solution map always fills the whole viewport. This is perhaps a disatvantage of this approach. Can it be critical for a user to see the whole globe at once? IDK. There are 2 more possible solutions where you can view the whole map:
For the above reason (user can't view the whole globe) it can be regarded as a breaking change. |
There was a problem in my initial solution. When the zoomed map was "thrown" hard against the horizontal edge, the center lng soon reached some extreme values, they were wrapped and therefore map switched to the opposite side of the globe.
Right, there are some interesting details...
When it tries to zoom in/out near the edges of the globe, the horizontal constraint leads to a slightly weird trajectory. Here in the end of animation it switches from smooth curve to a rather linear movement: flyTo.single-globe.mp4Actually this is not exactly a new problem: vertical constraints also lead to bad trajectory on flyTo. Perhaps it would be a good (and feasible) idea to restrict the "zooming curve" of flyTo in certain situations (By looking at zoom level and coordinate we can deduce that we are close to some constraint and therefore flyTo shouldn't zoom out too much). Didn't fix this yet. Same zooming problem applies to
If you call something like easeTo.mp4
What should happen when marker/popup is animated horizontally by incrementing its lng? |
Thanks for looking into all aspects of this change! |
This PR fixes an ugly panning behaviour on a single-world map (when
{renderWorldCopies: false}
).AFAIK there was no relevant issue.
CHANGELOG.md
under the## main
section.Wrong behaviour: when panning the map to the far left/right, map appears on the opposite side of the viewport with a splash of special effects.
How I suggest to improve it: constrain the panning on single-world map so that the map always fills the whole viewport width.
Solution is to set
transform.lngRange
(that normally comes frommaxBounds
) to the full globe width.Unfortunately when I tried to set lngRange to
[-180, 180]
, it didn't work (it's treated as if there are no bounds at all). For this reason I had to use "almost 180".single.world.panning.mp4