CK-240: fix multiple select interactions on map
event handlers have to be (de)activated when the interaction is added or removed to the map, not when constructed added unit test
This commit is contained in:
1 parent
10c7f08fa4
commit
a30a92a963
2 files changed
+57
-5
No files matched your search
@@ -259,9 +259,6 @@ class Select extends Interaction {
|
||||
* @type {Object<string, import("../layer/Layer.js").default>}
|
||||
*/
|
||||
this.featureLayerAssociation_ = {};
|
||||
|
||||
this.features_.addEventListener(CollectionEventType.ADD, this.boundAddFeature_);
|
||||
this.features_.addEventListener(CollectionEventType.REMOVE, this.boundRemoveFeature_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,8 +326,13 @@ class Select extends Interaction {
|
||||
this.features_.forEach(this.restorePreviousStyle_.bind(this));
|
||||
}
|
||||
super.setMap(map);
|
||||
if (map && this.style_) {
|
||||
this.features_.forEach(this.applySelectedStyle_.bind(this));
|
||||
if (map) {
|
||||
this.features_.addEventListener(CollectionEventType.ADD, this.boundAddFeature_);
|
||||
this.features_.addEventListener(CollectionEventType.REMOVE, this.boundRemoveFeature_);
|
||||
|
||||
if (this.style_) {
|
||||
this.features_.forEach(this.applySelectedStyle_.bind(this));
|
||||
}
|
||||
}
|
||||
if (!map) {
|
||||
this.features_.removeEventListener(CollectionEventType.ADD, this.boundAddFeature_);
|
||||
|
||||
Reference in new issue
Block a user