diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 72547772d3..a7da6c0dde 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -383,16 +383,6 @@ class PluggableMap extends BaseObject { // is "defined" already. this.setProperties(optionsInternal.values); - this.controls.forEach( - /** - * @param {import("./control/Control.js").default} control Control. - * @this {PluggableMap} - */ - function (control) { - control.setMap(this); - }.bind(this) - ); - this.controls.addEventListener( CollectionEventType.ADD, /** @@ -413,16 +403,6 @@ class PluggableMap extends BaseObject { }.bind(this) ); - this.interactions.forEach( - /** - * @param {import("./interaction/Interaction.js").default} interaction Interaction. - * @this {PluggableMap} - */ - function (interaction) { - interaction.setMap(this); - }.bind(this) - ); - this.interactions.addEventListener( CollectionEventType.ADD, /** @@ -443,8 +423,6 @@ class PluggableMap extends BaseObject { }.bind(this) ); - this.overlays_.forEach(this.addOverlayInternal_.bind(this)); - this.overlays_.addEventListener( CollectionEventType.ADD, /** @@ -473,6 +451,28 @@ class PluggableMap extends BaseObject { event.element.setMap(null); }.bind(this) ); + + this.controls.forEach( + /** + * @param {import("./control/Control.js").default} control Control. + * @this {PluggableMap} + */ + function (control) { + control.setMap(this); + }.bind(this) + ); + + this.interactions.forEach( + /** + * @param {import("./interaction/Interaction.js").default} interaction Interaction. + * @this {PluggableMap} + */ + function (interaction) { + interaction.setMap(this); + }.bind(this) + ); + + this.overlays_.forEach(this.addOverlayInternal_.bind(this)); } /**