Skip to content

fix: Dynamically compute default zoom/center for map traces#7884

Open
camdecoster wants to merge 9 commits into
v4.0from
cam/7674/compute-map-default-bounds
Open

fix: Dynamically compute default zoom/center for map traces#7884
camdecoster wants to merge 9 commits into
v4.0from
cam/7674/compute-map-default-bounds

Conversation

@camdecoster

@camdecoster camdecoster commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

Use lat/lon points to dynamically compute the default zoom/center for scattermap and densitymap traces.

Closes #7674.

Changes

  • Add check during handleDefaults to dynamically computer map bounds
  • Add tests
  • Linting/formatting

Screenshots

Before After
image image

Testing

  • Be on master
  • Run the following mock through Plotly devtools
    {
      "data": [
        {
          "hovertext": ["San Marino", "Cairo", "Istanbul", "Trondheim"],
          "lat": [43.9360958, 30.06263, 41.01384, 63.43049],
          "lon": [12.4417702, 31.24967, 28.94966, 10.39506],
          "marker": { "color": "#f00" },
          "mode": "markers",
          "type": "scattermap"
        }
      ],
      "layout": { "width": 900, "height": 600 }
    }
  • Note that the Trondheim point is outside of the frame
  • Switch to this branch
  • Run the same mock
  • Note that the scatter points are nicely framed
  • Pan/zoom around
  • Click the reset view button
  • Note that the view is still nicely framed

Notes

@camdecoster camdecoster marked this pull request as ready for review July 1, 2026 23:16
@camdecoster camdecoster added this to the v4.0.0 milestone Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant