# HG changeset patch # User Markus Kottlaender # Date 1551776161 -3600 # Node ID f2758dafe3906fa7bf57ad389870d2c5f6f6e997 # Parent 3dc7c0f60a628f04fb98586fc2851aa4560b10de 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. diff -r 3dc7c0f60a62 -r f2758dafe390 client/src/store/map.js --- 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