mobility-toolbox-js 3.0.0-beta.26 → 3.0.0-beta.28
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 +22 -2
- package/mbt.js.map +3 -3
- package/mbt.min.js +13 -13
- package/mbt.min.js.map +3 -3
- package/ol/layers/Layer.js +10 -2
- package/ol/layers/MaplibreLayer.js +5 -0
- package/ol/layers/MaplibreStyleLayer.js +10 -0
- package/package.json +1 -1
package/ol/layers/Layer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debounce from 'lodash.debounce';
|
|
2
2
|
import OLLayer from 'ol/layer/Layer';
|
|
3
|
-
import
|
|
3
|
+
import LayerRenderer from 'ol/renderer/Layer';
|
|
4
4
|
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
5
5
|
let deprecated = () => { };
|
|
6
6
|
if (typeof window !== 'undefined' &&
|
|
@@ -10,6 +10,14 @@ if (typeof window !== 'undefined' &&
|
|
|
10
10
|
console.warn(message);
|
|
11
11
|
}, 1000);
|
|
12
12
|
}
|
|
13
|
+
class EmptyLayerRenderer extends LayerRenderer {
|
|
14
|
+
prepareFrame() {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
renderFrame() {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
13
21
|
/**
|
|
14
22
|
* An OpenLayers layer here only for backward compatibility v2.
|
|
15
23
|
* @deprecated Use an OpenLayers Layer instead.
|
|
@@ -24,7 +32,7 @@ class Layer extends MobilityLayerMixin(OLLayer) {
|
|
|
24
32
|
}
|
|
25
33
|
// ol does not like when it returns null.
|
|
26
34
|
createRenderer() {
|
|
27
|
-
return new
|
|
35
|
+
return new EmptyLayerRenderer(this);
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
export default Layer;
|
|
@@ -53,8 +53,13 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
53
53
|
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
54
54
|
*/
|
|
55
55
|
constructor(options) {
|
|
56
|
+
var _a;
|
|
56
57
|
const newOptions = Object.assign(Object.assign({ apiKeyName: 'key', style: 'travic_v2', url: 'https://maps.geops.io' }, (options || {})), { mapLibreOptions: Object.assign({}, (options.mapLibreOptions || {})) });
|
|
57
58
|
if (!newOptions.mapLibreOptions.style &&
|
|
59
|
+
((_a = newOptions.url) === null || _a === void 0 ? void 0 : _a.includes('style.json'))) {
|
|
60
|
+
newOptions.mapLibreOptions.style = newOptions.url;
|
|
61
|
+
}
|
|
62
|
+
else if (!newOptions.mapLibreOptions.style &&
|
|
58
63
|
newOptions.apiKey &&
|
|
59
64
|
newOptions.style &&
|
|
60
65
|
typeof newOptions.style === 'string') {
|
|
@@ -185,6 +185,16 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
|
|
|
185
185
|
this.detachFromMap();
|
|
186
186
|
this.attachToMap(map);
|
|
187
187
|
}
|
|
188
|
+
}),
|
|
189
|
+
// When the style changes we wait that it is loaded to relaunch the onLoad
|
|
190
|
+
this.maplibreLayer.on('propertychange', (evt) => {
|
|
191
|
+
if (evt.key === 'style') {
|
|
192
|
+
evt.target.maplibreMap.once('styledata', () => {
|
|
193
|
+
evt.target.maplibreMap.once('idle', () => {
|
|
194
|
+
this.onLoad();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}
|
|
188
198
|
}));
|
|
189
199
|
}
|
|
190
200
|
/**
|
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.28",
|
|
6
6
|
"homepage": "https://mobility-toolbox-js.geops.io/",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|