diff client/src/components/fairway/Profiles.vue @ 3006:44493664d40e

client: refactored layers config Layers are not stored in the vuex store anymore but instead they are served from a factory function, so that different maps can haved individual layer objects
author Markus Kottlaender <markus@intevation.de>
date Thu, 11 Apr 2019 11:44:11 +0200
parents 1b8bb4f89227
children c71373594719
line wrap: on
line diff
--- a/client/src/components/fairway/Profiles.vue	Thu Apr 11 10:11:59 2019 +0200
+++ b/client/src/components/fairway/Profiles.vue	Thu Apr 11 11:44:11 2019 +0200
@@ -264,7 +264,7 @@
   },
   computed: {
     ...mapState("application", ["showProfiles"]),
-    ...mapState("map", ["layers", "lineTool", "polygonTool", "cutTool"]),
+    ...mapState("map", ["openLayersMap", "lineTool", "polygonTool", "cutTool"]),
     ...mapState("bottlenecks", [
       "bottlenecksList",
       "surveys",
@@ -348,7 +348,10 @@
         if (!cut) {
           this.$store.commit("fairwayprofile/clearCurrentProfile");
           this.$store.commit("application/showSplitscreen", false);
-          this.layers.CUTTOOL.getSource().clear();
+          this.openLayersMap
+            .getLayer("CUTTOOL")
+            .getSource()
+            .clear();
         }
       }
     },
@@ -409,19 +412,22 @@
         }
       )
         .then(() => {
-          this.layers.DIFFERENCES.getSource().updateParams({
-            cql_filter:
-              "objnam='" +
-              this.selectedBottleneck +
-              "' AND " +
-              "minuend='" +
-              this.selectedSurvey.date_info +
-              "' AND subtrahend='" +
-              this.additionalSurvey.date_info +
-              "'"
-          });
-          this.layers.BOTTLENECKISOLINE.setVisible(false);
-          this.layers.DIFFERENCES.setVisible(true);
+          this.openLayersMap
+            .getLayer("DIFFERENCES")
+            .getSource()
+            .updateParams({
+              cql_filter:
+                "objnam='" +
+                this.selectedBottleneck +
+                "' AND " +
+                "minuend='" +
+                this.selectedSurvey.date_info +
+                "' AND subtrahend='" +
+                this.additionalSurvey.date_info +
+                "'"
+            });
+          this.openLayersMap.getLayer("BOTTLENECKISOLINE").setVisible(false);
+          this.openLayersMap.getLayer("DIFFERENCES").setVisible(true);
         })
         .catch(error => {
           const { status, data } = error.response;
@@ -478,14 +484,20 @@
       coordinates = coordinates.filter(c => Number(c) === c);
       if (coordinates.length === 4) {
         // draw line on map
-        this.layers.CUTTOOL.getSource().clear();
+        this.openLayersMap
+          .getLayer("CUTTOOL")
+          .getSource()
+          .clear();
         const cut = new Feature({
           geometry: new LineString([
             [coordinates[0], coordinates[1]],
             [coordinates[2], coordinates[3]]
           ]).transform("EPSG:4326", "EPSG:3857")
         });
-        this.layers.CUTTOOL.getSource().addFeature(cut);
+        this.openLayersMap
+          .getLayer("CUTTOOL")
+          .getSource()
+          .addFeature(cut);
 
         // draw diagram
         this.$store.dispatch("fairwayprofile/cut", cut);