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.
- package/mbt.js +119 -117
- package/mbt.js.map +3 -3
- package/mbt.min.js +1 -1
- package/mbt.min.js.map +2 -2
- package/ol/layers/MaplibreStyleLayer.js +15 -13
- package/ol/mixins/PropertiesLayerMixin.js +1 -1
- package/package.json +1 -1
|
@@ -135,25 +135,27 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
|
|
|
135
135
|
if (!this.map || !this.maplibreLayer) {
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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 || (() => { }))(
|
|
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.
|
|
5
|
+
"version": "3.0.0-beta.5",
|
|
6
6
|
"homepage": "https://mobility-toolbox-js.geops.io/",
|
|
7
7
|
"module": "index.js",
|
|
8
8
|
"exports": {
|