From 8df95bc674561e2039e4b9d7694706db13546796 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 3 Apr 2014 14:30:58 +0200 Subject: [PATCH] Handle skipped features when setting the map When a Select interaction is removed from the map, it should remove its selected features from the map's skippedFeatures collection. When it is added to a map, it should add them. --- src/ol/interaction/selectinteraction.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index 827d98444c..9347deae50 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -179,8 +179,20 @@ ol.interaction.Select.prototype.handleMapBrowserEvent = * @inheritDoc */ ol.interaction.Select.prototype.setMap = function(map) { + var currentMap = this.getMap(); + var selectedFeatures = this.featureOverlay_.getFeatures(); + if (!goog.isNull(currentMap)) { + selectedFeatures.forEach(function(feature) { + currentMap.getSkippedFeatures().remove(feature); + }); + } goog.base(this, 'setMap', map); this.featureOverlay_.setMap(map); + if (!goog.isNull(map)) { + selectedFeatures.forEach(function(feature) { + map.getSkippedFeatures().push(feature); + }); + } };