Skip to content

Commit

Permalink
Properly detect feature on unmanaged layer
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Jan 27, 2016
1 parent 7b78c21 commit 4b29e24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ol/interaction/selectinteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
* @param {ol.layer.Layer} layer Layer.
*/
function(feature, layer) {
if (layer !== this.featureOverlay_) {
if (layer !== null) {
if (add || toggle) {
if (this.filter_(feature, layer) &&
!ol.array.includes(features.getArray(), feature) &&
Expand All @@ -332,7 +332,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
this.addFeatureLayerAssociation_(feature, layer);
}
}
} else {
} else if (this.featureOverlay_.getSource().hasFeature(feature)) {
if (remove || toggle) {
deselected.push(feature);
this.removeFeatureLayerAssociation_(feature);
Expand Down
11 changes: 11 additions & 0 deletions src/ol/source/vectorsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,17 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
};


/**
* @param {ol.Feature} feature Feature.
* @return {boolean} Feature is in source.
*/
ol.source.Vector.prototype.hasFeature = function(feature) {
goog.asserts.assertInstanceof(feature, ol.Feature);
var id = feature.getId();
return id ? id in this.idIndex_ : goog.getUid(feature) in this.undefIdIndex_;
};


/**
* @return {boolean} Is empty.
*/
Expand Down

0 comments on commit 4b29e24

Please sign in to comment.