changeset 4022:efe0904b1d45

Change of ECDIS no longer requires reload When the maps are initialized, the source of th ECDIS is retireved from the store. When a change of the configuration is made, the store is updated.
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 22 Jul 2019 13:28:04 +0200
parents b10f210af325
children baa51bb82364 5eaa3d45757e
files client/src/components/map/Map.vue client/src/components/map/layers.js client/src/components/systemconfiguration/MapLayers.vue
diffstat 3 files changed, 25 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/map/Map.vue	Mon Jul 22 11:20:20 2019 +0200
+++ b/client/src/components/map/Map.vue	Mon Jul 22 13:28:04 2019 +0200
@@ -42,6 +42,7 @@
 import { displayError } from "@/lib/errors";
 import { pane } from "@/lib/mixins";
 import { layerFactory } from "@/components/map/layers";
+import { ImageWMS as ImageSource } from "ol/source";
 import "ol/ol.css";
 
 /* for the sake of debugging */
@@ -60,7 +61,7 @@
     ...mapState("map", ["initialLoad", "extent", "syncedMaps", "syncedView"]),
     ...mapState("bottlenecks", ["selectedSurvey"]),
     ...mapState("fairwayprofile", ["additionalSurvey"]),
-    ...mapState("application", ["paneSetup", "paneRotate"]),
+    ...mapState("application", ["paneSetup", "paneRotate", "config"]),
     ...mapState("imports", ["selectedStretchId", "selectedSectionId"]),
     layers() {
       return layerFactory(this.paneId);
@@ -207,6 +208,13 @@
       }
     },
     mountMap() {
+      const source = new ImageSource({
+        preload: 1,
+        url: this.config.ecdis_wms_url,
+        crossOrigin: "anonymous",
+        params: JSON.parse(this.config.ecdis_wms_params)
+      });
+      this.layers.get("INLANDECDIS").setSource(source);
       this.map = new Map({
         layers: this.layers.config,
         target: "map-" + this.paneId,
@@ -222,7 +230,6 @@
               })
       });
       this.map.getLayer = id => this.layers.get(id);
-
       // store map position on every move
       // will be obsolete once we abandoned the separated admin context
       this.map.on("moveend", event => {
--- a/client/src/components/map/layers.js	Mon Jul 22 11:20:20 2019 +0200
+++ b/client/src/components/map/layers.js	Mon Jul 22 13:28:04 2019 +0200
@@ -243,12 +243,7 @@
           id: "INLANDECDIS",
           label: "Inland ECDIS chart Danube",
           visible: true,
-          source: new ImageSource({
-            preload: 1,
-            url: store.state.application.config.ecdis_wms_url,
-            crossOrigin: "anonymous",
-            params: JSON.parse(store.state.application.config.ecdis_wms_params)
-          })
+          source: null
         }),
         new ImageLayer({
           id: "WATERWAYAREA",
--- a/client/src/components/systemconfiguration/MapLayers.vue	Mon Jul 22 11:20:20 2019 +0200
+++ b/client/src/components/systemconfiguration/MapLayers.vue	Mon Jul 22 13:28:04 2019 +0200
@@ -144,16 +144,22 @@
       this.lookupWMSCapabilities();
     },
     submit() {
-      this.$store.dispatch("application/saveConfig", {
-        ecdis_wms_url: this.config.ecdis_wms_url,
-        ecdis_wms_params: JSON.stringify({
-          LAYERS: this.selectedWMSLayers
-            .filter(l => this.availableWMSLayers.find(al => al === l))
-            .join(","),
-          VERSION: this.wmsVersion,
-          TILED: true
+      const layers = this.selectedWMSLayers
+        .filter(l => this.availableWMSLayers.find(al => al === l))
+        .join(",");
+      const wmsParams = JSON.stringify({
+        LAYERS: layers,
+        VERSION: this.wmsVersion,
+        TILED: true
+      });
+      this.$store
+        .dispatch("application/saveConfig", {
+          ecdis_wms_url: this.config.ecdis_wms_url,
+          ecdis_wms_params: wmsParams
         })
-      });
+        .then(() => {
+          this.config.ecdis_wms_params = wmsParams;
+        });
     }
   },
   mounted() {