Select style multiple select interactions removed
This fixes issue 10486 by removing the event listeners when an interaction is removed from a map.
This commit is contained in:
committed by
Andreas Hocevar
parent
c196f2f7b0
commit
10c7f08fa4
@@ -167,6 +167,16 @@ class Select extends Interaction {
|
|||||||
|
|
||||||
const options = opt_options ? opt_options : {};
|
const options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.boundAddFeature_ = this.addFeature_.bind(this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.boundRemoveFeature_ = this.removeFeature_.bind(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {import("../events/condition.js").Condition}
|
* @type {import("../events/condition.js").Condition}
|
||||||
@@ -250,9 +260,8 @@ class Select extends Interaction {
|
|||||||
*/
|
*/
|
||||||
this.featureLayerAssociation_ = {};
|
this.featureLayerAssociation_ = {};
|
||||||
|
|
||||||
const features = this.getFeatures();
|
this.features_.addEventListener(CollectionEventType.ADD, this.boundAddFeature_);
|
||||||
features.addEventListener(CollectionEventType.ADD, this.addFeature_.bind(this));
|
this.features_.addEventListener(CollectionEventType.REMOVE, this.boundRemoveFeature_);
|
||||||
features.addEventListener(CollectionEventType.REMOVE, this.removeFeature_.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -323,6 +332,10 @@ class Select extends Interaction {
|
|||||||
if (map && this.style_) {
|
if (map && this.style_) {
|
||||||
this.features_.forEach(this.applySelectedStyle_.bind(this));
|
this.features_.forEach(this.applySelectedStyle_.bind(this));
|
||||||
}
|
}
|
||||||
|
if (!map) {
|
||||||
|
this.features_.removeEventListener(CollectionEventType.ADD, this.boundAddFeature_);
|
||||||
|
this.features_.removeEventListener(CollectionEventType.REMOVE, this.boundRemoveFeature_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user