diff client/src/store/map.js @ 2910:c8c7122047a2

client: stretches: select/unselect stretches by clicking on them on the map
author Markus Kottlaender <markus@intevation.de>
date Tue, 02 Apr 2019 18:59:26 +0200
parents 5105f6ad0176
children 173ce013a021
line wrap: on
line diff
--- a/client/src/store/map.js	Tue Apr 02 18:19:43 2019 +0200
+++ b/client/src/store/map.js	Tue Apr 02 18:59:26 2019 +0200
@@ -771,7 +771,6 @@
 
               for (let feature of features) {
                 let id = feature.getId();
-
                 // avoid identifying the same feature twice
                 if (
                   identifiedFeatures.findIndex(
@@ -835,6 +834,28 @@
                     });
                   }
                 }
+
+                // get selected stretch
+                if (/^stretches/.test(id)) {
+                  if (rootState.imports.selectedStretchId === feature.getId()) {
+                    commit("imports/selectedStretchId", null, { root: true });
+                  } else {
+                    commit("imports/selectedStretchId", feature.getId(), {
+                      root: true
+                    });
+                    commit("moveMap", {
+                      coordinates: getCenter(
+                        feature
+                          .getGeometry()
+                          .clone()
+                          .transform("EPSG:3857", "EPSG:4326")
+                          .getExtent()
+                      ),
+                      zoom: null,
+                      preventZoomOut: true
+                    });
+                  }
+                }
               }
 
               commit("setIdentifiedFeatures", identifiedFeatures);