mobility-toolbox-js 3.0.0-beta.2 → 3.0.0-beta.21
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/HttpAPI.d.ts +20 -0
- package/api/HttpAPI.js +0 -11
- package/api/RealtimeAPI.d.ts +404 -0
- package/api/RealtimeAPI.js +342 -276
- package/api/RoutingAPI.d.ts +47 -0
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +44 -0
- package/api/StopsAPI.js +16 -10
- package/api/WebSocketAPI.d.ts +147 -0
- package/api/WebSocketAPI.js +164 -164
- package/api/index.d.ts +3 -0
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +76 -0
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +53 -0
- package/common/controls/StopFinderControlCommon.js +31 -31
- package/common/index.d.ts +2 -0
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +267 -0
- package/common/mixins/RealtimeLayerMixin.js +401 -393
- package/common/styles/index.d.ts +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/typedefs.d.ts +219 -0
- package/common/typedefs.js +7 -1
- package/common/utils/compareDepartures.d.ts +10 -0
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/constants.d.ts +5 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
- package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
- package/common/utils/createRealtimeFilters.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.js +5 -1
- package/common/utils/getMapGlCopyrights.d.ts +17 -0
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getUrlWithParams.d.ts +8 -0
- package/common/utils/getVehiclePosition.d.ts +17 -0
- package/common/utils/getVehiclePosition.js +9 -3
- package/common/utils/index.d.ts +16 -0
- package/common/utils/realtimeConfig.d.ts +64 -0
- package/common/utils/removeDuplicate.d.ts +9 -0
- package/common/utils/renderTrajectories.d.ts +16 -0
- package/common/utils/renderTrajectories.js +6 -6
- package/common/utils/sortAndFilterDepartures.d.ts +15 -0
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.js +5 -1
- package/common/utils/timeUtils.d.ts +23 -0
- package/common/utils/toMercatorExtent.d.ts +5 -0
- package/iife.d.ts +2 -0
- package/index.d.ts +9 -0
- package/maplibre/controls/CopyrightControl.d.ts +35 -0
- package/maplibre/controls/index.d.ts +1 -0
- package/maplibre/index.d.ts +5 -0
- package/maplibre/layers/Layer.d.ts +28 -0
- package/maplibre/layers/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +181 -0
- package/maplibre/layers/RealtimeLayer.js +29 -5
- package/maplibre/layers/index.d.ts +2 -0
- package/maplibre/utils/getMercatorResolution.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/maplibre/utils/index.d.ts +2 -0
- package/mbt.js +22103 -14430
- package/mbt.js.map +4 -4
- package/mbt.min.js +61 -58
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.js +18 -8
- package/ol/controls/RoutingControl.d.ts +202 -0
- package/ol/controls/RoutingControl.js +220 -219
- package/ol/controls/StopFinderControl.d.ts +37 -0
- package/ol/controls/StopFinderControl.js +4 -1
- package/ol/controls/index.d.ts +3 -0
- package/ol/index.d.ts +7 -0
- package/ol/index.js +1 -0
- package/ol/layers/Layer.d.ts +101 -0
- package/ol/layers/Layer.js +25 -0
- package/ol/layers/MaplibreLayer.d.ts +160 -0
- package/ol/layers/MaplibreLayer.js +97 -27
- package/ol/layers/MaplibreStyleLayer.d.ts +237 -0
- package/ol/layers/MaplibreStyleLayer.js +291 -267
- package/ol/layers/RealtimeLayer.d.ts +283 -0
- package/ol/layers/RealtimeLayer.js +143 -128
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +31 -0
- package/ol/layers/index.d.ts +5 -0
- package/ol/layers/index.js +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +96 -0
- package/ol/mixins/MobilityLayerMixin.js +1 -4
- package/ol/mixins/PropertiesLayerMixin.d.ts +135 -0
- package/ol/mixins/PropertiesLayerMixin.js +112 -140
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -0
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
- package/ol/renderers/RealtimeLayerRenderer.js +58 -53
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/routingStyle.d.ts +4 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
- package/ol/utils/getFeatureInfoAtCoordinate.js +12 -18
- package/ol/utils/index.d.ts +1 -0
- package/package.json +31 -31
- package/setupTests.d.ts +1 -0
- package/setupTests.js +3 -4
- package/types/common.d.ts +55 -48
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +91 -93
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/ol/layers/MapGlLayer.js +0 -142
package/ol/layers/MapGlLayer.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import Source from 'ol/source/Source';
|
|
2
|
-
import BaseEvent from 'ol/events/Event';
|
|
3
|
-
import Layer from 'ol/layer/Layer';
|
|
4
|
-
import debounce from 'lodash.debounce';
|
|
5
|
-
import { getUrlWithParams, getMapGlCopyrights } from '../../common/utils';
|
|
6
|
-
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
7
|
-
/**
|
|
8
|
-
* Common class for Maplibre and Maplibre and potential other fork from Maplibre.
|
|
9
|
-
* It's used to share code between Maplibre and Maplibre layers without importing both libs.
|
|
10
|
-
* @private
|
|
11
|
-
*/
|
|
12
|
-
class MapGlLayer extends MobilityLayerMixin(Layer) {
|
|
13
|
-
get apiKey() {
|
|
14
|
-
return this.get('apiKey');
|
|
15
|
-
}
|
|
16
|
-
set apiKey(newValue) {
|
|
17
|
-
this.set('apiKey', newValue);
|
|
18
|
-
}
|
|
19
|
-
get apiKeyName() {
|
|
20
|
-
return this.get('apiKeyName');
|
|
21
|
-
}
|
|
22
|
-
set apiKeyName(newValue) {
|
|
23
|
-
this.set('apiKeyName', newValue);
|
|
24
|
-
}
|
|
25
|
-
get style() {
|
|
26
|
-
return this.get('style');
|
|
27
|
-
}
|
|
28
|
-
set style(newValue) {
|
|
29
|
-
this.set('style', newValue);
|
|
30
|
-
}
|
|
31
|
-
get url() {
|
|
32
|
-
return this.get('url');
|
|
33
|
-
}
|
|
34
|
-
set url(newValue) {
|
|
35
|
-
this.set('url', newValue);
|
|
36
|
-
}
|
|
37
|
-
get queryRenderedFeaturesOptions() {
|
|
38
|
-
return this.get('queryRenderedFeaturesOptions');
|
|
39
|
-
}
|
|
40
|
-
set queryRenderedFeaturesOptions(newValue) {
|
|
41
|
-
this.set('queryRenderedFeaturesOptions', newValue);
|
|
42
|
-
}
|
|
43
|
-
constructor(options) {
|
|
44
|
-
super(Object.assign(Object.assign({ source: new Source({
|
|
45
|
-
attributions: () => {
|
|
46
|
-
return (this.mbMap && getMapGlCopyrights(this.mbMap)) || [];
|
|
47
|
-
},
|
|
48
|
-
}), apiKeyName: 'key', style: 'travic_v2', url: 'https://maps.geops.io' }, (options || {})), { mapOptions: Object.assign({ interactive: false, trackResize: false, attributionControl: false }, ((options === null || options === void 0 ? void 0 : options.mapOptions) || {})), queryRenderedFeaturesOptions: Object.assign({}, ((options === null || options === void 0 ? void 0 : options.queryRenderedFeaturesOptions) || {})) }));
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Initialize the layer and listen to feature clicks.
|
|
52
|
-
* @param {ol/Map~Map} map
|
|
53
|
-
*/
|
|
54
|
-
attachToMap(map) {
|
|
55
|
-
super.attachToMap(map);
|
|
56
|
-
this.loadMbMap();
|
|
57
|
-
const updateMbMapDebounced = debounce(this.updateMbMap.bind(this), 150);
|
|
58
|
-
this.olListenersKeys.push(this.on('propertychange', (evt) => {
|
|
59
|
-
if (/(apiKey|apiKeyName|url|style|)/.test(evt.key)) {
|
|
60
|
-
updateMbMapDebounced();
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Terminate what was initialized in init function. Remove layer, events...
|
|
66
|
-
*/
|
|
67
|
-
detachFromMap() {
|
|
68
|
-
if (this.mbMap) {
|
|
69
|
-
// Some asynchrone repaints are triggered even if the mbMap has been removed,
|
|
70
|
-
// to avoid display of errors we set an empty function.
|
|
71
|
-
this.mbMap.triggerRepaint = () => { };
|
|
72
|
-
this.mbMap.remove();
|
|
73
|
-
this.mbMap = undefined;
|
|
74
|
-
}
|
|
75
|
-
this.loaded = false;
|
|
76
|
-
super.detachFromMap();
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Create the Maplibre map.
|
|
80
|
-
* @private
|
|
81
|
-
*/
|
|
82
|
-
loadMbMap() {
|
|
83
|
-
var _a, _b, _c;
|
|
84
|
-
this.loaded = false;
|
|
85
|
-
this.olListenersKeys.push(
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
(_a = this.map) === null || _a === void 0 ? void 0 : _a.on('change:target', this.loadMbMap.bind(this)));
|
|
88
|
-
if (!((_b = this.map) === null || _b === void 0 ? void 0 : _b.getTargetElement())) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (!this.visible) {
|
|
92
|
-
// On next change of visibility we load the map
|
|
93
|
-
this.olListenersKeys.push(
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
this.once('change:visible', this.loadMbMap.bind(this)));
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const container = document.createElement('div');
|
|
99
|
-
container.style.position = 'absolute';
|
|
100
|
-
container.style.width = '100%';
|
|
101
|
-
container.style.height = '100%';
|
|
102
|
-
/**
|
|
103
|
-
* A Maplibre map
|
|
104
|
-
* @type {maplibregl.Map}
|
|
105
|
-
*/
|
|
106
|
-
this.mbMap = this.createMap(Object.assign({ style: this.getStyle(), container }, (((_c = this.options) === null || _c === void 0 ? void 0 : _c.mapOptions) || {})));
|
|
107
|
-
this.mbMap.on('sourcedata', () => {
|
|
108
|
-
var _a;
|
|
109
|
-
(_a = this.getSource()) === null || _a === void 0 ? void 0 : _a.refresh(); // Refresh attribution
|
|
110
|
-
});
|
|
111
|
-
this.mbMap.once('load', () => {
|
|
112
|
-
this.loaded = true;
|
|
113
|
-
this.dispatchEvent(new BaseEvent('load'));
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
getStyle() {
|
|
117
|
-
// If the style is a complete style object, use it directly.
|
|
118
|
-
if (this.style &&
|
|
119
|
-
typeof this.style === 'object' &&
|
|
120
|
-
this.style.name &&
|
|
121
|
-
this.style.version) {
|
|
122
|
-
return this.style;
|
|
123
|
-
}
|
|
124
|
-
// If the url set is already a complete style url, use it directly.
|
|
125
|
-
if (this.url.includes('style.json')) {
|
|
126
|
-
return this.url;
|
|
127
|
-
}
|
|
128
|
-
/// Otherwise build the complete style url.
|
|
129
|
-
return getUrlWithParams(`${this.url}/styles/${this.style}/style.json`, {
|
|
130
|
-
[this.apiKeyName]: this.apiKey,
|
|
131
|
-
}).toString();
|
|
132
|
-
}
|
|
133
|
-
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
134
|
-
createMap(options) {
|
|
135
|
-
throw new Error('createMap must be implemented in child class');
|
|
136
|
-
}
|
|
137
|
-
updateMbMap() {
|
|
138
|
-
var _a;
|
|
139
|
-
(_a = this.mbMap) === null || _a === void 0 ? void 0 : _a.setStyle(this.getStyle(), { diff: false });
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
export default MapGlLayer;
|