mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.2k stars 2.22k forks source link

map.fitBounds() with bearing does not fit the entire bounds #10064

Open blahblahblah- opened 4 years ago

blahblahblah- commented 4 years ago

When map.fitBounds(...) is called with a bearing option passed in, it seems like the bearing is not taken into the account on calculating the appropriate zoom, resulting in part of the bounded area to not be in view.

mapbox-gl-js version: 1.12.0

browser: Chrome

Steps to Trigger Behavior

  1. Create a bounded area with a list of coordinates
  2. Call map.fitBounds(...) with bearing option set

Link to Demonstration

https://jsfiddle.net/_blahblahblah/k4vL6s5r/

Expected Behavior

When clicking on the 'Fit to Line at 29º Bearing' button in the demo link, all 6 stations should be in view.

Actual Behavior

Only 4 of the 6 stations are in view.

karimnaaji commented 4 years ago

Hello @blahblahblah- , I think this was fixed by https://github.com/mapbox/mapbox-gl-js/pull/9821, but is not yet released.

blahblahblah- commented 4 years ago

Hi @karimnaaji, I also tested with the latest main and I can still reproduce the issue.

karimnaaji commented 4 years ago

Ok thanks for confirming!

pimhoogendoorn commented 1 year ago

Hi @TannerPerrien it seems that your fix has been merged however, I can still reproduce it even in the latest version 2.14.1. Is that correct and the reason why this issue is still open?

pahuta commented 1 year ago

Checked on v.2.15.0, bug is not reproduced. Updated demo: https://jsfiddle.net/q4d50L9h/

@mapbox/gl-js , please consider to close the issue.

chrisnok commented 10 months ago

If you change the demo to use bearing 135 instead of 29, you get an extra padding. Is there a workaround for this?