-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
map.fitBounds
does not account for padding options when used with globe projection
#12498
Comments
Hello @simengjermundsen . We added support for |
I tried this one from npm. No difference unfortunately :( "node_modules/mapbox-gl": { |
Are you using any extra padding on either the viewport to offset the vanishing point or as a parameter to this API? And does removing it make any difference? |
Yes! Without any padding all countries scale perfectly to the entire screen. (I need the padding though :) But this probably narrows things down?) |
Yes it does! Thanks for the information :) I'll reword the title to be more precise and flag as a bug; it's an overlook and padding options are not currently accounted for in that specific code path. |
Thank you! |
map.fitBounds
does not account for padding options when used with globe projection
Same issue with cameraForBounds also btw, but I guess it uses the same functionality under the hood. |
Hey @simengjermundsen I am trying to do pretty much exactly what you are doing in your video example. I am currently using a I am having a difficult time understanding what this exactly means by @karimnaaji:
For me, I am only using a mapbox-gl canvas that occupies 100% of my page's width and height. Is there some other padding you guys are talking about? |
Padding is accounted for on initial map load -- my guess is that the |
Hey everyone! https://jsfiddle.net/jonasnoki/1k86sb3y One observation I've made is that only larger bounds are not respecting the padding of the map. This insight might aid in identifying the cause of the issue. |
Hey everyone! I created a pull request that should fix this. Can someone have a look at it please? |
I am making a globe where countries of the world can be highlighted.
I am adding a padding to the map (shown using showPadding-debug), and moving the map using fitBounds like this:
map.current.fitBounds( [ [west, south], [east, north] ], { duration: ANIMATION_TIME, easing: easeInOutCubic } );
The bounds sent to fitBounds are the same used to draw the blue-ish area in the video.
When clicking smaller countries this works like a charm, but there are major issues on larger areas like USA and Russia, and also when selecting countries near the north pole (Norway).
There are completely viable configurations of zoom and translation available, like I am trying to illustrate in the video by manually moving/scaling the wrongly positioned areas.
Am I doing something wrong here, or is fitBounds simply not adapted completely for globe-projections?
FitBoundsIssue.mp4
The text was updated successfully, but these errors were encountered: