changeset 770:c12ec7fde3f2

client: add simple identify top area box * Add Identify.vue as a top area box that display the currently identified features in a short text-only way. This can be styled further, also the box is not yet resized dynamically. Put in to subdir layers because it is closest to Layers.vue, which was used as a template. * Introduce a new mapstore/identifiedFeatures state.
author Bernhard Reiter <bernhard@intevation.de>
date Wed, 26 Sep 2018 09:13:29 +0200
parents ba2007b746ef
children 6d214b3bed35
files client/src/application/Topbar.vue client/src/application/assets/application.scss client/src/layers/Identify.vue client/src/map/Maplayer.vue client/src/map/store.js
diffstat 5 files changed, 121 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/application/Topbar.vue	Tue Sep 25 21:51:53 2018 +0200
+++ b/client/src/application/Topbar.vue	Wed Sep 26 09:13:29 2018 +0200
@@ -17,6 +17,9 @@
         <div class="">
             <Layers v-if="routeName == 'mainview'"></Layers>
         </div>
+        <div class="">
+            <Identify v-if="routeName == 'mainview'"></Identify>
+        </div>
     </div>
 </template>
 
@@ -84,10 +87,12 @@
 
 <script>
 import Layers from "../layers/Layers";
+import Identify from "../layers/Identify";
 
 export default {
   name: "topbar",
   components: {
+    Identify: Identify,
     Layers: Layers
   },
   data() {
--- a/client/src/application/assets/application.scss	Tue Sep 25 21:51:53 2018 +0200
+++ b/client/src/application/assets/application.scss	Wed Sep 26 09:13:29 2018 +0200
@@ -6,6 +6,8 @@
 $large-offset: 2rem;
 $layerselect-height: 20rem;
 $layerselect-width: 20rem;
+$identify-height: 20rem;
+$identify-width: 20rem;
 $offset: 1rem;
 $searchbar-width: 50vw;
 $sidebar-height: 16rem;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/layers/Identify.vue	Wed Sep 26 09:13:29 2018 +0200
@@ -0,0 +1,95 @@
+<template>
+    <div class="identifymenu">
+        <div @click="collapse" class="d-flex flex-column ui-element minimizer">
+            <div>
+                <i class="fa fa-info"></i>
+            </div>
+        </div>
+        <div :class="identifyStyle">
+            <div v-if="!collapsed" class="card-body">
+                <div class="headline">
+                    <h4 class="card-title">Identified</h4>
+                </div>
+                <hr>
+                <div class="d-flex flex-column">
+                  <div v-for="feature of identifiedFeatures" :key="feature.getId()">
+                    {{ feature.getId().replace(/[.][^.]*$/,"") /* cut away everything from the last . to the end */}}:
+                    <small v-for="(value, key) in prepareProperties(feature)" :key="key">
+                      <div v-if="value">{{key}}:{{value}}</div>
+                    </small>
+                  </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</template>
+
+<style lang="scss">
+.identifymenu {
+  position: relative;
+  margin-right: $offset;
+}
+.identify {
+  background-color: white;
+  margin-left: $small-offset;
+  opacity: $slight-transparent;
+}
+
+.identifycollapsed {
+  height: $icon-height;
+  width: $icon-width;
+  transition: $transition-fast;
+}
+
+.identifyexpanded {
+  height: $identify-height;
+  width: $identify-width;
+}
+
+.minimizer {
+  position: absolute;
+  z-index: 2;
+  right: 0;
+  margin-top: $x-small-offset;
+  border-radius: $border-radius;
+  height: $icon-width;
+  width: $icon-height;
+}
+</style>
+
+<script>
+import { mapGetters } from "vuex";
+
+export default {
+  name: "identify",
+  data() {
+    return {
+      collapsed: true
+    };
+  },
+  computed: {
+    ...mapGetters("mapstore", ["identifiedFeatures"]),
+    identifyStyle() {
+      return {
+        "ui-element": true,
+        card: true,
+        identify: true,
+        shadow: true,
+        identifyexpanded: !this.collapsed,
+        identifycollapsed: this.collapsed
+      };
+    }
+  },
+  methods: {
+    collapse() {
+      this.collapsed = !this.collapsed;
+    },
+    prepareProperties(feature) {
+      // return dict object with propertyname:plainvalue prepared for display
+      var properties = feature.getProperties();
+      delete properties[feature.getGeometryName()];
+      return properties;
+    }
+  }
+};
+</script>
--- a/client/src/map/Maplayer.vue	Tue Sep 25 21:51:53 2018 +0200
+++ b/client/src/map/Maplayer.vue	Wed Sep 26 09:13:29 2018 +0200
@@ -48,7 +48,11 @@
     };
   },
   computed: {
-    ...mapGetters("mapstore", ["layers", "getLayerByName"]),
+    ...mapGetters("mapstore", [
+      "layers",
+      "getLayerByName",
+      "identifiedFeatures"
+    ]),
     mapStyle() {
       return {
         mapfull: !this.split,
@@ -196,8 +200,13 @@
       });
     },
     identify(coordinate, pixel) {
+      this.$store.commit("mapstore/setIdentifiedFeatures", []);
       // checking our WFS layers
       var features = this.openLayersMap.getFeaturesAtPixel(pixel);
+      this.$store.commit("mapstore/setIdentifiedFeatures", features);
+
+      // DEBUG output and example how to remove the GeometryName
+      /*
       for (let feature of features) {
         console.log("Identified:", feature.getId());
         for (let key of feature.getKeys()) {
@@ -206,6 +215,7 @@
           }
         }
       }
+      */
 
       // trying the GetFeatureInfo way for WMS
       var wmsSource = this.getLayerByName(
--- a/client/src/map/store.js	Tue Sep 25 21:51:53 2018 +0200
+++ b/client/src/map/store.js	Wed Sep 26 09:13:29 2018 +0200
@@ -147,7 +147,8 @@
         }),
         isVisible: true
       }
-    ]
+    ],
+    identifiedFeatures: []
   },
   getters: {
     layers: state => {
@@ -155,12 +156,18 @@
     },
     getLayerByName: state => name => {
       return state.layers.find(layer => layer.name === name);
+    },
+    identifiedFeatures: state => {
+      return state.identifiedFeatures;
     }
   },
   mutations: {
     toggleVisibility: (state, layer) => {
       state.layers[layer].isVisible = !state.layers[layer].isVisible;
       state.layers[layer].data.setVisible(state.layers[layer].isVisible);
+    },
+    setIdentifiedFeatures: (state, identifiedFeatures) => {
+      state.identifiedFeatures = identifiedFeatures;
     }
   }
 };