mobility-toolbox-js 3.0.0-beta.15 → 3.0.0-beta.16
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 +27 -17
- package/mbt.js.map +2 -2
- package/mbt.min.js +7 -7
- package/mbt.min.js.map +3 -3
- package/ol/layers/MaplibreLayer.d.ts +2 -1
- package/ol/layers/MaplibreLayer.js +14 -14
- package/ol/mixins/PropertiesLayerMixin.js +2 -2
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import OlMap from 'ol/Map';
|
|
2
2
|
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
|
|
3
|
-
import type { MapLibreLayerOptions } from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
|
|
3
|
+
import type { MapLibreLayerOptions, MapLibreOptions } from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
|
|
4
4
|
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
5
5
|
export type MaplibreLayerOptions = MobilityLayerOptions & MapLibreLayerOptions & {
|
|
6
6
|
apiKey?: string;
|
|
7
7
|
apiKeyName?: string;
|
|
8
8
|
style?: string | maplibregl.StyleSpecification;
|
|
9
9
|
url?: string;
|
|
10
|
+
mapLibreOptions?: MapLibreOptions;
|
|
10
11
|
};
|
|
11
12
|
declare const MaplibreLayer_base: {
|
|
12
13
|
new (...args: any[]): {
|
|
@@ -2,6 +2,11 @@ import debounce from 'lodash.debounce';
|
|
|
2
2
|
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
|
|
3
3
|
import { getUrlWithParams } from '../../common/utils';
|
|
4
4
|
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
5
|
+
const buildStyleUrl = (url, style, apiKey, apiKeyName) => {
|
|
6
|
+
return getUrlWithParams(`${url}/styles/${style}/style.json`, {
|
|
7
|
+
[apiKeyName]: apiKey,
|
|
8
|
+
}).toString();
|
|
9
|
+
};
|
|
5
10
|
/**
|
|
6
11
|
* An OpenLayers layer able to display data from the [geOps Maps API](https://developer.geops.io/apis/maps).
|
|
7
12
|
*
|
|
@@ -31,12 +36,12 @@ import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
|
31
36
|
class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
32
37
|
get mbMap() {
|
|
33
38
|
// eslint-disable-next-line no-console
|
|
34
|
-
console.warn('
|
|
39
|
+
console.warn('.mbMap deprecated. Use layer.maplibreMap.');
|
|
35
40
|
return this.maplibreMap;
|
|
36
41
|
}
|
|
37
42
|
get maplibreMap() {
|
|
38
43
|
// eslint-disable-next-line no-console
|
|
39
|
-
console.warn('
|
|
44
|
+
console.warn('.maplibreMap eprecated. Use layer.mapLibreMap.');
|
|
40
45
|
return this.mapLibreMap;
|
|
41
46
|
}
|
|
42
47
|
// get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
|
|
@@ -70,7 +75,11 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
70
75
|
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
71
76
|
*/
|
|
72
77
|
constructor(options) {
|
|
73
|
-
|
|
78
|
+
const newOptions = Object.assign(Object.assign({ apiKeyName: 'key', style: 'travic_v2', url: 'https://maps.geops.io' }, (options || {})), { mapLibreOptions: Object.assign({}, (options.mapLibreOptions || {})) });
|
|
79
|
+
if (!newOptions.mapLibreOptions.style && newOptions.apiKey) {
|
|
80
|
+
newOptions.mapLibreOptions.style = buildStyleUrl(newOptions.url, newOptions.style, newOptions.apiKey, newOptions.apiKeyName);
|
|
81
|
+
}
|
|
82
|
+
super(newOptions);
|
|
74
83
|
}
|
|
75
84
|
/**
|
|
76
85
|
* Initialize the layer and listen to feature clicks.
|
|
@@ -99,20 +108,11 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
99
108
|
return this.url;
|
|
100
109
|
}
|
|
101
110
|
/// Otherwise build the complete style url.
|
|
102
|
-
return
|
|
103
|
-
[this.get('apiKeyName')]: this.get('apiKey'),
|
|
104
|
-
}).toString();
|
|
111
|
+
return buildStyleUrl(this.url, this.style, this.get('apiKey'), this.get('apiKeyName'));
|
|
105
112
|
}
|
|
106
|
-
// eslint-disable-next-line class-methods-use-this
|
|
107
|
-
// createMap(options: MapOptions): Map {
|
|
108
|
-
// return new Map(options);
|
|
109
|
-
// }
|
|
110
|
-
// createRenderer(): MaplibreLayerRenderer {
|
|
111
|
-
// return new MaplibreLayerRenderer(this);
|
|
112
|
-
// }
|
|
113
113
|
updateMaplibreMap() {
|
|
114
114
|
var _a;
|
|
115
|
-
(_a = this.
|
|
115
|
+
(_a = this.mapLibreMap) === null || _a === void 0 ? void 0 : _a.setStyle(this.getStyle(), { diff: false });
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Create a copy of the MaplibreLayer.
|
|
@@ -112,7 +112,7 @@ function PropertiesLayerMixin(Base) {
|
|
|
112
112
|
}
|
|
113
113
|
}));
|
|
114
114
|
this.options = options;
|
|
115
|
-
this.children
|
|
115
|
+
this.set('children', options.children || []); // Trigger the on children change event
|
|
116
116
|
}
|
|
117
117
|
// @ts-expect-error - this is a mixin
|
|
118
118
|
setMapInternal(map) {
|
|
@@ -130,7 +130,7 @@ function PropertiesLayerMixin(Base) {
|
|
|
130
130
|
(oldValue || []).forEach((child) => {
|
|
131
131
|
child.set('parent', undefined);
|
|
132
132
|
});
|
|
133
|
-
(this.children || []).forEach((child) => {
|
|
133
|
+
(this.get('children') || []).forEach((child) => {
|
|
134
134
|
child.set('parent', this);
|
|
135
135
|
});
|
|
136
136
|
}
|
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.16",
|
|
6
6
|
"homepage": "https://mobility-toolbox-js.geops.io/",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|