changeset 3021:2e2a271c1026

client: fixed layer factory to actually serve different objects
author Markus Kottlaender <markus@intevation.de>
date Thu, 11 Apr 2019 18:57:40 +0200
parents 94edd5e5dd1b
children 0b19105c7c4b
files client/src/components/map/Map.vue client/src/components/map/layers.js
diffstat 2 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/map/Map.vue	Thu Apr 11 17:48:18 2019 +0200
+++ b/client/src/components/map/Map.vue	Thu Apr 11 18:57:40 2019 +0200
@@ -69,6 +69,9 @@
     ...mapState("bottlenecks", ["selectedSurvey"]),
     ...mapState("application", ["showSplitscreen", "panes", "paneMode"]),
     ...mapState("imports", ["selectedStretchId"]),
+    layers() {
+      return layers();
+    },
     hasActiveInteractions() {
       return (
         (this.lineTool && this.lineTool.getActive()) ||
@@ -82,14 +85,14 @@
       const exists = bottleneck_id != "does_not_exist";
 
       if (exists) {
-        layers
+        this.layers
           .get("BOTTLENECKISOLINE")
           .getSource()
           .updateParams({
             cql_filter: `date_info='${datestr}' AND bottleneck_id='${bottleneck_id}'`
           });
       }
-      layers.get("BOTTLENECKISOLINE").setVisible(exists);
+      this.layers.get("BOTTLENECKISOLINE").setVisible(exists);
     }
   },
   watch: {
@@ -122,7 +125,7 @@
       }
     },
     selectedStretchId(id) {
-      layers
+      this.layers
         .get("STRETCHES")
         .getSource()
         .getFeatures()
@@ -136,7 +139,7 @@
   },
   mounted() {
     this.map = new Map({
-      layers: layers.config,
+      layers: this.layers.config,
       target: "map-" + this.uuid,
       controls: [],
       view: new View({
@@ -146,7 +149,7 @@
         projection: "EPSG:3857"
       })
     });
-    this.map.getLayer = id => layers.get(id);
+    this.map.getLayer = id => this.layers.get(id);
 
     // store map position on every move
     // will be obsolete once we abandoned the separated admin context
@@ -212,7 +215,7 @@
                 color: btlnFillC
               })
             });
-            layers.get("BOTTLENECKS").setStyle(newStyle);
+            this.layers.get("BOTTLENECKS").setStyle(newStyle);
           })
           .catch(error => {
             console.log(error);
--- a/client/src/components/map/layers.js	Thu Apr 11 17:48:18 2019 +0200
+++ b/client/src/components/map/layers.js	Thu Apr 11 18:57:40 2019 +0200
@@ -56,7 +56,7 @@
   };
 };
 
-export default (function() {
+export default function() {
   return {
     get(id) {
       return this.config.find(l => l.get("id") === id);
@@ -491,4 +491,4 @@
       })
     ]
   };
-})();
+}