mobility-toolbox-js 3.0.0-beta.31 → 3.0.0-beta.33
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.js +1 -3
- package/api/RealtimeAPI.d.ts +3 -3
- package/api/WebSocketAPI.js +0 -1
- package/common/styles/realtimeDefaultStyle.js +0 -5
- package/common/styles/realtimeHeadingStyle.js +0 -5
- package/common/styles/realtimeSimpleStyle.d.ts +0 -1
- package/common/styles/realtimeSimpleStyle.js +0 -1
- package/common/utils/RealtimeEngine.d.ts +224 -0
- package/common/utils/RealtimeEngine.js +565 -0
- package/common/utils/getLayersAsFlatArray.d.ts +0 -1
- package/common/utils/getLayersAsFlatArray.js +0 -1
- package/common/utils/realtimeConfig.d.ts +1 -1
- package/common/utils/realtimeConfig.js +0 -1
- package/maplibre/layers/RealtimeLayer.d.ts +50 -109
- package/maplibre/layers/RealtimeLayer.js +108 -111
- package/mbt.js +5122 -13362
- package/mbt.js.map +4 -4
- package/mbt.min.js +67 -70
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +5 -4
- package/ol/controls/RoutingControl.js +2 -29
- package/ol/controls/StopFinderControl.d.ts +2 -5
- package/ol/controls/StopFinderControl.js +0 -3
- package/ol/layers/MaplibreLayer.d.ts +29 -18
- package/ol/layers/MaplibreLayer.js +18 -10
- package/ol/layers/MaplibreStyleLayer.d.ts +39 -27
- package/ol/layers/MaplibreStyleLayer.js +33 -28
- package/ol/layers/RealtimeLayer.d.ts +72 -124
- package/ol/layers/RealtimeLayer.js +130 -168
- package/ol/mixins/PropertiesLayerMixin.d.ts +4 -6
- package/ol/mixins/PropertiesLayerMixin.js +0 -2
- package/ol/renderers/RealtimeLayerRenderer.js +6 -31
- package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
- package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
- package/ol/styles/fullTrajectoryStyle.js +5 -7
- package/ol/styles/routingStyle.d.ts +0 -1
- package/ol/styles/routingStyle.js +2 -7
- package/package.json +31 -30
- package/types/common.d.ts +2 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +0 -267
- package/common/mixins/RealtimeLayerMixin.js +0 -751
|
@@ -6,12 +6,13 @@ import { Geometry, LineString, Point } from 'ol/geom';
|
|
|
6
6
|
import { Modify } from 'ol/interaction';
|
|
7
7
|
import { ModifyEvent } from 'ol/interaction/Modify';
|
|
8
8
|
import VectorLayer from 'ol/layer/Vector';
|
|
9
|
+
import VectorSource from 'ol/source/Vector';
|
|
9
10
|
import { RoutingAPI } from '../../api';
|
|
10
11
|
import type { Map, MapBrowserEvent } from 'ol';
|
|
11
12
|
import type { Coordinate } from 'ol/coordinate';
|
|
12
13
|
import type { StyleLike } from 'ol/style/Style';
|
|
13
14
|
import type { RoutingGraph, RoutingMot, RoutingParameters, RoutingViaPoint } from '../../types';
|
|
14
|
-
export type RoutingControlOptions =
|
|
15
|
+
export type RoutingControlOptions = {
|
|
15
16
|
active?: boolean;
|
|
16
17
|
apiKey?: string;
|
|
17
18
|
graphs?: RoutingGraph[];
|
|
@@ -19,13 +20,13 @@ export type RoutingControlOptions = Options & {
|
|
|
19
20
|
mot?: string;
|
|
20
21
|
onRouteError?: () => void;
|
|
21
22
|
routingApiParams?: RoutingParameters;
|
|
22
|
-
routingLayer?: VectorLayer<
|
|
23
|
+
routingLayer?: VectorLayer<VectorSource>;
|
|
23
24
|
snapToClosestStation?: boolean;
|
|
24
25
|
stopsApiKey?: string;
|
|
25
26
|
stopsApiUrl?: string;
|
|
26
27
|
style?: StyleLike;
|
|
27
28
|
useRawViaPoints?: boolean;
|
|
28
|
-
};
|
|
29
|
+
} & Options;
|
|
29
30
|
export type AbotControllersByGraph = Record<string, AbortController>;
|
|
30
31
|
/**
|
|
31
32
|
* This OpenLayers control allows the user to add and modifiy via points to a map and request a route from the [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
@@ -77,7 +78,7 @@ declare class RoutingControl extends Control {
|
|
|
77
78
|
onMapClickKey?: EventsKey;
|
|
78
79
|
onRouteError: (error?: Error, control?: RoutingControl) => void;
|
|
79
80
|
routingApiParams?: RoutingParameters;
|
|
80
|
-
routingLayer?: VectorLayer<
|
|
81
|
+
routingLayer?: VectorLayer<VectorSource>;
|
|
81
82
|
segments: Feature<LineString>[];
|
|
82
83
|
snapToClosestStation: boolean;
|
|
83
84
|
stopsApiKey?: string;
|
|
@@ -18,22 +18,17 @@ import { RoutingAPI } from '../../api';
|
|
|
18
18
|
// @47.37811,8.53935 a station at position 47.37811, 8.53935
|
|
19
19
|
// @47.37811,8.53935$4 track 4 in a station at position 47.37811, 8.53935
|
|
20
20
|
// zürich hb@47.37811,8.53935$8 track 8 in station "Zürich HB" at position 47.37811, 8.53935
|
|
21
|
-
/** @private */
|
|
22
21
|
const REGEX_VIA_POINT = /^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/;
|
|
23
22
|
// Examples for a single hop:
|
|
24
23
|
//
|
|
25
24
|
// 47.37811,8.53935 a position 47.37811, 8.53935
|
|
26
|
-
/** @private */
|
|
27
25
|
const REGEX_VIA_POINT_COORD = /^([\d.]+),([\d.]+)$/;
|
|
28
26
|
// Examples for a single hop:
|
|
29
27
|
//
|
|
30
28
|
// !8596126 a station with id 8596126
|
|
31
29
|
// !8596126$4 a station with id 8596126
|
|
32
|
-
/** @private */
|
|
33
30
|
const REGEX_VIA_POINT_STATION_ID = /^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/;
|
|
34
|
-
/** @private */
|
|
35
31
|
const STOP_FETCH_ABORT_CONTROLLER_KEY = 'stop-fetch';
|
|
36
|
-
/** @private */
|
|
37
32
|
const getFlatCoordinatesFromSegments = (segmentArray) => {
|
|
38
33
|
const coords = [];
|
|
39
34
|
segmentArray.forEach((seg) => {
|
|
@@ -95,36 +90,23 @@ class RoutingControl extends Control {
|
|
|
95
90
|
}
|
|
96
91
|
/** True if the control is requesting the backend. */
|
|
97
92
|
this.loading = false;
|
|
98
|
-
/** @private */
|
|
99
93
|
this.active = options.active || true;
|
|
100
|
-
/** @private */
|
|
101
94
|
this.graphs = options.graphs || [['osm', 0, 99]];
|
|
102
|
-
/** @private */
|
|
103
95
|
this.mot = options.mot || 'bus';
|
|
104
|
-
/** @private */
|
|
105
96
|
this.modify = options.modify !== false;
|
|
106
|
-
/** @private */
|
|
107
97
|
this.routingApiParams = options.routingApiParams;
|
|
108
|
-
/** @private */
|
|
109
98
|
this.useRawViaPoints = options.useRawViaPoints || false;
|
|
110
|
-
/** @private */
|
|
111
99
|
this.snapToClosestStation = options.snapToClosestStation || false;
|
|
112
|
-
/** @private */
|
|
113
100
|
this.apiKey = options.apiKey;
|
|
114
|
-
/** @private */
|
|
115
101
|
this.stopsApiKey = options.stopsApiKey || this.apiKey;
|
|
116
|
-
/** @private */
|
|
117
102
|
this.stopsApiUrl = options.stopsApiUrl || 'https://api.geops.io/stops/v1/';
|
|
118
|
-
/** @private */
|
|
119
103
|
this.api = new RoutingAPI(Object.assign({}, options));
|
|
120
|
-
/** @private */
|
|
121
104
|
this.routingLayer =
|
|
122
105
|
options.routingLayer ||
|
|
123
106
|
new VectorLayer({
|
|
124
107
|
source: new VectorSource(),
|
|
125
108
|
style: options.style,
|
|
126
109
|
});
|
|
127
|
-
/** @private */
|
|
128
110
|
this.onRouteError =
|
|
129
111
|
options.onRouteError ||
|
|
130
112
|
((error) => {
|
|
@@ -133,13 +115,9 @@ class RoutingControl extends Control {
|
|
|
133
115
|
// eslint-disable-next-line no-console
|
|
134
116
|
console.error(error);
|
|
135
117
|
});
|
|
136
|
-
/** @private */
|
|
137
118
|
this.onMapClick = this.onMapClick.bind(this);
|
|
138
|
-
/** @private */
|
|
139
119
|
this.onModifyEnd = this.onModifyEnd.bind(this);
|
|
140
|
-
/** @private */
|
|
141
120
|
this.onModifyStart = this.onModifyStart.bind(this);
|
|
142
|
-
/** @private */
|
|
143
121
|
this.createModifyInteraction();
|
|
144
122
|
this.on('propertychange', (evt) => {
|
|
145
123
|
if (evt.key === 'active') {
|
|
@@ -188,11 +166,9 @@ class RoutingControl extends Control {
|
|
|
188
166
|
var _a;
|
|
189
167
|
const map = this.getMap();
|
|
190
168
|
if (map) {
|
|
191
|
-
/** @private */
|
|
192
169
|
this.format = new GeoJSON({
|
|
193
170
|
featureProjection: map.getView().getProjection(),
|
|
194
171
|
});
|
|
195
|
-
/** @private */
|
|
196
172
|
this.graphsResolutions = RoutingControl.getGraphsResolutions(this.graphs, map);
|
|
197
173
|
// Clean the modifyInteraction if present
|
|
198
174
|
if (this.modifyInteraction) {
|
|
@@ -217,7 +193,6 @@ class RoutingControl extends Control {
|
|
|
217
193
|
return;
|
|
218
194
|
}
|
|
219
195
|
this.removeListeners();
|
|
220
|
-
/** @private */
|
|
221
196
|
this.onMapClickKey = (_a = this.getMap()) === null || _a === void 0 ? void 0 : _a.on('singleclick', this.onMapClick);
|
|
222
197
|
}
|
|
223
198
|
/**
|
|
@@ -243,7 +218,6 @@ class RoutingControl extends Control {
|
|
|
243
218
|
* @private
|
|
244
219
|
*/
|
|
245
220
|
createDefaultElement() {
|
|
246
|
-
/** @private */
|
|
247
221
|
this.element = document.createElement('button');
|
|
248
222
|
this.element.id = 'ol-toggle-routing';
|
|
249
223
|
this.element.innerHTML = 'Toggle Route Control';
|
|
@@ -269,9 +243,9 @@ class RoutingControl extends Control {
|
|
|
269
243
|
// hitDetection: this.routingLayer, // Create a bug, the first point is always selected even if the mous eis far away
|
|
270
244
|
deleteCondition: (e) => {
|
|
271
245
|
var _a;
|
|
272
|
-
const feats = (_a = e.target) === null || _a === void 0 ? void 0 : _a.getFeaturesAtPixel(e.pixel, {
|
|
246
|
+
const feats = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.getFeaturesAtPixel(e.pixel, {
|
|
273
247
|
hitTolerance: 5,
|
|
274
|
-
} || []
|
|
248
|
+
})) || [];
|
|
275
249
|
const viaPoint = feats.find((feat) => { var _a; return ((_a = feat.getGeometry()) === null || _a === void 0 ? void 0 : _a.getType()) === 'Point' && feat.get('index'); });
|
|
276
250
|
if (click(e) && viaPoint) {
|
|
277
251
|
// Remove node & viaPoint if an existing viaPoint was clicked
|
|
@@ -585,7 +559,6 @@ class RoutingControl extends Control {
|
|
|
585
559
|
.filter((feat) => { var _a; return ((_a = feat.getGeometry()) === null || _a === void 0 ? void 0 : _a.getType()) === 'Point'; }) ||
|
|
586
560
|
[])[0];
|
|
587
561
|
// Write object with modify info
|
|
588
|
-
/** @private */
|
|
589
562
|
this.initialRouteDrag = {
|
|
590
563
|
oldRoute: route && route.clone(),
|
|
591
564
|
segmentIndex,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Feature } from 'geojson';
|
|
2
2
|
import Control, { Options } from 'ol/control/Control';
|
|
3
3
|
import StopFinderControlCommon from '../../common/controls/StopFinderControlCommon';
|
|
4
|
-
export type StopFinderControlOptions =
|
|
4
|
+
export type StopFinderControlOptions = {
|
|
5
5
|
className?: string;
|
|
6
|
-
};
|
|
6
|
+
} & Options & StopFinderControlCommon;
|
|
7
7
|
/**
|
|
8
8
|
* This OpenLayers control allows to search stations from the [geOps Stops API](https://developer.geops.io/apis/stops/).
|
|
9
9
|
*
|
|
@@ -28,9 +28,6 @@ export type StopFinderControlOptions = Options & StopFinderControlCommon & {
|
|
|
28
28
|
declare class StopFinderControl extends Control {
|
|
29
29
|
controller: StopFinderControlCommon;
|
|
30
30
|
constructor(options: StopFinderControlOptions);
|
|
31
|
-
/**
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
31
|
onSuggestionClick(suggestion: Feature): void;
|
|
35
32
|
search(q: string, abortController: AbortController): Promise<void>;
|
|
36
33
|
}
|
|
@@ -31,9 +31,6 @@ class StopFinderControl extends Control {
|
|
|
31
31
|
super(opt);
|
|
32
32
|
this.controller = new StopFinderControlCommon(Object.assign({ onSuggestionClick: this.onSuggestionClick.bind(this) }, opt));
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
35
|
-
* @private
|
|
36
|
-
*/
|
|
37
34
|
onSuggestionClick(suggestion) {
|
|
38
35
|
var _a;
|
|
39
36
|
const coord = fromLonLat(suggestion.geometry.coordinates);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
|
|
2
2
|
import OlMap from 'ol/Map';
|
|
3
3
|
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
4
|
+
import type { MapLibreOptions } from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
|
|
5
|
+
import type { QueryRenderedFeaturesOptions } from 'maplibre-gl';
|
|
6
|
+
import type { Options as LayerOptions } from 'ol/layer/Layer';
|
|
7
|
+
export type MaplibreLayerOptions = {
|
|
6
8
|
apiKey?: string;
|
|
7
9
|
apiKeyName?: string;
|
|
8
10
|
mapLibreOptions?: MapLibreOptions;
|
|
11
|
+
queryRenderedFeaturesOptions?: QueryRenderedFeaturesOptions | undefined;
|
|
9
12
|
style?: maplibregl.StyleSpecification | null | string;
|
|
10
13
|
url?: string;
|
|
11
|
-
};
|
|
14
|
+
} & LayerOptions & MobilityLayerOptions;
|
|
12
15
|
declare const MaplibreLayer_base: {
|
|
13
16
|
new (...args: any[]): {
|
|
14
17
|
olEventsKeys: import("ol/events").EventsKey[];
|
|
@@ -16,9 +19,9 @@ declare const MaplibreLayer_base: {
|
|
|
16
19
|
attachToMap(map: OlMap): void;
|
|
17
20
|
detachFromMap(): void;
|
|
18
21
|
flat(): any[];
|
|
19
|
-
onChildrenChange(oldValue: import("ol/layer").
|
|
22
|
+
onChildrenChange(oldValue: import("ol/layer/Layer").default[]): void;
|
|
20
23
|
setMapInternal: ((map: OlMap) => void) & ((map: import("ol/Map").default | null) => void);
|
|
21
|
-
children: import("ol/layer").
|
|
24
|
+
children: import("ol/layer/Layer").default<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
22
25
|
get copyrights(): string;
|
|
23
26
|
set copyrights(newCopyrights: string | string[]);
|
|
24
27
|
disabled: boolean;
|
|
@@ -27,8 +30,8 @@ declare const MaplibreLayer_base: {
|
|
|
27
30
|
readonly key: string;
|
|
28
31
|
readonly map: OlMap;
|
|
29
32
|
readonly name: string;
|
|
30
|
-
olLayer: import("ol/layer").
|
|
31
|
-
parent: import("ol/layer").
|
|
33
|
+
olLayer: import("ol/layer/Layer").default;
|
|
34
|
+
parent: import("ol/layer/Layer").default<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
32
35
|
visible: boolean;
|
|
33
36
|
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
34
37
|
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
@@ -52,7 +55,7 @@ declare const MaplibreLayer_base: {
|
|
|
52
55
|
getBackground: () => import("ol/layer/Base").BackgroundColor | false;
|
|
53
56
|
getClassName: () => string;
|
|
54
57
|
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
55
|
-
getLayersArray: (array?: import("ol/layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer").default>;
|
|
58
|
+
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
|
|
56
59
|
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
|
|
57
60
|
getExtent: () => import("ol/extent").Extent | undefined;
|
|
58
61
|
getMaxResolution: () => number;
|
|
@@ -121,31 +124,33 @@ declare const MaplibreLayer_base: {
|
|
|
121
124
|
* });
|
|
122
125
|
*
|
|
123
126
|
* @classproperty {maplibregl.Map} mapLibreMap - The Maplibre map object. Readonly.
|
|
124
|
-
* @classproperty {string} style - geOps Maps
|
|
125
|
-
* @extends {
|
|
127
|
+
* @classproperty {string} style - The [geOps Maps API](https://developer.geops.io/apis/maps) style.
|
|
128
|
+
* @extends {MapLibreLayer}
|
|
126
129
|
* @public
|
|
127
130
|
*/
|
|
128
131
|
declare class MaplibreLayer extends MaplibreLayer_base {
|
|
129
132
|
/**
|
|
130
133
|
* Constructor.
|
|
131
134
|
*
|
|
132
|
-
* @param {
|
|
133
|
-
* @param {string} options.apiKey
|
|
134
|
-
* @param {string} [options.apiKeyName="key"] The geOps Maps API key name.
|
|
135
|
-
* @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }]
|
|
136
|
-
* @param {string} [options.style="travic_v2"] The geOps Maps API style.
|
|
137
|
-
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
135
|
+
* @param {Object} options
|
|
136
|
+
* @param {string} options.apiKey Accesss key for [geOps APIs](https://developer.geops.io/).
|
|
137
|
+
* @param {string} [options.apiKeyName="key"] The [geOps Maps API](https://developer.geops.io/apis/maps) key name.
|
|
138
|
+
* @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }] MapLibre map options.
|
|
139
|
+
* @param {string} [options.style="travic_v2"] The [geOps Maps API](https://developer.geops.io/apis/maps) style.
|
|
140
|
+
* @param {string} [options.url="https://maps.geops.io"] The [geOps Maps API](https://developer.geops.io/apis/maps) url.
|
|
138
141
|
*/
|
|
139
142
|
constructor(options: MaplibreLayerOptions);
|
|
140
143
|
/**
|
|
141
144
|
* Initialize the layer and listen to feature clicks.
|
|
142
|
-
* @param {ol/Map~Map} map
|
|
145
|
+
* @param {ol/Map~Map} map An OpenLayers map.
|
|
143
146
|
*/
|
|
144
147
|
attachToMap(map: OlMap): void;
|
|
145
148
|
/**
|
|
146
149
|
* Create a copy of the MaplibreLayer.
|
|
147
|
-
*
|
|
150
|
+
*
|
|
151
|
+
* @param {Object} newOptions Options to override. See constructor.
|
|
148
152
|
* @return {MaplibreLayer} A MaplibreLayer layer
|
|
153
|
+
* @public
|
|
149
154
|
*/
|
|
150
155
|
clone(newOptions: MaplibreLayerOptions): MaplibreLayer;
|
|
151
156
|
getStyle(): string;
|
|
@@ -154,7 +159,13 @@ declare class MaplibreLayer extends MaplibreLayer_base {
|
|
|
154
159
|
get apiKey(): string;
|
|
155
160
|
set apiKeyName(newValue: string);
|
|
156
161
|
get apiKeyName(): string;
|
|
162
|
+
/**
|
|
163
|
+
* @deprecated Use layer.mapLibreMap.
|
|
164
|
+
*/
|
|
157
165
|
get maplibreMap(): maplibregl.Map | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Use layer.mapLibreMap.
|
|
168
|
+
*/
|
|
158
169
|
get mbMap(): maplibregl.Map | undefined;
|
|
159
170
|
get style(): string;
|
|
160
171
|
set style(newValue: string);
|
|
@@ -37,20 +37,20 @@ if (typeof window !== 'undefined' &&
|
|
|
37
37
|
* });
|
|
38
38
|
*
|
|
39
39
|
* @classproperty {maplibregl.Map} mapLibreMap - The Maplibre map object. Readonly.
|
|
40
|
-
* @classproperty {string} style - geOps Maps
|
|
41
|
-
* @extends {
|
|
40
|
+
* @classproperty {string} style - The [geOps Maps API](https://developer.geops.io/apis/maps) style.
|
|
41
|
+
* @extends {MapLibreLayer}
|
|
42
42
|
* @public
|
|
43
43
|
*/
|
|
44
44
|
class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
45
45
|
/**
|
|
46
46
|
* Constructor.
|
|
47
47
|
*
|
|
48
|
-
* @param {
|
|
49
|
-
* @param {string} options.apiKey
|
|
50
|
-
* @param {string} [options.apiKeyName="key"] The geOps Maps API key name.
|
|
51
|
-
* @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }]
|
|
52
|
-
* @param {string} [options.style="travic_v2"] The geOps Maps API style.
|
|
53
|
-
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
48
|
+
* @param {Object} options
|
|
49
|
+
* @param {string} options.apiKey Accesss key for [geOps APIs](https://developer.geops.io/).
|
|
50
|
+
* @param {string} [options.apiKeyName="key"] The [geOps Maps API](https://developer.geops.io/apis/maps) key name.
|
|
51
|
+
* @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }] MapLibre map options.
|
|
52
|
+
* @param {string} [options.style="travic_v2"] The [geOps Maps API](https://developer.geops.io/apis/maps) style.
|
|
53
|
+
* @param {string} [options.url="https://maps.geops.io"] The [geOps Maps API](https://developer.geops.io/apis/maps) url.
|
|
54
54
|
*/
|
|
55
55
|
constructor(options) {
|
|
56
56
|
var _a;
|
|
@@ -69,7 +69,7 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Initialize the layer and listen to feature clicks.
|
|
72
|
-
* @param {ol/Map~Map} map
|
|
72
|
+
* @param {ol/Map~Map} map An OpenLayers map.
|
|
73
73
|
*/
|
|
74
74
|
attachToMap(map) {
|
|
75
75
|
super.attachToMap(map);
|
|
@@ -91,8 +91,10 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
91
91
|
// }
|
|
92
92
|
/**
|
|
93
93
|
* Create a copy of the MaplibreLayer.
|
|
94
|
-
*
|
|
94
|
+
*
|
|
95
|
+
* @param {Object} newOptions Options to override. See constructor.
|
|
95
96
|
* @return {MaplibreLayer} A MaplibreLayer layer
|
|
97
|
+
* @public
|
|
96
98
|
*/
|
|
97
99
|
clone(newOptions) {
|
|
98
100
|
return new MaplibreLayer(Object.assign(Object.assign({}, (this.options || {})), (newOptions || {})));
|
|
@@ -134,10 +136,16 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
134
136
|
get apiKeyName() {
|
|
135
137
|
return this.get('apiKeyName');
|
|
136
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated Use layer.mapLibreMap.
|
|
141
|
+
*/
|
|
137
142
|
get maplibreMap() {
|
|
138
143
|
deprecated('MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap.');
|
|
139
144
|
return this.mapLibreMap;
|
|
140
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* @deprecated Use layer.mapLibreMap.
|
|
148
|
+
*/
|
|
141
149
|
get mbMap() {
|
|
142
150
|
deprecated('MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap.');
|
|
143
151
|
return this.maplibreMap;
|
|
@@ -8,13 +8,13 @@ import { FilterFunction } from '../../common/typedefs';
|
|
|
8
8
|
import { LayerGetFeatureInfoResponse } from '../../types';
|
|
9
9
|
import MaplibreStyleLayerRenderer from '../renderers/MaplibreStyleLayerRenderer';
|
|
10
10
|
import MaplibreLayer, { MaplibreLayerOptions } from './MaplibreLayer';
|
|
11
|
-
export type MaplibreStyleLayerOptions =
|
|
11
|
+
export type MaplibreStyleLayerOptions = {
|
|
12
12
|
beforeId?: string;
|
|
13
13
|
layers?: maplibregl.AddLayerObject[];
|
|
14
14
|
layersFilter?: FilterFunction;
|
|
15
15
|
maplibreLayer?: MaplibreLayer;
|
|
16
16
|
queryRenderedLayersFilter?: FilterFunction;
|
|
17
|
-
};
|
|
17
|
+
} & MaplibreLayerOptions;
|
|
18
18
|
declare const MaplibreStyleLayer_base: {
|
|
19
19
|
new (...args: any[]): {
|
|
20
20
|
olEventsKeys: import("ol/events").EventsKey[];
|
|
@@ -36,7 +36,12 @@ declare const MaplibreStyleLayer_base: {
|
|
|
36
36
|
olLayer: Layer;
|
|
37
37
|
parent: Layer<Source, import("ol/renderer/Layer").default<any>>;
|
|
38
38
|
visible: boolean;
|
|
39
|
-
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events"
|
|
39
|
+
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events" /**
|
|
40
|
+
* Request feature information for a given coordinate.
|
|
41
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
42
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
43
|
+
* @deprecated Use getFeatureInfoAtCoordinate([layer], coordinate) from mobility-toolbox-ol package instead.
|
|
44
|
+
*/).EventsKey>;
|
|
40
45
|
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
41
46
|
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
42
47
|
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
@@ -106,22 +111,25 @@ declare const MaplibreStyleLayer_base: {
|
|
|
106
111
|
};
|
|
107
112
|
} & typeof Layer;
|
|
108
113
|
/**
|
|
109
|
-
* Layer
|
|
114
|
+
* Layer that helps show/hide a specific subset of style layers of a [MaplibreLayer](./MaplibreLayer.js~MaplibreLayer.html).
|
|
110
115
|
*
|
|
111
116
|
* @example
|
|
112
|
-
* import {
|
|
117
|
+
* import { MaplibreLayer, MaplibreStyleLayer } from 'mobility-toolbox-js/ol';
|
|
113
118
|
*
|
|
114
|
-
* const maplibreLayer = new
|
|
115
|
-
*
|
|
119
|
+
* const maplibreLayer = new MaplibreLayer({
|
|
120
|
+
* apiKey: 'yourApiKey',
|
|
116
121
|
* });
|
|
117
122
|
*
|
|
118
|
-
* const layer = new
|
|
123
|
+
* const layer = new MaplibreStyleLayer({
|
|
119
124
|
* maplibreLayer: maplibreLayer,
|
|
120
|
-
*
|
|
125
|
+
* layersFilter: (layer) => {
|
|
126
|
+
* // show/hide only style layers related to stations
|
|
127
|
+
* return /station/.test(layer.id);
|
|
128
|
+
* },
|
|
121
129
|
* });
|
|
122
130
|
*
|
|
123
|
-
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
124
131
|
* @extends {ol/layer/Layer~Layer}
|
|
132
|
+
* @public
|
|
125
133
|
*/
|
|
126
134
|
declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
127
135
|
highlightedFeatures: Feature[];
|
|
@@ -130,16 +138,16 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
130
138
|
* Constructor.
|
|
131
139
|
*
|
|
132
140
|
* @param {Object} options
|
|
133
|
-
* @param {
|
|
134
|
-
* @param {maplibregl.SourceSpecification[]} [options.sources] The source to add to the style on load.
|
|
141
|
+
* @param {string} [options.beforeId] The style layer id to use when the options.layers property is defined, unsused otherwise.
|
|
135
142
|
* @param {maplibregl.AddLayerObject[]} [options.layers] The layers to add to the style on load.
|
|
136
143
|
* @param {FilterFunction} [options.layersFilter] Filter function to decide which style layer to apply visiblity on. If not provided, the 'layers' property is used.
|
|
144
|
+
* @param {MaplibreLayer} [options.maplibreLayer] The MaplibreLayer to use.
|
|
137
145
|
* @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
|
|
146
|
+
* @param {maplibregl.SourceSpecification[]} [options.sources] The sources to add to the style on load.
|
|
147
|
+
* @public
|
|
138
148
|
*/
|
|
139
149
|
constructor(options?: MaplibreStyleLayerOptions);
|
|
140
|
-
/** @private */
|
|
141
150
|
addLayers(): void;
|
|
142
|
-
/** @private */
|
|
143
151
|
addSources(): void;
|
|
144
152
|
applyLayoutVisibility(evt?: ObjectEvent): void;
|
|
145
153
|
/**
|
|
@@ -149,9 +157,11 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
149
157
|
*/
|
|
150
158
|
attachToMap(map: Map): void;
|
|
151
159
|
/**
|
|
152
|
-
* Create a copy of the
|
|
153
|
-
*
|
|
154
|
-
* @
|
|
160
|
+
* Create a copy of the MaplibreStyleLayer.
|
|
161
|
+
*
|
|
162
|
+
* @param {Object} newOptions Options to override. See constructor.
|
|
163
|
+
* @return {MapboxStyleLayer} A MaplibreStyleLayer.
|
|
164
|
+
* @public
|
|
155
165
|
*/
|
|
156
166
|
clone(newOptions: MaplibreStyleLayerOptions): MaplibreStyleLayer;
|
|
157
167
|
createRenderer(): MaplibreStyleLayerRenderer;
|
|
@@ -164,33 +174,32 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
164
174
|
* Request feature information for a given coordinate.
|
|
165
175
|
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
166
176
|
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
177
|
+
* @deprecated Use getFeatureInfoAtCoordinate([layer], coordinate) from mobility-toolbox-ol package instead.
|
|
167
178
|
*/
|
|
168
179
|
getFeatureInfoAtCoordinate(coordinate: Coordinate): Promise<LayerGetFeatureInfoResponse>;
|
|
169
180
|
/**
|
|
170
181
|
* Highlight a list of features.
|
|
171
182
|
* @param {Array<ol/Feature~Feature>} [features=[]] Features to highlight.
|
|
172
|
-
* @
|
|
183
|
+
* @deprecated Use layer.setFeatureState(features, {hover: true|false}) instead.
|
|
173
184
|
*/
|
|
174
185
|
highlight(features?: Feature[]): void;
|
|
175
186
|
/**
|
|
176
187
|
* On Maplibre map load callback function. Add style layers and dynaimc filters.
|
|
177
|
-
* @private
|
|
178
188
|
*/
|
|
179
189
|
onLoad(): void;
|
|
180
|
-
/** @private */
|
|
181
190
|
removeLayers(): void;
|
|
182
|
-
/** @private */
|
|
183
191
|
removeSources(): void;
|
|
184
192
|
/**
|
|
185
193
|
* Select a list of features.
|
|
186
194
|
* @param {Array<ol/Feature~Feature>} [features=[]] Features to select.
|
|
187
|
-
* @
|
|
195
|
+
* @deprecated Use layer.setFeatureState(features, {selected: true|false}) instead.
|
|
188
196
|
*/
|
|
189
197
|
select(features?: Feature[]): void;
|
|
190
198
|
/**
|
|
191
199
|
* Set the feature state of the features.
|
|
192
|
-
*
|
|
193
|
-
* @param {
|
|
200
|
+
*
|
|
201
|
+
* @param {ol/Feature~Feature[]} features
|
|
202
|
+
* @param {maplibregl.FeatureState} state The feature state
|
|
194
203
|
* @public
|
|
195
204
|
*/
|
|
196
205
|
setFeatureState(features: Feature[], state: FeatureState): void;
|
|
@@ -198,15 +207,18 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
198
207
|
* Set if features are hovered or not.
|
|
199
208
|
* @param {Array<ol/Feature~Feature>} features
|
|
200
209
|
* @param {boolean} state Is the feature hovered
|
|
201
|
-
* @
|
|
210
|
+
* @deprecated Use layer.setFeatureState(features, {hover: true|false}) instead.
|
|
202
211
|
*/
|
|
203
212
|
setHoverState(features: Feature[], state: boolean): void;
|
|
204
213
|
get beforeId(): string;
|
|
205
|
-
set beforeId(newValue: string
|
|
214
|
+
set beforeId(newValue: string | undefined);
|
|
206
215
|
get layers(): maplibregl.AddLayerObject[];
|
|
207
216
|
set layers(newValue: maplibregl.AddLayerObject[]);
|
|
208
217
|
get layersFilter(): (layer: maplibregl.LayerSpecification) => boolean;
|
|
209
218
|
set layersFilter(newValue: (layer: maplibregl.LayerSpecification) => boolean);
|
|
219
|
+
/**
|
|
220
|
+
* @deprecated Use MaplibreStyleLayer.maplibreLayer instead.
|
|
221
|
+
*/
|
|
210
222
|
get mapboxLayer(): MaplibreLayer | undefined;
|
|
211
223
|
get maplibreLayer(): MaplibreLayer;
|
|
212
224
|
set maplibreLayer(newValue: MaplibreLayer);
|
|
@@ -215,7 +227,7 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
215
227
|
get sources(): Record<string, maplibregl.SourceSpecification>;
|
|
216
228
|
set sources(newValue: Record<string, maplibregl.SourceSpecification>);
|
|
217
229
|
/**
|
|
218
|
-
* @deprecated
|
|
230
|
+
* @deprecated Use MaplibreStyleLayer.layer instead.
|
|
219
231
|
*/
|
|
220
232
|
get styleLayer(): maplibregl.AddLayerObject;
|
|
221
233
|
/**
|