Fix adding controls with map config

If a control like ol.control.Bar adds sub controls when added to a map
it fails during map creating because the listeners are added after the control
was added to the map.
This commit is contained in:
Maximilian Krög
2021-07-12 13:49:08 +02:00
committed by Maximilian Kroeg
parent 5d7f7dbf51
commit 8f8027c33a

View File

@@ -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));
}
/**