changeset 2510:f2758dafe390

client: identify tool: avoid identifying the same feature twice If the same feature from the geoserver is represented by more than one geometry/feature on the map the feature will be added to the identifiedFeatures list twice. This situation appeared with the new layer for critical bottlenecks, which places a second feature on the map, on top of the already existing bottleneck outline. Clicking that new critical bottleneck indicator, lead to the bottleneck appearing twice in the identified box.
author Markus Kottlaender <markus@intevation.de>
date Tue, 05 Mar 2019 09:56:01 +0100
parents 3dc7c0f60a62
children e958104be9a9
files client/src/store/map.js
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/store/map.js	Tue Mar 05 09:12:29 2019 +0100
+++ b/client/src/store/map.js	Tue Mar 05 09:56:01 2019 +0100
@@ -749,11 +749,21 @@
               hitTolerance: 7
             });
             if (features) {
-              commit("setIdentifiedFeatures", features);
+              let identifiedFeatures = [];
 
-              // get selected bottleneck from identified features
               for (let feature of features) {
                 let id = feature.getId();
+                console.log(id);
+
+                if (
+                  identifiedFeatures.findIndex(
+                    f => f.getId() === feature.getId()
+                  ) === -1
+                ) {
+                  identifiedFeatures.push(feature);
+                }
+
+                // get selected bottleneck
                 // RegExp.prototype.test() works with number, str and undefined
                 if (/^bottlenecks/.test(id)) {
                   if (
@@ -781,6 +791,8 @@
                   }
                 }
               }
+
+              commit("setIdentifiedFeatures", identifiedFeatures);
             }
 
             // DEBUG output and example how to remove the GeometryName