Skip to content

fix(geo-layers): MVTLayer reloads tiles when the viewport changes frame - #10871

Open
aaranadev wants to merge 1 commit into
visgl:masterfrom
aaranadev:fix/mvt-layer-reload-on-frame-change
Open

aaranadev wants to merge 1 commit into
visgl:masterfrom
aaranadev:fix/mvt-layer-reload-on-frame-change

Conversation

@aaranadev

@aaranadev aaranadev commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #10870

Change List

  • MVTLayer: reload the tileset when the viewport changes coordinate frame
  • Unit test, fails without the change
pr-mvtlayer-reload-before-after

The repro from the issue after zooming from 12.4 to 11.6. Left 9.4.0, right with this change applied.

Follow up of the review on #10869.

MVTLayer#getTileData parses tiles in WGS84 when the viewport has a
resolution (GlobeViewport) and in tile coordinates otherwise, but cached
tiles were never reloaded when that changed. GlobeView switches to a
WebMercatorViewport above zoom 12, so crossing it kept tiles in the old
frame: features were misplaced zooming out, and lost on the next sub
layer rebuild zooming in. Reload the tileset when the frame changes.
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Fixes tile reloading when viewport coordinate frame changes.

The PR appears safe to merge, with a non-blocking display issue while replacement tiles load.

Findings

  1. P2 Old tiles remain visible ▶

Summary

MVTLayer now tracks whether the viewport uses geographic or tile-local coordinates and reloads tiles when that changes.

  • MVTLayer reloads tiles when the viewport changes coordinate frames.

Reviews (1) · Last reviewed commit: "fix(geo-layers): MVTLayer reloads tiles ..." · Reviewed by Greptile

// above zoom 12): tiles loaded in the other frame must be loaded again
const wgs84 = Boolean(context.viewport.resolution);
if (wgs84 !== this.state.wgs84) {
this.state.tileset?.reloadAll();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Old tiles remain visible

reloadAll() keeps selected tiles' old content and sublayers. When the user crosses the globe/flat-map boundary, those sublayers keep drawing data from the previous coordinate frame until the new requests finish. Users can still see misplaced features during loading, especially on slow connections. Hide or discard the old-frame content instead of keeping it visible while replacements load.

Knowledge Base Used: Geospatial layer types

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Checked with tile requests delayed by 3 s on a MapLibre globe, right after crossing zoom 12:

  • 11.6 → 12.4: the kept sub layers were built for [lng, lat] data in LNGLAT, which stays valid on the WebMercatorViewport, so they stay in place until the reload finishes. Discarding them instead (finalize() and a new tileset) blanks the view until then.
  • 12.4 → 11.6: the kept CARTESIAN sub layers draw nothing on the GlobeViewport, so no misplaced features show while loading.

Keeping reloadAll().

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That makes sense. With the delayed-request repro, reloadAll() is the better transition behavior: on Web Mercator → Globe, the retained CARTESIAN sublayers render nothing, while on Globe → Web Mercator, the retained [lng, lat] LNGLAT data remains valid in the new viewport. Replacing the tileset would unnecessarily blank the view, so I withdraw the concern about keeping the old content visible and have no objection to retaining reloadAll().

This branch has not been deployed

No deployments
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.

[Bug] MVTLayer keeps cached tiles in the wrong coordinate frame when a globe crosses zoom 12

1 participant