Mercurial > gemma
changeset 4272:dd8ec623b969
LegendElement: refresh legend elements for vector layers
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 28 Aug 2019 11:42:44 +0200 |
parents | 315474a66589 |
children | 9abb63b6b80a |
files | client/src/components/layers/LegendElement.vue |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/layers/LegendElement.vue Wed Aug 28 11:06:47 2019 +0200 +++ b/client/src/components/layers/LegendElement.vue Wed Aug 28 11:42:44 2019 +0200 @@ -34,7 +34,7 @@ }; }, computed: { - ...mapState("map", ["layers"]), + ...mapState("map", ["layers", "ongoingRefresh"]), id() { return ( "legendelement-" + @@ -51,13 +51,16 @@ } }, watch: { + ongoingRefresh() { + if (this.ongoingRefresh) return; + if (this.layer.getType() == "VECTOR") { + this.recreateLayers(); + } + }, mstyle(newStyle, oldStyle) { // only recreate if there already was a style before if (oldStyle) { - let vector = this.createVectorLayer(); - - this.myMap.removeLayer(this.myMap.getLayers()[0]); - this.myMap.addLayer(vector); + this.recreateLayers(); } } }, @@ -97,6 +100,12 @@ } }, methods: { + recreateLayers() { + let vector = this.createVectorLayer(); + + this.myMap.removeLayer(this.myMap.getLayers()[0]); + this.myMap.addLayer(vector); + }, initMap() { let vector = this.createVectorLayer();