Vizzuality / layer-manager

A library to get a layer depending on provider and layer spec
https://layer-manager-docs.vercel.app
MIT License
18 stars 12 forks source link

Deck layers: new way of thinking (konecta) #141

Closed mbarrenechea closed 2 years ago

mbarrenechea commented 2 years ago

This PR adds a better way of handling deck layers. You only need to memoize the layer using a useMemo a listen to changes to re render the new layer.

The key part is that we are now listening from layer manager mapbox plugin to the changes in deck layers.

  setDeck(layerModel) {
    const { mapLayer, deck } = layerModel;

    mapLayer?.layers?.forEach((layer, i) => {
      if (layer && layer.setProps && typeof layer.setProps === 'function') {
        const dl = deck[i - 1];
        if (dl) {
          const { props: deckProps } = dl;

          layer.setProps(deckProps);
        } else {
          console.warn('No deck layer found for layer', layer);
        }
      }
    });
vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
layer-manager-docs ✅ Ready (Inspect) Visit Preview Jul 15, 2022 at 9:25AM (UTC)
sorodrigo commented 2 years ago

konecta