mobility-toolbox-js 3.0.0-beta.3 → 3.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,25 +135,27 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
135
135
  if (!this.map || !this.maplibreLayer) {
136
136
  return;
137
137
  }
138
- // Apply the initial visibiltity.
139
- const { maplibreMap } = this.maplibreLayer;
140
- if (!maplibreMap) {
141
- // If the maplibreMap is not yet created because the map has no target yet, we
138
+ if (!this.map.getTargetElement()) {
139
+ // If ther e is no target element the maplibreMap is not yet created, we
142
140
  // relaunch the initialisation when it's the case.
143
141
  this.olListenersKeys.push(this.map.on('change:target', () => {
144
142
  this.attachToMap(map);
145
143
  }));
146
144
  return;
147
145
  }
148
- // maplibreMap.loaded() and maplibreMap.isStyleLoaded() are reliable only on the first call of init.
149
- // On the next call (when a topic change for example), these functions returns false because
150
- // the style is being modified.
151
- // That's why we rely on a property instead for the next calls.
152
- if (maplibreMap.loaded()) {
153
- this.onLoad();
154
- }
155
- else {
156
- maplibreMap.once('load', this.onLoad);
146
+ // Apply the initial visibility if possible otherwise we wait for the load event of the layer
147
+ const { maplibreMap } = this.maplibreLayer;
148
+ if (maplibreMap) {
149
+ // maplibreMap.loaded() and maplibreMap.isStyleLoaded() are reliable only on the first call of init.
150
+ // On the next call (when a topic change for example), these functions returns false because
151
+ // the style is being modified.
152
+ // That's why we rely on a property instead for the next calls.
153
+ if (maplibreMap.loaded()) {
154
+ this.onLoad();
155
+ }
156
+ else {
157
+ maplibreMap.once('load', this.onLoad);
158
+ }
157
159
  }
158
160
  // Apply the visibiltity when layer's visibility change.
159
161
  this.olListenersKeys.push(
@@ -189,7 +189,7 @@ function PropertiesLayerMixin(Base) {
189
189
  this.map.removeLayer(child);
190
190
  });
191
191
  // @ts-ignore
192
- (super.detachFromMap || (() => { }))(map);
192
+ (super.detachFromMap || (() => { }))();
193
193
  }
194
194
  /**
195
195
  * Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mobility-toolbox-js",
3
3
  "license": "MIT",
4
4
  "description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
5
- "version": "3.0.0-beta.3",
5
+ "version": "3.0.0-beta.5",
6
6
  "homepage": "https://mobility-toolbox-js.geops.io/",
7
7
  "module": "index.js",
8
8
  "exports": {