changeset 3270:d7bc51fd50b0

client: map layers: integrated osm layer into main layer configuration file only url is set afterwards
author Markus Kottlaender <markus@intevation.de>
date Wed, 15 May 2019 13:53:48 +0200
parents 5746497085b6
children b74e9768231d
files client/src/components/map/Map.vue client/src/components/map/layers.js
diffstat 2 files changed, 12 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/map/Map.vue	Wed May 15 13:22:21 2019 +0200
+++ b/client/src/components/map/Map.vue	Wed May 15 13:53:48 2019 +0200
@@ -42,9 +42,7 @@
 import { displayError } from "@/lib/errors";
 import { pane } from "@/lib/mixins";
 import layers from "@/components/map/layers";
-import { Tile as TileLayer } from "ol/layer";
 import "ol/ol.css";
-import OSM from "ol/source/OSM";
 
 /* for the sake of debugging */
 /* eslint-disable no-console */
@@ -233,19 +231,12 @@
       headers: { "X-Gemma-Auth": localStorage.getItem("token") }
     })
       .then(response => {
-        const url = response.data["osm-url"];
-        const config = {};
-        if (url) {
-          config["url"] = url;
+        if (response.data["osm-url"]) {
+          this.layers
+            .get("OPENSTREETMAP")
+            .getSource()
+            .setUrl(response.data["osm-url"]);
         }
-        this.layers.config.unshift(
-          new TileLayer({
-            id: "OPENSTREETMAP",
-            label: "Open Streetmap",
-            visible: true,
-            source: new OSM(config)
-          })
-        );
         this.initMap();
 
         if (this.selectedSurvey && this.paneId === "main") {
--- a/client/src/components/map/layers.js	Wed May 15 13:22:21 2019 +0200
+++ b/client/src/components/map/layers.js	Wed May 15 13:53:48 2019 +0200
@@ -10,6 +10,7 @@
 import Point from "ol/geom/Point";
 import { bbox as bboxStrategy } from "ol/loadingstrategy";
 import { WFS, GeoJSON } from "ol/format";
+import OSM from "ol/source/OSM";
 import { equalTo } from "ol/format/filter";
 import { HTTP } from "@/lib/http";
 import styles from "./styles";
@@ -166,6 +167,12 @@
       return this.config.find(l => l.get("id") === id);
     },
     config: [
+      new TileLayer({
+        id: "OPENSTREETMAP",
+        label: "Open Streetmap",
+        visible: true,
+        source: new OSM()
+      }),
       new ImageLayer({
         id: "INLANDECDIS",
         label: "Inland ECDIS chart Danube",