Repository navigation
Conversation
VectorTileLayer overrides getTileData and does not pass the `mvt.coordinates` and `mvt.tileIndex` load options MVTLayer passes, so on a GlobeView viewport MVT tiles keep tile-relative coordinates and are drawn as [lng, lat] near 0, 0. Pass them for MVT tiles, and compute auto labels in the tile's geographic bounds when tiles are in WGS84.
[Medium impact] Adjusts how vector tiles render on globe versus flat maps. Reloading cached tiles when switching coordinate frames should be fixed before merging. Findings
Summary
Reviews (1) · Last reviewed commit: "fix(carto): VectorTileLayer MVT tiles on..." · Reviewed by Greptile |
| loadOptions = mergeLoadOptions(loadOptions, { | ||
| mvt: { | ||
| coordinates: this.context.viewport.resolution ? 'wgs84' : 'local', | ||
| tileIndex: tile.index | ||
| } |
There was a problem hiding this comment.
Switching views moves cached features
Tiles loaded in GlobeView now cache WGS84 coordinates. If the app switches to MapView while keeping the same layer ID and data, those tiles are not reloaded. A later style change rebuilds their layers, and MVTLayer.renderSubLayers applies the tile-relative transform to the cached longitude and latitude values. Features then appear in the wrong places.
Reload cached tiles when the viewport changes coordinate frames, and rebuild their layers after the reload.
There was a problem hiding this comment.
Good catch, but this isn't specific to this PR: MVTLayer behaves the same, since it also picks wgs84/local per request and never reloads when the viewport changes frame. With a plain MVTLayer on 9.4.0 and a MapLibre globe, zooming 11.6 → 12.4 and restyling drops the fills, and 12.4 → 11.6 misplaces features without any restyle. VectorTileLayer inherits updateState from MVTLayer, so the fix belongs there. I'll open a separate issue and PR and keep this one scoped.
There was a problem hiding this comment.
That distinction is fair. The cache/frame transition is pre-existing in MVTLayer and inherited by VectorTileLayer, so it isn’t a regression introduced by this PR. Given the separate issue/PR you’re planning, I’ll withdraw this comment and keep the review scoped to the MVT loading and labeling changes here.
Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.
Closes #10867
Change List
VectorTileLayer: passmvt.coordinatesandmvt.tileIndexfor MVT tiles, asMVTLayerdoesVectorTileLayer: auto labels use the tile's geographic bbox for WGS84 MVT tilesThe repro from the issue at zoom 10. Left 9.4.0, right with this change applied.
Above zoom 12 MVT fills also need #10868. Seams along tile edges with translucent fills are #10716, as with
MVTLayer.