Add fitbounds support for map subplots - #7911
Open
kirthi-b wants to merge 2 commits into
Open
Conversation
kirthi-b
added a commit
to kirthi-b/plotly.js
that referenced
this pull request
Jul 19, 2026
Contributor
|
Thanks for the PR! We recently made some changes to the map traces to auto-fit for non-choropleth plots. This is in the release branch for the upcoming |
kirthi-b
force-pushed
the
feat/map-fitbounds
branch
from
July 22, 2026 18:04
e789d86 to
692fd96
Compare
Extend layout.map.fitbounds to cover choroplethmap traces, which the v4.0 auto-fit currently skips. With 'locations' (the default) the view fits to the bounding box of the geometries matched by the trace's locations; a new 'geojson' value fits to the entire input geojson instead. Point traces (scattermap, densitymap) are unaffected. Bounds are read at supply-defaults time from the resolved trace geojson, so a URL geojson that has not been fetched yet is skipped quietly rather than driving the fit or logging an error.
The test asserted that any choroplethmap trace on the subplot forces getMapFitBounds to return null. That was true before choroplethmap support was added, but the added commit intentionally lets a choroplethmap trace with unresolved geojson be skipped while other traces still drive the fit, so the old assertion no longer matches the documented behavior. Updated the test to check that case, and added the real null case: a subplot where the only trace is a choroplethmap with no resolvable geojson.
kirthi-b
force-pushed
the
feat/map-fitbounds
branch
from
August 6, 2026 16:20
7e817df to
6e57729
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3434.
Reworked for the v4.0 branch as requested. Since v4.0 already auto-fits lon/lat map traces (scattermap, densitymap) via layout.map.fitbounds, this PR now adds the part that is still missing: choroplethmap support.
What this adds on top of v4.0's fitbounds:
locationsusingfeatureidkey(dotted paths supported), and the matched geometry's bbox feeds the fit.'geojson'value forlayout.map.fitbounds: fit to the entire input geojson rather than only the matched locations, mirroring the same distinction geo.fitbounds makes.Tests: two updated unit specs in map_get_fit_bounds_test.js covering the choroplethmap paths (skip-when-unresolved with other traces still driving the fit, and null when nothing contributes), plus three @gl integration specs in map_test.js. The map auto-fit suite passes 9/9 with these commits; a control run on plain v4.0 confirms the three new specs are the only additions and nothing else flips.