mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

map.fitBounds with padding affects the map.getBounds

Open benderlidze opened this issue 10 months ago • 0 comments

map.fitBounds(bounds, { padding: 150 }) in v3.10 somehow sets the global bounds. If you call map.getBounds(), it returns the bounds including the 150 px padding, which is incorrect.

In v2, map.getBounds() returns the correct bounds covering 100% of the height and width without any padding.

map.fitBounds(bounds, { padding: 150 });
const s = map.getBounds();
console.log('s', s);

v2 Results: [7.1204, 52.6618, 13.8875, 59.2029] v3 Results: [8.4594, 53.4663, 12.5486, 58.5104]

benderlidze avatar Feb 18 '25 15:02 benderlidze