mobility-toolbox-js 3.0.0-beta.19 → 3.0.0-beta.20
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 +5 -5
- package/api/RealtimeAPI.d.ts +204 -171
- package/api/RealtimeAPI.js +306 -258
- package/api/RoutingAPI.d.ts +4 -4
- package/api/StopsAPI.d.ts +4 -4
- package/api/WebSocketAPI.d.ts +60 -66
- package/api/WebSocketAPI.js +164 -164
- package/api/index.js +1 -1
- package/common/controls/StopFinderControlCommon.d.ts +11 -11
- package/common/controls/StopFinderControlCommon.js +30 -30
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +149 -155
- package/common/mixins/RealtimeLayerMixin.js +395 -395
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/utils/getMapGlCopyrights.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getVehiclePosition.d.ts +2 -2
- package/common/utils/getVehiclePosition.js +7 -7
- package/common/utils/renderTrajectories.js +5 -5
- package/common/utils/sortByDelay.js +5 -5
- package/maplibre/layers/RealtimeLayer.d.ts +59 -64
- package/maplibre/layers/RealtimeLayer.js +8 -8
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/mbt.js +7205 -7031
- package/mbt.js.map +4 -4
- package/mbt.min.js +25 -25
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +81 -87
- package/ol/controls/RoutingControl.js +216 -218
- package/ol/layers/Layer.d.ts +9 -9
- package/ol/layers/MaplibreLayer.d.ts +10 -10
- package/ol/layers/MaplibreLayer.js +9 -3
- package/ol/layers/MaplibreStyleLayer.d.ts +77 -76
- package/ol/layers/MaplibreStyleLayer.js +237 -238
- package/ol/layers/RealtimeLayer.d.ts +92 -96
- package/ol/layers/RealtimeLayer.js +139 -131
- package/ol/mixins/MobilityLayerMixin.d.ts +9 -9
- package/ol/mixins/PropertiesLayerMixin.d.ts +33 -36
- package/ol/mixins/PropertiesLayerMixin.js +73 -72
- package/ol/renderers/MaplibreLayerRenderer.js +3 -3
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
- package/ol/renderers/MaplibreStyleLayerRenderer.js +14 -17
- package/ol/renderers/RealtimeLayerRenderer.d.ts +6 -6
- package/ol/renderers/RealtimeLayerRenderer.js +54 -52
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +10 -16
- package/package.json +6 -5
- package/setupTests.js +3 -4
- package/types/common.d.ts +53 -49
- 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
|
@@ -78,7 +78,8 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
78
78
|
const newOptions = Object.assign(Object.assign({ apiKeyName: 'key', style: 'travic_v2', url: 'https://maps.geops.io' }, (options || {})), { mapLibreOptions: Object.assign({}, (options.mapLibreOptions || {})) });
|
|
79
79
|
if (!newOptions.mapLibreOptions.style &&
|
|
80
80
|
newOptions.apiKey &&
|
|
81
|
-
newOptions.style
|
|
81
|
+
newOptions.style &&
|
|
82
|
+
typeof newOptions.style === 'string') {
|
|
82
83
|
newOptions.mapLibreOptions.style = buildStyleUrl(newOptions.url, newOptions.style, newOptions.apiKey, newOptions.apiKeyName);
|
|
83
84
|
}
|
|
84
85
|
super(newOptions);
|
|
@@ -89,7 +90,6 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
89
90
|
*/
|
|
90
91
|
attachToMap(map) {
|
|
91
92
|
super.attachToMap(map);
|
|
92
|
-
this.updateMaplibreMap();
|
|
93
93
|
const updateMaplibreMapDebounced = debounce(this.updateMaplibreMap.bind(this), 150);
|
|
94
94
|
this.olEventsKeys.push(this.on('propertychange', (evt) => {
|
|
95
95
|
if (/(url|style)/.test(evt.key)) {
|
|
@@ -114,7 +114,13 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
114
114
|
}
|
|
115
115
|
updateMaplibreMap() {
|
|
116
116
|
var _a;
|
|
117
|
-
|
|
117
|
+
try {
|
|
118
|
+
(_a = this.mapLibreMap) === null || _a === void 0 ? void 0 : _a.setStyle(this.getStyle(), { diff: false });
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
// eslint-disable-next-line no-console
|
|
122
|
+
console.error('Error while updating MaplibreMap', e);
|
|
123
|
+
}
|
|
118
124
|
}
|
|
119
125
|
/**
|
|
120
126
|
* Create a copy of the MaplibreLayer.
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
+
import { FeatureState } from 'maplibre-gl';
|
|
1
2
|
import { Feature, Map } from 'ol';
|
|
2
3
|
import { Coordinate } from 'ol/coordinate';
|
|
3
|
-
import { ObjectEvent } from 'ol/Object';
|
|
4
4
|
import { Layer } from 'ol/layer';
|
|
5
|
-
import {
|
|
5
|
+
import { ObjectEvent } from 'ol/Object';
|
|
6
6
|
import { Source } from 'ol/source';
|
|
7
|
-
import { LayerGetFeatureInfoResponse } from '../../types';
|
|
8
7
|
import { FilterFunction } from '../../common/typedefs';
|
|
9
|
-
import
|
|
8
|
+
import { LayerGetFeatureInfoResponse } from '../../types';
|
|
10
9
|
import MaplibreStyleLayerRenderer from '../renderers/MaplibreStyleLayerRenderer';
|
|
11
|
-
|
|
10
|
+
import MaplibreLayer, { MaplibreLayerOptions } from './MaplibreLayer';
|
|
11
|
+
export type MaplibreStyleLayerOptions = {
|
|
12
12
|
beforeId?: string;
|
|
13
|
-
maplibreLayer?: MaplibreLayer;
|
|
14
13
|
layers?: maplibregl.AddLayerObject[];
|
|
15
14
|
layersFilter?: FilterFunction;
|
|
15
|
+
maplibreLayer?: MaplibreLayer;
|
|
16
16
|
queryRenderedLayersFilter?: FilterFunction;
|
|
17
|
-
};
|
|
17
|
+
} & MaplibreLayerOptions;
|
|
18
18
|
declare const MaplibreStyleLayer_base: {
|
|
19
19
|
new (...args: any[]): {
|
|
20
|
-
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions;
|
|
21
20
|
olEventsKeys: import("ol/events").EventsKey[];
|
|
21
|
+
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions;
|
|
22
|
+
attachToMap(map: Map): void;
|
|
23
|
+
detachFromMap(): void;
|
|
24
|
+
flat(): any[];
|
|
25
|
+
onChildrenChange(oldValue: Layer[]): void;
|
|
26
|
+
setMapInternal: ((map: Map) => void) & ((map: import("ol/Map" /**
|
|
27
|
+
* Set if features are hovered or not.
|
|
28
|
+
* @param {Array<ol/Feature~Feature>} features
|
|
29
|
+
* @param {boolean} state Is the feature hovered
|
|
30
|
+
* @private
|
|
31
|
+
*/).default | null) => void);
|
|
22
32
|
children: Layer<Source, import("ol/renderer/Layer").default<any>>[];
|
|
23
33
|
get copyrights(): string;
|
|
24
34
|
set copyrights(newCopyrights: string | string[]);
|
|
@@ -31,17 +41,10 @@ declare const MaplibreStyleLayer_base: {
|
|
|
31
41
|
olLayer: Layer;
|
|
32
42
|
parent: Layer<Source, import("ol/renderer/Layer").default<any>>;
|
|
33
43
|
visible: boolean;
|
|
34
|
-
setMapInternal: ((map: Map) => void) & ((map: import("ol/Map").default | null) => void);
|
|
35
|
-
onChildrenChange(oldValue: Layer[]): void;
|
|
36
|
-
attachToMap(map: Map): void;
|
|
37
|
-
detachFromMap(): void;
|
|
38
|
-
flat(): any[];
|
|
39
|
-
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
40
|
-
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
41
44
|
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
42
|
-
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
43
45
|
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
44
46
|
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
47
|
+
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
45
48
|
getSource: () => Source | null;
|
|
46
49
|
getRenderSource: () => Source | null;
|
|
47
50
|
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
|
|
@@ -99,9 +102,11 @@ declare const MaplibreStyleLayer_base: {
|
|
|
99
102
|
unset: (key: string, silent?: boolean | undefined) => void;
|
|
100
103
|
changed: () => void;
|
|
101
104
|
getRevision: () => number;
|
|
105
|
+
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
102
106
|
dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
|
|
103
107
|
getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
|
|
104
108
|
hasListener: (type?: string | undefined) => boolean;
|
|
109
|
+
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
105
110
|
dispose: () => void;
|
|
106
111
|
};
|
|
107
112
|
} & typeof Layer;
|
|
@@ -126,39 +131,6 @@ declare const MaplibreStyleLayer_base: {
|
|
|
126
131
|
declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
127
132
|
highlightedFeatures: Feature[];
|
|
128
133
|
selectedFeatures: Feature[];
|
|
129
|
-
get beforeId(): string;
|
|
130
|
-
set beforeId(newValue: string[]);
|
|
131
|
-
get layers(): maplibregl.AddLayerObject[];
|
|
132
|
-
set layers(newValue: maplibregl.AddLayerObject[]);
|
|
133
|
-
get layersFilter(): (layer: maplibregl.LayerSpecification) => boolean;
|
|
134
|
-
set layersFilter(newValue: (layer: maplibregl.LayerSpecification) => boolean);
|
|
135
|
-
get mapboxLayer(): MaplibreLayer | undefined;
|
|
136
|
-
get maplibreLayer(): MaplibreLayer;
|
|
137
|
-
set maplibreLayer(newValue: MaplibreLayer);
|
|
138
|
-
get queryRenderedLayersFilter(): (layer: maplibregl.LayerSpecification) => boolean;
|
|
139
|
-
set queryRenderedLayersFilter(newValue: (layer: maplibregl.LayerSpecification) => boolean);
|
|
140
|
-
get sources(): {
|
|
141
|
-
[key: string]: maplibregl.SourceSpecification;
|
|
142
|
-
};
|
|
143
|
-
set sources(newValue: {
|
|
144
|
-
[key: string]: maplibregl.SourceSpecification;
|
|
145
|
-
});
|
|
146
|
-
/**
|
|
147
|
-
* @deprecated
|
|
148
|
-
*/
|
|
149
|
-
get styleLayer(): maplibregl.AddLayerObject;
|
|
150
|
-
/**
|
|
151
|
-
* @deprecated
|
|
152
|
-
*/
|
|
153
|
-
set styleLayer(newValue: maplibregl.AddLayerObject);
|
|
154
|
-
/**
|
|
155
|
-
* @deprecated
|
|
156
|
-
*/
|
|
157
|
-
get styleLayers(): maplibregl.AddLayerObject[];
|
|
158
|
-
/**
|
|
159
|
-
* @deprecated
|
|
160
|
-
*/
|
|
161
|
-
set styleLayers(newValue: maplibregl.AddLayerObject[]);
|
|
162
134
|
/**
|
|
163
135
|
* Constructor.
|
|
164
136
|
*
|
|
@@ -170,31 +142,56 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
170
142
|
* @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
|
|
171
143
|
*/
|
|
172
144
|
constructor(options?: MaplibreStyleLayerOptions);
|
|
173
|
-
|
|
145
|
+
/** @private */
|
|
146
|
+
addLayers(): void;
|
|
147
|
+
/** @private */
|
|
148
|
+
addSources(): void;
|
|
149
|
+
applyLayoutVisibility(evt?: ObjectEvent): void;
|
|
174
150
|
/**
|
|
175
151
|
* Initialize the layer.
|
|
176
152
|
* @param {ol/Map~Map} map the Maplibre map.
|
|
177
153
|
* @override
|
|
178
154
|
*/
|
|
179
155
|
attachToMap(map: Map): void;
|
|
156
|
+
/**
|
|
157
|
+
* Create a copy of the MapboxStyleLayer.
|
|
158
|
+
* @param {Object} newOptions Options to override.
|
|
159
|
+
* @return {MapboxStyleLayer} A MapboxStyleLayer.
|
|
160
|
+
*/
|
|
161
|
+
clone(newOptions: MaplibreStyleLayerOptions): MaplibreStyleLayer;
|
|
162
|
+
createRenderer(): MaplibreStyleLayerRenderer;
|
|
180
163
|
/**
|
|
181
164
|
* Terminate the layer.
|
|
182
165
|
* @override
|
|
183
166
|
*/
|
|
184
167
|
detachFromMap(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Request feature information for a given coordinate.
|
|
170
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
171
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
172
|
+
*/
|
|
173
|
+
getFeatureInfoAtCoordinate(coordinate: Coordinate): Promise<LayerGetFeatureInfoResponse>;
|
|
174
|
+
/**
|
|
175
|
+
* Highlight a list of features.
|
|
176
|
+
* @param {Array<ol/Feature~Feature>} [features=[]] Features to highlight.
|
|
177
|
+
* @private
|
|
178
|
+
*/
|
|
179
|
+
highlight(features?: Feature[]): void;
|
|
180
|
+
/**
|
|
181
|
+
* On Maplibre map load callback function. Add style layers and dynaimc filters.
|
|
182
|
+
* @private
|
|
183
|
+
*/
|
|
184
|
+
onLoad(): void;
|
|
185
185
|
/** @private */
|
|
186
|
-
|
|
186
|
+
removeLayers(): void;
|
|
187
187
|
/** @private */
|
|
188
188
|
removeSources(): void;
|
|
189
|
-
/** @private */
|
|
190
|
-
addLayers(): void;
|
|
191
|
-
/** @private */
|
|
192
|
-
removeLayers(): void;
|
|
193
189
|
/**
|
|
194
|
-
*
|
|
190
|
+
* Select a list of features.
|
|
191
|
+
* @param {Array<ol/Feature~Feature>} [features=[]] Features to select.
|
|
195
192
|
* @private
|
|
196
193
|
*/
|
|
197
|
-
|
|
194
|
+
select(features?: Feature[]): void;
|
|
198
195
|
/**
|
|
199
196
|
* Set the feature state of the features.
|
|
200
197
|
* @param {Array<ol/Feature~Feature>} features
|
|
@@ -202,12 +199,6 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
202
199
|
* @public
|
|
203
200
|
*/
|
|
204
201
|
setFeatureState(features: Feature[], state: FeatureState): void;
|
|
205
|
-
/**
|
|
206
|
-
* Request feature information for a given coordinate.
|
|
207
|
-
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
208
|
-
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
209
|
-
*/
|
|
210
|
-
getFeatureInfoAtCoordinate(coordinate: Coordinate): Promise<LayerGetFeatureInfoResponse>;
|
|
211
202
|
/**
|
|
212
203
|
* Set if features are hovered or not.
|
|
213
204
|
* @param {Array<ol/Feature~Feature>} features
|
|
@@ -215,27 +206,37 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
215
206
|
* @private
|
|
216
207
|
*/
|
|
217
208
|
setHoverState(features: Feature[], state: boolean): void;
|
|
209
|
+
get beforeId(): string;
|
|
210
|
+
set beforeId(newValue: string[]);
|
|
211
|
+
get layers(): maplibregl.AddLayerObject[];
|
|
212
|
+
set layers(newValue: maplibregl.AddLayerObject[]);
|
|
213
|
+
get layersFilter(): (layer: maplibregl.LayerSpecification) => boolean;
|
|
214
|
+
set layersFilter(newValue: (layer: maplibregl.LayerSpecification) => boolean);
|
|
215
|
+
get mapboxLayer(): MaplibreLayer | undefined;
|
|
216
|
+
get maplibreLayer(): MaplibreLayer;
|
|
217
|
+
set maplibreLayer(newValue: MaplibreLayer);
|
|
218
|
+
get queryRenderedLayersFilter(): (layer: maplibregl.LayerSpecification) => boolean;
|
|
219
|
+
set queryRenderedLayersFilter(newValue: (layer: maplibregl.LayerSpecification) => boolean);
|
|
220
|
+
get sources(): Record<string, maplibregl.SourceSpecification>;
|
|
221
|
+
set sources(newValue: Record<string, maplibregl.SourceSpecification>);
|
|
218
222
|
/**
|
|
219
|
-
*
|
|
220
|
-
* @param {Array<ol/Feature~Feature>} [features=[]] Features to select.
|
|
221
|
-
* @private
|
|
223
|
+
* @deprecated
|
|
222
224
|
*/
|
|
223
|
-
|
|
225
|
+
get styleLayer(): maplibregl.AddLayerObject;
|
|
224
226
|
/**
|
|
225
|
-
*
|
|
226
|
-
* @param {Array<ol/Feature~Feature>} [features=[]] Features to highlight.
|
|
227
|
-
* @private
|
|
227
|
+
* @deprecated
|
|
228
228
|
*/
|
|
229
|
-
|
|
229
|
+
set styleLayer(newValue: maplibregl.AddLayerObject);
|
|
230
230
|
/**
|
|
231
231
|
* Apply visibility to style layers that fits the styleLayersFilter function.
|
|
232
232
|
*/
|
|
233
|
-
applyLayoutVisibility(evt?: ObjectEvent): void;
|
|
234
233
|
/**
|
|
235
|
-
*
|
|
236
|
-
* @param {Object} newOptions Options to override.
|
|
237
|
-
* @return {MapboxStyleLayer} A MapboxStyleLayer.
|
|
234
|
+
* @deprecated
|
|
238
235
|
*/
|
|
239
|
-
|
|
236
|
+
get styleLayers(): maplibregl.AddLayerObject[];
|
|
237
|
+
/**
|
|
238
|
+
* @deprecated
|
|
239
|
+
*/
|
|
240
|
+
set styleLayers(newValue: maplibregl.AddLayerObject[]);
|
|
240
241
|
}
|
|
241
242
|
export default MaplibreStyleLayer;
|