mapbox-gl-js
mapbox-gl-js copied to clipboard
map.fitBounds with padding affects the map.getBounds
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]