TileLayer in one view is affected by viewport of other view, when there are multiple views
See original GitHub issueWhen there are multiple Views, a TileLayer inside one View is always affected by viewport of other view.
For example, (I will try to create a runnable one if necessary)
const views = [
new OrbitView({ id: "v0", width: "50%" }),
new OrbitView({ id: "v1", x: "50%", width: "50%" })
];
const layers = [
new TileLayer({
id: "v0-tile",
renderSubLayers() {
return new BitmapLayer(...);
}
})
];
const layerFilter = ({ layer, viewport }) =>
layer.id.startsWith(`${viewport.id}-`);
<DeckGL views={views} layers={layers} layerFilter={layerFilter} />;
The TileLayer intends to be shown in v0 only.
But this does not work well, since layerManager.activateViewport()
sets current viewport to viewport v0 and v1 alternatively. When viewport v1 is applied, the layer is rendering using the incorrect zoom level and tile indices, which causes tiles loading or disappearing.
This situation could be fixed partially by limiting TileLayer to only react to v0:
class MyTileLayer extends TileLayer {
shouldUpdateState(params) {
if (params.context.viewport.id !== 'v0') return false;
...
}
_updateTileset() {
if (this.context.viewport.id !== 'v0') return false;
...
}
}
However, the workaround does not solve the root issue that changeFlags.viewportChanged
is true when layerManager.activateViewport()
detects a change of viewport from v1 to v0, and provides it to TileLayer
, even if only props change.
This causes that, when TileLayer.updateState()
is invoked, the line inside the following if clause is invoked incorrectly, as changeFlags.viewportChanged
is true:
if (createTileCache || changeFlags.viewportChanged) {
this._updateTileset();
}
Any suggestions? Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
Fixed by
deck.gl@8.2.0
Thanks for the working!The above PR is landed in 8.2.0-beta.2