Skip to content

Conversation

@na9da
Copy link
Collaborator

@na9da na9da commented Nov 3, 2025

Split from #7626
Required for #6845

What this PR does

Track initial camera view for viewers and return the same view unless the viewer camera has changed.

Previously, the camera view would drift when switching between viewer modes. This is because each time we switch the viewer, we get the current view from leaflet/cesium instance and the value changes slightly each time depending on how the viewer sets the camera. The drift becomes even more noticeable when using custom projections and the extent used with the custom projection is not compatible with the other map modes. This can be a problem when restoring share links and the viewer is first initialized in 3d/cesium mode and then switches to leaflet/2d mode.

This change makes sure that the view remains stable if the camera hasn't changed after setting the initial view.

Test me

  • Open this main branch CI link
  • Then from the settings panel, switch between 3D and 2D a few times (7-8 times)
  • Observe the camera view drift from home camera (Australia) to the global view.
  • Now repeat the same with this branch
  • Observe that the camera view is stable no matter how many times we switch the viewer modes.

Checklist

  • There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)
  • I've updated relevant documentation in doc/.
  • I've updated CHANGES.md with what I changed.
  • I've provided instructions in the PR description on how to test this PR.

na9da added 3 commits November 3, 2025 11:05
…n't changed.

Previously, the camera view would drift when switching between viewer
modes. This is because each time we switch the viewer, we get the current view
from leaflet/cesium scene which renders the map differently. This can be a
problem when restoring share links and the viewer is first initialized in
3d/cesium mode and then switches to leaflet/2d mode.

This change makes sure that the view remains stable if the camera hasn't
changed after setting the initial view.
@na9da na9da changed the title Return stable camera view when switching viewers Keep camera steady when switching between viewer modes. Nov 3, 2025
Copy link
Contributor

@micholm micholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@na9da na9da merged commit b302179 into main Nov 5, 2025
9 checks passed
@na9da na9da deleted the initial-camera-view branch November 5, 2025 23:08
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.

3 participants