Skip to content
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

fitBounds doesn't work with the alternate projections #12885

Open
LarryZhu-dev opened this issue Sep 13, 2023 · 6 comments
Open

fitBounds doesn't work with the alternate projections #12885

LarryZhu-dev opened this issue Sep 13, 2023 · 6 comments
Labels

Comments

@LarryZhu-dev
Copy link

Other coordinate systems will have significant offsets

@stepankuzmin
Copy link
Contributor

stepankuzmin commented Sep 18, 2023

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.

@LarryZhu-dev
Copy link
Author

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

@asktomi
Copy link

asktomi commented Oct 16, 2023

I can confirm that when using Equal Earth projection the fitbounds function doesn't fit all markers to the viewport.

@LarryZhu-dev
Copy link
Author

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

@stepankuzmin
Copy link
Contributor

Yes, thanks for the clarification. This is a known issue, related to #12913, #11284, #12565

@stepankuzmin stepankuzmin changed the title map.fitBounds(rect) Only valid in projection: 'mercetor' fitBounds doesn't work with the alternate projections Dec 11, 2023
@jmersonuo
Copy link

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}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants