Mercurial > gemma
diff client/src/components/map/Maplayer.vue @ 1424:4afbc615cfc2
little code cleanup
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Thu, 29 Nov 2018 14:16:16 +0100 |
parents | b350b0b5cb6c |
children | 7fa030127b05 |
line wrap: on
line diff
--- a/client/src/components/map/Maplayer.vue Thu Nov 29 13:06:14 2018 +0100 +++ b/client/src/components/map/Maplayer.vue Thu Nov 29 14:16:16 2018 +0100 @@ -55,7 +55,7 @@ }; }, computed: { - ...mapGetters("map", ["getLayerByName"]), + ...mapGetters("map", ["getLayerByName", "getVSourceByName"]), ...mapState("map", [ "extent", "layers", @@ -127,9 +127,7 @@ */ // trying the GetFeatureInfo way for WMS - var wmsSource = this.getLayerByName( - "Inland ECDIS chart Danube" - ).data.getSource(); + var wmsSource = this.getVSourceByName("Inland ECDIS chart Danube"); var url = wmsSource.getGetFeatureInfoUrl( coordinate, 100 /* resolution */, @@ -189,10 +187,11 @@ }, updateBottleneckFilter(bottleneck_id, datestr) { console.log("updating filter with", bottleneck_id, datestr); - var layer = this.getLayerByName("Bottleneck isolines"); - var wmsSrc = layer.data.getSource(); + const layer = this.getLayerByName("Bottleneck isolines"); + const wmsSrc = layer.data.getSource(); + const exists = bottleneck_id != "does_not_exist"; - if (bottleneck_id != "does_not_exist") { + if (exists) { wmsSrc.updateParams({ cql_filter: "date_info='" + @@ -201,12 +200,9 @@ bottleneck_id + "'" }); - layer.isVisible = true; - layer.data.setVisible(true); - } else { - layer.isVisible = false; - layer.data.setVisible(false); } + layer.isVisible = exists; + layer.data.setVisible(exists); }, onBeforePrint(/* evt */) { // console.log("onBeforePrint(", evt ,")"); @@ -300,11 +296,9 @@ } } ).then(response => { - var features = new GeoJSON().readFeatures(JSON.stringify(response.data)); - var vectorSrc = this.getLayerByName( - "Fairway Dimensions" - ).data.getSource(); - vectorSrc.addFeatures(features); + this.getVSourceByName("Fairway Dimensions").addFeatures( + new GeoJSON().readFeatures(JSON.stringify(response.data)) + ); // would scale to the extend of all resulting features // this.openLayersMap.getView().fit(vectorSrc.getExtent()); });