diff client/src/components/Maplayer.vue @ 2184:826fc7309370

client: Added refresh button to reload the WFS layer data.
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 11 Feb 2019 16:19:52 +0100
parents 8be0fbac2297
children 9212b3d60f2a
line wrap: on
line diff
--- a/client/src/components/Maplayer.vue	Mon Feb 11 16:16:35 2019 +0100
+++ b/client/src/components/Maplayer.vue	Mon Feb 11 16:19:52 2019 +0100
@@ -183,35 +183,41 @@
 
     // load different fairway dimension layers (level of service)
     ["1", "2", "3"].forEach(los => {
-      // loading the full WFS layer, by not setting the loader function
-      // and without bboxStrategy
-      var featureRequest = new WFS().writeGetFeature({
-        srsName: "EPSG:3857",
-        featureNS: "gemma",
-        featurePrefix: "gemma",
-        featureTypes: ["fairway_dimensions"],
-        outputFormat: "application/json",
-        filter: equalTo("level_of_service", los)
-      });
+      // loading the full WFS layer without bboxStrategy
+      var source = this.getVSourceByName("Fairway Dimensions LOS " + los)
+      var loader = function(extent, resolution, projection) {
+        var featureRequest = new WFS().writeGetFeature({
+          srsName: "EPSG:3857",
+          featureNS: "gemma",
+          featurePrefix: "gemma",
+          featureTypes: ["fairway_dimensions"],
+          outputFormat: "application/json",
+          filter: equalTo("level_of_service", los)
+        });
 
-      // NOTE: loading the full fairway_dimensions makes sure
-      //       that all are available for the intersection with the profile
-      HTTP.post(
-        "/internal/wfs",
-        new XMLSerializer().serializeToString(featureRequest),
-        {
-          headers: {
-            "X-Gemma-Auth": localStorage.getItem("token"),
-            "Content-type": "text/xml; charset=UTF-8"
+        featureRequest["outputFormat"] = "application/json";
+        // NOTE: loading the full fairway_dimensions makes sure
+        //       that all are available for the intersection with the profile
+        HTTP.post(
+          "/internal/wfs",
+          new XMLSerializer().serializeToString(featureRequest),
+          {
+            headers: {
+              "X-Gemma-Auth": localStorage.getItem("token"),
+              "Content-type": "text/xml; charset=UTF-8"
+            }
           }
-        }
-      ).then(response => {
-        this.getVSourceByName("Fairway Dimensions LOS " + los).addFeatures(
-          new GeoJSON().readFeatures(JSON.stringify(response.data))
-        );
-        // would scale to the extend of all resulting features
-        // this.openLayersMap.getView().fit(vectorSrc.getExtent());
-      });
+        ).then(response => {
+          source.addFeatures(
+            new GeoJSON().readFeatures(JSON.stringify(response.data))
+          );
+          // would scale to the extend of all resulting features
+          // this.openLayersMap.getView().fit(vectorSrc.getExtent());
+        });
+      }
+
+      layer = this.getLayerByName("Fairway Dimensions LOS " + los);
+      layer.data.getSource().setLoader(loader)
     });
 
     // load following layers with bboxStrategy (using our request builder)