account for padding in getBounds #10386
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Launch Checklist
This change proposes to alter
map.getBounds()
, when a global map padding is set, to return the inset bounds rather than the outset bounds (current behaviour).This probably needs some discussion, not sure if it's considered a breaking change or a bug fix, however by making this the new default it ensures that:
getBounds
followed byfitBounds
ensures the map view doesn't change (should address getBounds value is wrong when I set fitBounds with padding #10169)My rationale is once you've set your global map padding to account for UI elements then all bounds refer to the inset bounds for consistency.
We could consider adding an option to
getBounds
/fitBounds
to specify if the bounds should be for the inset or outset padded area, as I can see times when a dev would like to specify this.before
getBounds:
setBounds:
after:
getBounds/setBounds:
added one unit test to confirm that
getBounds
returns the inset when padding is setdocument any changes to public APIs
I've updated the docs for
getBounds
/fitBounds
to specify it's for the inset when padding is set, however I can see especially withfitBounds
how someone reading the docs could get confused between the two different kinds of padding (map.setPadding
andmap.fitBounds
padding
option), not sure how to improve that.post benchmark scores
manually test the debug page
yes, I added a new debug page
apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
feature or bug? Possibly considered a breaking change.
add an entry inside this element for inclusion in the
mapbox-gl-js
changelog:<changelog>Changed
map.getBounds()to return the inset bounds when a map padding is set</changelog>