Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reevaluate paint property when modifying layers #77

Closed
henningko opened this issue Jan 22, 2019 · 4 comments
Closed

Reevaluate paint property when modifying layers #77

henningko opened this issue Jan 22, 2019 · 4 comments
Labels

Comments

@henningko
Copy link

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.

@soal soal added the bug label Jan 22, 2019
@aidangarza
Copy link
Contributor

@soal, It looks like your solution to this will be replacing the "paint" and "layout" properties with a single "layer" property. The current version (0.1.3) does not apply paint properties to "symbol" type geojson layers, I assume because your default paint object has a "fill-color" property. Will this solution remove that limitation so that "paint" on "symbol" type layers will work again?

@soal
Copy link
Owner

soal commented Feb 4, 2019

Yes, since all layer configuration will be moved into layer and source props, this problem will be eliminated. I've concluded that trying to support quite broad Mapbox API as separate props are too difficult and leads to bugs, considering that Mapbox API itself not stable yet.

I need to do some testing to ensure that reactivity features works properly before it will be landed in version 0.2

@aidangarza
Copy link
Contributor

@henningko, I have found (as a temporary workaround) if you change the layerId prop, the layer is replaced and the new paint properties are displayed. It works until @soal's refactor is finished.

@soal
Copy link
Owner

soal commented Feb 16, 2019

Must be fixed in 0.2. Feel free to reopen this issue if you still have this problem.

@soal soal closed this as completed Feb 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants