changeset 764:a6a8fe89eb84

client: add hooks for identify mode * Add hooks for single mouse click if the interaction is not enabled. For example get the d4d WMS url for getfeatureinfo and display it.
author Bernhard Reiter <bernhard@intevation.de>
date Tue, 25 Sep 2018 15:23:15 +0200
parents d05bc3e34338
children c1baaff348b0
files client/src/map/Maplayer.vue
diffstat 1 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/map/Maplayer.vue	Tue Sep 25 13:11:33 2018 +0200
+++ b/client/src/map/Maplayer.vue	Tue Sep 25 15:23:15 2018 +0200
@@ -178,6 +178,31 @@
       this.interaction = interaction;
       this.openLayersMap.addInteraction(interaction);
     },
+    activateIdentifyMode() {
+      this.openLayersMap.on("singleclick", event => {
+        // console.log("single click on map:", event);
+        this.identify(
+          event.coordinate,
+          this.getLayerByName("Inland ECDIS chart Danube").data.getSource()
+        );
+      });
+    },
+    identify(coordinate, wmsSource) {
+      // console.log(coordinate, wmsSource);
+      //var viewResolution = this.openLayersMap.view.getResolution();
+      var url = wmsSource.getGetFeatureInfoUrl(
+        coordinate,
+        100,
+        "EPSG:3857",
+        // { INFO_FORMAT: "application/vnd.ogc.gml" } // not allowed by d4d
+        { INFO_FORMAT: "text/plain" }
+      );
+
+      if (url) {
+        // cannot directly query here because of SOP
+        console.log(url);
+      }
+    },
     buildVectorLoader(featureRequestOptions, endpoint, vectorSource) {
       // build a function to be used for VectorSource.setLoader()
       // make use of WFS().writeGetFeature to build the request
@@ -357,6 +382,8 @@
       )
     );
     layer.data.setVisible(layer.isVisible);
+
+    this.activateIdentifyMode();
   }
 };
 </script>