mobility-toolbox-js 3.0.0-beta.7 → 3.0.0-beta.8
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/api/RealtimeAPI.js +96 -89
- package/common/utils/getLayersAsFlatArray.js +5 -1
- package/maplibre/layers/RealtimeLayer.js +2 -2
- package/mbt.js +105 -90
- package/mbt.js.map +3 -3
- package/mbt.min.js +13 -13
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.js +18 -8
- package/ol/controls/RoutingControl.js +3 -0
- package/ol/controls/StopFinderControl.js +3 -0
- package/ol/layers/RealtimeLayer.js +2 -2
- package/ol/utils/getFeatureInfoAtCoordinate.js +1 -1
- package/package.json +1 -1
|
@@ -26,6 +26,11 @@ class CopyrightControl extends Control {
|
|
|
26
26
|
const element = createDefaultCopyrightElement();
|
|
27
27
|
element.className = options.className || 'mbt-copyright';
|
|
28
28
|
super(Object.assign({ element }, options));
|
|
29
|
+
this.format =
|
|
30
|
+
options.format ||
|
|
31
|
+
((copyrights) => {
|
|
32
|
+
return copyrights === null || copyrights === void 0 ? void 0 : copyrights.join(' | ');
|
|
33
|
+
});
|
|
29
34
|
}
|
|
30
35
|
render({ frameState }) {
|
|
31
36
|
if (!frameState) {
|
|
@@ -35,18 +40,23 @@ class CopyrightControl extends Control {
|
|
|
35
40
|
let copyrights = [];
|
|
36
41
|
// This code loop comes mainly from ol.
|
|
37
42
|
frameState === null || frameState === void 0 ? void 0 : frameState.layerStatesArray.forEach((layerState) => {
|
|
43
|
+
var _a;
|
|
38
44
|
const { layer } = layerState;
|
|
39
|
-
if (frameState &&
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
layer.
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
if (frameState && inView(layerState, frameState.viewState)) {
|
|
46
|
+
if ((_a = layer === null || layer === void 0 ? void 0 : layer.getSource()) === null || _a === void 0 ? void 0 : _a.getAttributions()) {
|
|
47
|
+
copyrights = copyrights.concat(layer.getSource().getAttributions()(frameState));
|
|
48
|
+
}
|
|
49
|
+
if (layer === null || layer === void 0 ? void 0 : layer.get('copyrights')) {
|
|
50
|
+
let copyProp = layer.get('copyrights');
|
|
51
|
+
copyProp = !Array.isArray(copyProp) ? [copyProp] : copyProp;
|
|
52
|
+
if (copyProp === null || copyProp === void 0 ? void 0 : copyProp.length) {
|
|
53
|
+
copyrights.push(...copyProp);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
46
56
|
}
|
|
47
57
|
});
|
|
48
58
|
const unique = removeDuplicate(copyrights) || [];
|
|
49
|
-
this.element.innerHTML =
|
|
59
|
+
this.element.innerHTML = this.format(unique);
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
export default CopyrightControl;
|
|
@@ -114,6 +114,9 @@ class RoutingControl extends Control {
|
|
|
114
114
|
this.segments = [];
|
|
115
115
|
this.format = new GeoJSON({ featureProjection: 'EPSG:3857' });
|
|
116
116
|
this.initialRouteDrag = {};
|
|
117
|
+
if (!this.element) {
|
|
118
|
+
this.createDefaultElement();
|
|
119
|
+
}
|
|
117
120
|
/** True if the control is requesting the backend. */
|
|
118
121
|
this.loading = false;
|
|
119
122
|
/** @private */
|
|
@@ -39,5 +39,8 @@ class StopFinderControl extends Control {
|
|
|
39
39
|
const coord = fromLonLat(suggestion.geometry.coordinates);
|
|
40
40
|
(_a = this.getMap()) === null || _a === void 0 ? void 0 : _a.getView().setCenter(coord);
|
|
41
41
|
}
|
|
42
|
+
search(q, abortController) {
|
|
43
|
+
return this.controller.search(q, abortController);
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
46
|
export default StopFinderControl;
|
|
@@ -11,7 +11,7 @@ import RealtimeLayerRenderer from '../renderers/RealtimeLayerRenderer';
|
|
|
11
11
|
/** @private */
|
|
12
12
|
const format = new GeoJSON();
|
|
13
13
|
/**
|
|
14
|
-
* Responsible for loading and display data from the geOps
|
|
14
|
+
* Responsible for loading and display data from the geOps realtime API.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* import { RealtimeLayer } from 'mobility-toolbox-js/ol';
|
|
@@ -38,7 +38,7 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
38
38
|
* @param {RealtimeLayerOptions} options
|
|
39
39
|
* @param {boolean} [options.allowRenderWhenAnimating=false] Allow rendering of the layer when the map is animating.
|
|
40
40
|
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
41
|
-
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps
|
|
41
|
+
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps realtime API url.
|
|
42
42
|
*
|
|
43
43
|
*/
|
|
44
44
|
constructor(options) {
|
|
@@ -63,7 +63,7 @@ const getFeatureInfoAtCoordinate = (coordinate, layers, hitTolerance = 5) => __a
|
|
|
63
63
|
const source = layer === null || layer === void 0 ? void 0 : layer.getSource();
|
|
64
64
|
// @ts-ignore
|
|
65
65
|
if (source === null || source === void 0 ? void 0 : source.getFeatureInfoUrl) {
|
|
66
|
-
const id = getUid(
|
|
66
|
+
const id = getUid(layer);
|
|
67
67
|
// Abort and recreates one controller per layer
|
|
68
68
|
(_c = abortControllers[id]) === null || _c === void 0 ? void 0 : _c.abort();
|
|
69
69
|
abortControllers[id] = new AbortController();
|
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.8",
|
|
6
6
|
"homepage": "https://mobility-toolbox-js.geops.io/",
|
|
7
7
|
"module": "index.js",
|
|
8
8
|
"exports": {
|