Skip to content

Reevaluate paint property when modifying layers #77

@henningko

Description

@henningko

I am using v-for to dynamically add and remove layers that are added to an array:

<MglGeojsonLayer v-for="(layer, index) in layers" :key="index"
        :type="layer.paintType"
        :sourceId="`source${index}`"
        :layerId="`layer${index}`"
        :source.sync="layer"
        :paint="layer.paint"
      />
layers: function() {
      let layers = [];
      this.bufferLayer ? layers.push(this.bufferLayer) : null;
      this.insideLayer ? layers.push(this.insideLayer) : null;
      this.outsideLayer ? layers.push(this.outsideLayer): null;
      return layers;
    },

Example layer:

const layer1 = {
  "paintType": "line",
  "paint": {
    "line-color": "cyan",
    "line-opacity": 0.5
  },
  "type": "FeatureCollection",
  "features": [ ...]
}

However, when swapping out a layer at position i, the paint properties are not re-evaluated, but rather, the paint properties of the previous layer at i are kept.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions