Add fitbounds support for map subplots - #7911
Conversation
|
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 |
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.
7e817df to
6e57729
Compare
|
Hello! This got closed unintentionally when the base branch got deleted. Could you open a new PR targeting the default branch? |
Never mind. It's open again. |
|
I'm moving this back to draft for now. When it's ready, let me know and I'll review. |
|
Thanks, this is ready now. The rework you asked for is in as of Aug 3: it targets the current default branch, and on top of the v4.0 auto-fit it adds choroplethmap support plus a |
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.