visgl / deck.gl

WebGL2 powered visualization framework
https://deck.gl
MIT License
11.92k stars 2.06k forks source link

[Bug]GoogleMapsOverlay, Add layer again after delete, can't add #8018

Open jongshy opened 11 months ago

jongshy commented 11 months ago

Description

setMap(map) -> setMap(null) -> setMap(map) add layer again after delete, can't add

Flavors

Expected Behavior

No response

Steps to Reproduce

const deckOverlay = new GoogleMapsOverlay({ layers: [jsonlayer], });

deckOverlay.setMap(map);

setTimeout(() => { deckOverlay.setMap(null); }, 5000);

setTimeout(() => { deckOverlay.setMap(map); }, 10000);

Environment

Logs

No response

jongshy commented 11 months ago

layer won't show up

Pessimistress commented 11 months ago

Finalized layers cannot be re-added. You will need to construct new layer instances. Pay attention to the console errors.

andynguyen-swdev commented 10 months ago

This is a real issue that has nothing to do with finalized layers. It's caused the layer filter being set to HIDE_ALL_LAYERS in _onRemove(): https://github.com/visgl/deck.gl/blob/7d74676978c8b0f8645678641d9b0bee33a02333/modules/google-maps/src/google-maps-overlay.ts#L190-L192 but there's no reversing it in _onAdd(): https://github.com/visgl/deck.gl/blob/7d74676978c8b0f8645678641d9b0bee33a02333/modules/google-maps/src/google-maps-overlay.ts#L147-L150

Adding this._deck.setProps({ layerFilter: null }); to the end of _onAdd() should resolve the issue.


EDIT: Setting layerFilter back to null might not be the correct thing to do, it should be this.props.layerFilter

Pessimistress commented 10 months ago

@felixpalmer Looks like onAdd should not create a new instance if it already exists?

andynguyen-swdev commented 10 months ago

createDeckInstance reuses the instance: https://github.com/visgl/deck.gl/blob/7d74676978c8b0f8645678641d9b0bee33a02333/modules/google-maps/src/utils.ts#L26-L28

so layerFilter still stays as HIDE_ALL_LAYERS and no layers get rendered.

EDIT: Thanks for reopening the issue btw :)