question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TileLayer in one view is affected by viewport of other view, when there are multiple views

See original GitHub issue

When 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:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
liokmcommented, Jul 1, 2020

Fixed by deck.gl@8.2.0 Thanks for the working!

1reaction
Pessimistresscommented, Jun 25, 2020

The above PR is landed in 8.2.0-beta.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

TileLayer - deck.gl
When z increases by 1, the view space is scaled by 2, meaning that one tile at z covers the same area as...
Read more >
Resizing on changeFlags.viewportChanged slower ... - GitHub
Multiple views can be on top of each other, and by default they just render their own content without clearing the region (aka...
Read more >
openlayers - Multiple OL views for single OL Map instance
A map can only use one view at any time, A map can have a overview map (via the OverviewMap control, but that...
Read more >
react-leaflet map not correctly displayed - Stack Overflow
I think there is another problem with the height of the map because I'm using css modules. I will investigate tomorrow. – ThomasThiebaud....
Read more >
deck.gl | What's New
TileLayer can now be used in multi-view applications, as long as each TileLayer instance is rendered into one view. See documentation for an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found