mapbox-gl-js
mapbox-gl-js copied to clipboard
fitBounds doesn't work with the alternate projections
Other coordinate systems will have significant offsets
Hi @LarryZhu-dev,
Thank you for using mapbox-gl-js. It's unclear to me what the issue is about. Could you please add more details on the subject? You can also provide a minimal, complete, verified demonstration of the issue to help the maintainers and community understand and address the problem accurately. We recommend using https://jsbin.com/.
Also, for future "how do I" questions like this, you can refer to our help documentation, and if you can't find the answer there, contact support. This issue tracker is for reporting bugs and feature requests.
You might also consider posting your question to https://stackoverflow.com/questions/tagged/mapbox-gl-js to ask the community for help.
That is to say, the fitBounds() method only correctly moves the perspective in the Mercator coordinate system, for example, in the wgs84 coordinate system, the more northward the incoming rect is, the more severely the method shifts
I can confirm that when using Equal Earth projection the fitbounds function doesn't fit all markers to the viewport.
Hi @LarryZhu-dev,
Thank you for using mapbox-gl-js. It's unclear to me what the issue is about. Could you please add more details on the subject? You can also provide a minimal, complete, verified demonstration of the issue to help the maintainers and community understand and address the problem accurately. We recommend using https://jsbin.com/.
Also, for future "how do I" questions like this, you can refer to our help documentation, and if you can't find the answer there, contact support. This issue tracker is for reporting bugs and feature requests.
You might also consider posting your question to https://stackoverflow.com/questions/tagged/mapbox-gl-js to ask the community for help.
Can you confirm the cause of the problem now
Yes, thanks for the clarification. This is a known issue, related to https://github.com/mapbox/mapbox-gl-js/issues/12913, https://github.com/mapbox/mapbox-gl-js/issues/11284, https://github.com/mapbox/mapbox-gl-js/issues/12565
I have the same problem - adding to the chorus on this "known issue".
Using globe/web Mercator, fitBounds
with the following coordinates works in the globe/default projection and fails in "naturalEarth" - it incorrectly zooms to eastern North America.
For example:
bbox = [
[-29.1, 30.4],
[58.0, 85.0]
];
map.fitBounds(bbox, {
padding: {top: 10, bottom:25, left: 15, right: 5}
});