mobility-toolbox-js 3.0.0-beta.1 → 3.0.0-beta.11

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.
Files changed (92) hide show
  1. package/api/HttpAPI.d.ts +20 -0
  2. package/api/HttpAPI.js +1 -11
  3. package/api/RealtimeAPI.d.ts +365 -0
  4. package/api/RealtimeAPI.js +101 -88
  5. package/api/RoutingAPI.d.ts +37 -0
  6. package/api/RoutingAPI.js +1 -1
  7. package/api/StopsAPI.d.ts +44 -0
  8. package/api/StopsAPI.js +15 -9
  9. package/api/WebSocketAPI.d.ts +153 -0
  10. package/api/index.d.ts +3 -0
  11. package/api/typedefs.d.ts +178 -0
  12. package/common/controls/StopFinderControlCommon.d.ts +53 -0
  13. package/common/index.d.ts +2 -0
  14. package/common/mixins/RealtimeLayerMixin.d.ts +273 -0
  15. package/common/styles/index.d.ts +4 -0
  16. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  17. package/common/styles/realtimeDelayStyle.d.ts +12 -0
  18. package/common/styles/realtimeHeadingStyle.d.ts +12 -0
  19. package/common/styles/realtimeSimpleStyle.d.ts +4 -0
  20. package/common/typedefs.d.ts +212 -0
  21. package/common/utils/compareDepartures.d.ts +10 -0
  22. package/common/utils/constants.d.ts +5 -0
  23. package/common/utils/createCanvas.d.ts +10 -0
  24. package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
  25. package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
  26. package/common/utils/createRealtimeFilters.d.ts +12 -0
  27. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  28. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  29. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  30. package/common/utils/getLayersAsFlatArray.js +5 -1
  31. package/common/utils/getMapGlCopyrights.d.ts +17 -0
  32. package/common/utils/getRealtimeModeSuffix.d.ts +9 -0
  33. package/common/utils/getUrlWithParams.d.ts +8 -0
  34. package/common/utils/getVehiclePosition.d.ts +16 -0
  35. package/common/utils/getVehiclePosition.js +3 -2
  36. package/common/utils/index.d.ts +16 -0
  37. package/common/utils/realtimeConfig.d.ts +64 -0
  38. package/common/utils/removeDuplicate.d.ts +9 -0
  39. package/common/utils/renderTrajectories.d.ts +16 -0
  40. package/common/utils/sortAndFilterDepartures.d.ts +15 -0
  41. package/common/utils/sortByDelay.d.ts +3 -0
  42. package/common/utils/timeUtils.d.ts +23 -0
  43. package/common/utils/toMercatorExtent.d.ts +5 -0
  44. package/iife.d.ts +2 -0
  45. package/index.d.ts +9 -0
  46. package/maplibre/controls/CopyrightControl.d.ts +35 -0
  47. package/maplibre/controls/index.d.ts +1 -0
  48. package/maplibre/index.d.ts +5 -0
  49. package/maplibre/layers/Layer.d.ts +28 -0
  50. package/maplibre/layers/RealtimeLayer.d.ts +160 -0
  51. package/maplibre/layers/RealtimeLayer.js +2 -2
  52. package/maplibre/layers/index.d.ts +2 -0
  53. package/maplibre/utils/getMercatorResolution.d.ts +7 -0
  54. package/maplibre/utils/getSourceCoordinates.d.ts +7 -0
  55. package/maplibre/utils/index.d.ts +2 -0
  56. package/mbt.js +5752 -6987
  57. package/mbt.js.map +4 -4
  58. package/mbt.min.js +55 -55
  59. package/mbt.min.js.map +4 -4
  60. package/ol/controls/CopyrightControl.d.ts +31 -0
  61. package/ol/controls/CopyrightControl.js +18 -8
  62. package/ol/controls/RoutingControl.d.ts +209 -0
  63. package/ol/controls/RoutingControl.js +4 -1
  64. package/ol/controls/StopFinderControl.d.ts +37 -0
  65. package/ol/controls/StopFinderControl.js +4 -1
  66. package/ol/controls/index.d.ts +3 -0
  67. package/ol/index.d.ts +6 -0
  68. package/ol/layers/MaplibreLayer.d.ts +183 -0
  69. package/ol/layers/MaplibreLayer.js +133 -10
  70. package/ol/layers/MaplibreStyleLayer.d.ts +241 -0
  71. package/ol/layers/MaplibreStyleLayer.js +61 -46
  72. package/ol/layers/RealtimeLayer.d.ts +285 -0
  73. package/ol/layers/RealtimeLayer.js +12 -6
  74. package/ol/layers/index.d.ts +3 -0
  75. package/ol/mixins/MobilityLayerMixin.d.ts +98 -0
  76. package/ol/mixins/MobilityLayerMixin.js +1 -4
  77. package/ol/mixins/PropertiesLayerMixin.d.ts +127 -0
  78. package/ol/mixins/PropertiesLayerMixin.js +6 -65
  79. package/ol/renderers/MaplibreLayerRenderer.d.ts +20 -0
  80. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
  81. package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
  82. package/ol/renderers/RealtimeLayerRenderer.js +9 -9
  83. package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
  84. package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
  85. package/ol/styles/index.d.ts +3 -0
  86. package/ol/styles/routingStyle.d.ts +4 -0
  87. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
  88. package/ol/utils/getFeatureInfoAtCoordinate.js +2 -2
  89. package/ol/utils/index.d.ts +1 -0
  90. package/package.json +19 -21
  91. package/setupTests.d.ts +1 -0
  92. package/ol/layers/MapGlLayer.js +0 -142
@@ -0,0 +1,31 @@
1
+ import { MapEvent } from 'ol';
2
+ import Control, { Options } from 'ol/control/Control';
3
+ export type CopyrightControlOptions = Options & {
4
+ className?: 'string';
5
+ format?: (copyrights: string[]) => string;
6
+ };
7
+ /**
8
+ * Display layer's copyrights.
9
+ *
10
+ * @example
11
+ * import { Map } from 'ol';
12
+ * import { CopyrightControl } from 'mobility-toolbox-js/ol';
13
+ *
14
+ * const map = new Map({
15
+ * target: 'map',
16
+ * });
17
+ *
18
+ * const control = new CopyrightControl();
19
+ * map.addControl(control);
20
+ *
21
+ *
22
+ * @see <a href="/example/ol-copyright">Openlayers copyright example</a>
23
+ *
24
+ * @extends {ol/control/Control}
25
+ */
26
+ declare class CopyrightControl extends Control {
27
+ format: (copyrights: string[]) => string;
28
+ constructor(options?: CopyrightControlOptions);
29
+ render({ frameState }: MapEvent): void;
30
+ }
31
+ export default CopyrightControl;
@@ -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
- inView(layerState, frameState.viewState) &&
41
- layer &&
42
- layer.getSource &&
43
- layer.getSource() &&
44
- layer.getSource().getAttributions()) {
45
- copyrights = copyrights.concat(layer.getSource().getAttributions()(frameState));
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 = unique.join(' | ');
59
+ this.element.innerHTML = this.format(unique);
50
60
  }
51
61
  }
52
62
  export default CopyrightControl;
@@ -0,0 +1,209 @@
1
+ import { Feature } from 'ol';
2
+ import type { Map, MapBrowserEvent } from 'ol';
3
+ import { Geometry, LineString, Point } from 'ol/geom';
4
+ import { Modify } from 'ol/interaction';
5
+ import { GeoJSON } from 'ol/format';
6
+ import type { Coordinate } from 'ol/coordinate';
7
+ import type { StyleLike } from 'ol/style/Style';
8
+ import { EventsKey } from 'ol/events';
9
+ import { ModifyEvent } from 'ol/interaction/Modify';
10
+ import VectorLayer from 'ol/layer/Vector';
11
+ import VectorSource from 'ol/source/Vector';
12
+ import Control, { Options } from 'ol/control/Control';
13
+ import { RoutingAPI } from '../../api';
14
+ import type { RoutingGraph, RoutingMot, RoutingParameters, RoutingViaPoint } from '../../types';
15
+ export type RoutingControlOptions = Options & {
16
+ apiKey?: string;
17
+ active?: boolean;
18
+ stopsApiKey?: string;
19
+ stopsApiUrl?: string;
20
+ routingLayer?: VectorLayer<VectorSource<Feature<Geometry>>>;
21
+ graphs?: RoutingGraph[];
22
+ mot?: string;
23
+ modify?: boolean;
24
+ routingApiParams?: RoutingParameters;
25
+ useRawViaPoints?: boolean;
26
+ snapToClosestStation?: boolean;
27
+ style?: StyleLike;
28
+ onRouteError?: () => void;
29
+ };
30
+ export type AbotControllersByGraph = {
31
+ [key: string]: AbortController;
32
+ };
33
+ /**
34
+ * This 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/).
35
+ *
36
+ * @example
37
+ * import { Map } from 'ol';
38
+ * import { RoutingControl } from 'mobility-toolbox-js/ol';
39
+ *
40
+ * const map = new Map({
41
+ * target: 'map'
42
+ * });
43
+ *
44
+ * const control = new RoutingControl();
45
+ *
46
+ * control.attachToMap(map)
47
+ *
48
+ * @classproperty {string} apiKey - Key used for RoutingApi requests.
49
+ * @classproperty {string} stopsApiKey - Key used for Stop lookup requests (defaults to apiKey).
50
+ * @classproperty {string} stopsApiUrl - Url used for Stop lookup requests (defaults to https://api.geops.io/stops/v1/lookup/).
51
+ * @classproperty {Array.<Array<graph="osm", minZoom=0, maxZoom=99>>} graphs - Array of routing graphs and min/max zoom levels. If you use the control in combination with the [geOps Maps API](https://developer.geops.io/apis/maps/), you may want to use the optimal level of generalizations: "[['gen4', 0, 8], ['gen3', 8, 9], ['gen2', 9, 11], ['gen1', 11, 13], ['osm', 13, 99]]"
52
+ * @classproperty {string} mot - Mean of transport to be used for routing.
53
+ * @classproperty {object} routingApiParams - object of additional parameters to pass to the routing api request.
54
+ * @classproperty {object} snapToClosestStation - If true, the routing will snap the coordinate to the closest station. Default to false.
55
+ * @classproperty {boolean} useRawViaPoints - Experimental property. Wen true, it allows the user to add via points using different kind of string. See "via" parameter defined by the [geOps Routing API](https://developer.geops.io/apis/routing/). Default to false, only array of coordinates and station's id are supported as via points.
56
+ * @classproperty {VectorLayer} routingLayer - Layer for adding route features.
57
+ * @classproperty {function} onRouteError - Callback on error.
58
+ * @classproperty {boolean} loading - True if the control is requesting the backend.
59
+ * @see <a href="/example/ol-routing">Openlayers routing example</a>
60
+ *
61
+ * @extends {Control}
62
+ * @implements {RoutingInterface}
63
+ * @public
64
+ */
65
+ declare class RoutingControl extends Control {
66
+ map?: Map;
67
+ viaPoints: RoutingViaPoint[];
68
+ routingLayer?: VectorLayer<VectorSource<Feature<Geometry>>>;
69
+ graphs: RoutingGraph[];
70
+ routingApiParams?: RoutingParameters;
71
+ useRawViaPoints: boolean;
72
+ snapToClosestStation: boolean;
73
+ cacheStationData: {
74
+ [key: string]: Coordinate;
75
+ };
76
+ abortControllers: {
77
+ [key: string]: AbortController;
78
+ };
79
+ apiKey?: string;
80
+ stopsApiKey?: string;
81
+ segments: Feature<LineString>[];
82
+ stopsApiUrl?: string;
83
+ api?: RoutingAPI;
84
+ format: GeoJSON;
85
+ graphsResolutions?: [number, number][];
86
+ onRouteError: (error?: Error, control?: RoutingControl) => void;
87
+ onMapClickKey?: EventsKey;
88
+ modifyInteraction?: Modify;
89
+ initialRouteDrag?: {
90
+ viaPoint?: Feature<Point>;
91
+ oldRoute?: Feature<LineString>;
92
+ segmentIndex?: number;
93
+ };
94
+ get active(): boolean;
95
+ set active(newValue: boolean);
96
+ get loading(): boolean;
97
+ set loading(newValue: boolean);
98
+ get modify(): any;
99
+ set modify(newValue: any);
100
+ get mot(): RoutingMot;
101
+ set mot(newValue: RoutingMot);
102
+ constructor(options?: RoutingControlOptions);
103
+ /**
104
+ * Calculate at which resolutions corresponds each generalizations.
105
+ *
106
+ * @private
107
+ */
108
+ static getGraphsResolutions(graphs: RoutingGraph[], map: Map): [number, number][];
109
+ /**
110
+ * Activet7deactivate the control when activ eproperty changes
111
+ * @private
112
+ */
113
+ onActiveChange(): void;
114
+ /**
115
+ * Adds/Replaces a viaPoint to the viaPoints array and redraws route:
116
+ * Adds a viaPoint at end of array by default.
117
+ * If an index is passed a viaPoint is added at the specified index.
118
+ * If an index is passed and overwrite x is > 0, x viaPoints at the specified
119
+ * index are replaced with a single new viaPoint.
120
+ * @param {number[]|string} coordinates Array of coordinates
121
+ * @param {number} [index=-1] Integer representing the index of the added viaPoint. If not specified, the viaPoint is added at the end of the array.
122
+ * @param {number} [overwrite=0] Marks the number of viaPoints that are removed at the specified index on add.
123
+ * @public
124
+ */
125
+ addViaPoint(coordinatesOrString: RoutingViaPoint, index?: number, overwrite?: number): void;
126
+ /**
127
+ * Removes a viaPoint at the passed array index and redraws route
128
+ * By default the last viaPoint is removed.
129
+ * @param {number} index Integer representing the index of the viaPoint to delete.
130
+ * @public
131
+ */
132
+ removeViaPoint(index?: number): void;
133
+ /**
134
+ * Replaces the current viaPoints with a new coordinate array.
135
+ * @param {Array<Array<number>>} coordinateArray Array of nested coordinates
136
+ * @public
137
+ */
138
+ setViaPoints(coordinateArray: Coordinate[]): void;
139
+ /**
140
+ * Removes all viaPoints, clears the source and triggers a change event
141
+ * @public
142
+ */
143
+ reset(): void;
144
+ /**
145
+ * Aborts viapoint and route requests
146
+ * @private
147
+ */
148
+ abortRequests(): void;
149
+ /**
150
+ * Draws route on map using an array of coordinates:
151
+ * If a single coordinate is passed a single point feature is added to map.
152
+ * If two or more coordinates are passed a request to the RoutingAPI fetches
153
+ * the route using the passed coordinates and the current mot.
154
+ * @private
155
+ */
156
+ drawRoute(): Promise<void | Feature<Geometry>> | Promise<Feature<Geometry> | null> | Promise<(void | never[])[]> | null;
157
+ /**
158
+ * Draw a via point. This function can parse all the possibilitiies
159
+ *
160
+ * @private
161
+ */
162
+ drawViaPoint(viaPoint: RoutingViaPoint, idx: number, abortController: AbortController): Promise<void | Feature<Geometry>> | Promise<Feature<Geometry> | null>;
163
+ /**
164
+ * Used on click on map while control is active:
165
+ * By default adds a viaPoint to the end of array.
166
+ * If an existing viaPoint is clicked removes the clicked viaPoint.
167
+ * @private
168
+ */
169
+ onMapClick(evt: MapBrowserEvent<MouseEvent>): void;
170
+ /**
171
+ * Used on start of the modify interaction. Stores relevant data
172
+ * in this.initialRouteDrag object
173
+ * @private
174
+ */
175
+ onModifyStart(evt: ModifyEvent): void;
176
+ /**
177
+ * Used on end of the modify interaction. Resolves feature modification:
178
+ * Line drag creates new viaPoint at the final coordinate of drag.
179
+ * Point drag replaces old viaPoint.
180
+ * @private
181
+ */
182
+ onModifyEnd(evt: ModifyEvent): void | Promise<never>;
183
+ /**
184
+ * Define a default element.
185
+ *
186
+ * @private
187
+ */
188
+ createDefaultElement(): void;
189
+ /**
190
+ * Create the interaction used to modify vertexes of features.
191
+ * @private
192
+ */
193
+ createModifyInteraction(): void;
194
+ /**
195
+ * Add click listener to map.
196
+ * @private
197
+ */
198
+ addListeners(): void;
199
+ /**
200
+ * Remove click listener from map.
201
+ * @private
202
+ */
203
+ removeListeners(): void;
204
+ setMap(map: Map): void;
205
+ activate(): void;
206
+ deactivate(): void;
207
+ render(): void;
208
+ }
209
+ export default RoutingControl;
@@ -47,7 +47,7 @@ const getFlatCoordinatesFromSegments = (segmentArray) => {
47
47
  return coords;
48
48
  };
49
49
  /**
50
- * Display a route of a specified mean of transport.
50
+ * This 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/).
51
51
  *
52
52
  * @example
53
53
  * import { Map } from 'ol';
@@ -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 */
@@ -0,0 +1,37 @@
1
+ import { Feature } from 'geojson';
2
+ import Control, { Options } from 'ol/control/Control';
3
+ import StopFinderControlCommon from '../../common/controls/StopFinderControlCommon';
4
+ export type StopFinderControlOptions = Options & StopFinderControlCommon & {
5
+ className?: string;
6
+ };
7
+ /**
8
+ * This OpenLayers control allows to search stations from the [geOps Stops API](https://developer.geops.io/apis/stops/).
9
+ *
10
+ * @example
11
+ * import { Map } from 'ol';
12
+ * import { StopFinderControl } from 'mobility-toolbox-js/ol';
13
+ *
14
+ * const map = new Map({
15
+ * target: 'map',
16
+ * });
17
+ *
18
+ * const control = new StopFinderControl({
19
+ * apiKey: [yourApiKey]
20
+ * });
21
+ *
22
+ * map.addControl(control);
23
+ *
24
+ *
25
+ * @see <a href="/example/ol-search">Openlayers search example</a>
26
+ * @public
27
+ */
28
+ declare class StopFinderControl extends Control {
29
+ controller: StopFinderControlCommon;
30
+ constructor(options: StopFinderControlOptions);
31
+ /**
32
+ * @private
33
+ */
34
+ onSuggestionClick(suggestion: Feature): void;
35
+ search(q: string, abortController: AbortController): Promise<void>;
36
+ }
37
+ export default StopFinderControl;
@@ -3,7 +3,7 @@ import Control from 'ol/control/Control';
3
3
  import StopFinderControlCommon from '../../common/controls/StopFinderControlCommon';
4
4
  import createDefaultStopFinderElement from '../../common/utils/createDefaultStopFinderElt';
5
5
  /**
6
- * Search stations.
6
+ * This OpenLayers control allows to search stations from the [geOps Stops API](https://developer.geops.io/apis/stops/).
7
7
  *
8
8
  * @example
9
9
  * import { Map } from 'ol';
@@ -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;
@@ -0,0 +1,3 @@
1
+ export { default as CopyrightControl } from "./CopyrightControl";
2
+ export { default as RoutingControl } from "./RoutingControl";
3
+ export { default as StopFinderControl } from "./StopFinderControl";
package/ol/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "../api";
2
+ export * from "../common";
3
+ export * from "./controls";
4
+ export * from "./layers";
5
+ export * from "./styles";
6
+ export * from "./utils";
@@ -0,0 +1,183 @@
1
+ import Source from 'ol/source/Source';
2
+ import OlMap from 'ol/Map';
3
+ import BaseEvent from 'ol/events/Event';
4
+ import Layer from 'ol/layer/Layer';
5
+ import { Map, MapOptions } from 'maplibre-gl';
6
+ import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
7
+ import MaplibreLayerRenderer from '../renderers/MaplibreLayerRenderer';
8
+ export type MaplibreLayerOptions = MobilityLayerOptions & {
9
+ apiKey?: string;
10
+ apiKeyName?: string;
11
+ style?: string | maplibregl.StyleSpecification;
12
+ url?: string;
13
+ mapOptions?: maplibregl.MapOptions;
14
+ queryRenderedFeaturesOptions?: maplibregl.QueryRenderedFeaturesOptions;
15
+ };
16
+ declare const MaplibreLayer_base: {
17
+ new (...args: any[]): {
18
+ options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions | undefined;
19
+ olListenersKeys: import("ol/events").EventsKey[];
20
+ children: Layer<Source, import("ol/renderer/Layer").default<any>>[];
21
+ get copyrights(): string;
22
+ set copyrights(newCopyrights: string | string[]);
23
+ disabled: boolean;
24
+ readonly group: string;
25
+ readonly hitTolerance: boolean;
26
+ readonly key: string;
27
+ readonly map: OlMap;
28
+ readonly name: string;
29
+ olLayer: Layer<Source, import("ol/renderer/Layer").default<any>>;
30
+ parent: Layer<Source, import("ol/renderer/Layer").default<any>>;
31
+ visible: boolean;
32
+ setMapInternal: ((map: OlMap) => void) & ((map: OlMap | null) => void);
33
+ onChildrenChange(oldValue: Layer<Source, import("ol/renderer/Layer").default<any>>[]): void;
34
+ attachToMap(map: OlMap): void;
35
+ detachFromMap(): void;
36
+ flat(): any[];
37
+ addEventListener: (type: string, listener: import("ol/events").Listener) => void;
38
+ removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
39
+ on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
40
+ render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
41
+ once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
42
+ un: import("ol/layer/Layer").LayerOnSignature<void>;
43
+ getSource: () => Source | null;
44
+ getRenderSource: () => Source | null;
45
+ getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<import("ol/Feature").FeatureLike[]>;
46
+ getData: (pixel: import("ol/pixel").Pixel) => Float32Array | Uint8ClampedArray | Uint8Array | DataView | null;
47
+ isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
48
+ getAttributions: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => string[];
49
+ unrender: () => void;
50
+ getDeclutter: () => string;
51
+ renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
52
+ renderDeferred: (frameState: import("ol/Map").FrameState) => void;
53
+ getMapInternal: () => OlMap | null;
54
+ setMap: (map: OlMap | null) => void;
55
+ setSource: (source: Source | null) => void;
56
+ getRenderer: () => import("ol/renderer/Layer").default<any> | null;
57
+ hasRenderer: () => boolean;
58
+ getBackground: () => false | import("ol/layer/Base").BackgroundColor;
59
+ getClassName: () => string;
60
+ getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
61
+ getLayersArray: (array?: Layer<Source, import("ol/renderer/Layer").default<any>>[] | undefined) => Layer<Source, import("ol/renderer/Layer").default<any>>[];
62
+ getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => import("ol/layer/Layer").State[];
63
+ getExtent: () => import("ol/extent").Extent | undefined;
64
+ getMaxResolution: () => number;
65
+ getMinResolution: () => number;
66
+ getMinZoom: () => number;
67
+ getMaxZoom: () => number;
68
+ getOpacity: () => number;
69
+ getSourceState: () => import("ol/source/Source").State;
70
+ getVisible: () => boolean;
71
+ getZIndex: () => number | undefined;
72
+ setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
73
+ setExtent: (extent: import("ol/extent").Extent | undefined) => void;
74
+ setMaxResolution: (maxResolution: number) => void;
75
+ setMinResolution: (minResolution: number) => void;
76
+ setMaxZoom: (maxZoom: number) => void;
77
+ setMinZoom: (minZoom: number) => void;
78
+ setOpacity: (opacity: number) => void;
79
+ setVisible: (visible: boolean) => void;
80
+ setZIndex: (zindex: number) => void;
81
+ get: (key: string) => any;
82
+ getKeys: () => string[];
83
+ getProperties: () => {
84
+ [x: string]: any;
85
+ };
86
+ getPropertiesInternal: () => {
87
+ [x: string]: any;
88
+ } | null;
89
+ hasProperties: () => boolean;
90
+ notify: (key: string, oldValue: any) => void;
91
+ addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
92
+ removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
93
+ set: (key: string, value: any, silent?: boolean | undefined) => void;
94
+ setProperties: (values: {
95
+ [x: string]: any;
96
+ }, silent?: boolean | undefined) => void;
97
+ unset: (key: string, silent?: boolean | undefined) => void;
98
+ changed: () => void;
99
+ getRevision: () => number;
100
+ dispatchEvent: (event: string | BaseEvent) => boolean | undefined;
101
+ getListeners: (type: string) => import("ol/events").Listener[] | undefined;
102
+ hasListener: (type?: string | undefined) => boolean;
103
+ dispose: () => void;
104
+ };
105
+ } & typeof Layer;
106
+ /**
107
+ * An OpenLayers layer able to display data from the [geOps Maps API](https://developer.geops.io/apis/maps).
108
+ *
109
+ * @example
110
+ * import { MaplibreLayer } from 'mobility-toolbox-js/ol';
111
+ *
112
+ * const layer = new MaplibreLayer({
113
+ * apiKey: 'yourApiKey',
114
+ * // apiKeyName: 'key',
115
+ * // mapOptions: {
116
+ * // interactive: false,
117
+ * // trackResize: false,
118
+ * // attributionControl: false,
119
+ * // }
120
+ * // queryRenderedFeaturesOptions: {
121
+ * // layers: ['waters_lakes'], // map.getFeaturesAtPixel will only return lakes.
122
+ * // },
123
+ * // style: 'travic_v2',
124
+ * // url: 'https://maps.geops.io',
125
+ * });
126
+ *
127
+ * @classproperty {maplibregl.Map} maplibreMap - The Maplibre map object. Readonly.
128
+ * @classproperty {maplibregl.QueryRenderedFeaturesOptions} queryRenderedFeaturesOptions - Options used when we query features using map.getFeaturesAtPixel().
129
+ * @classproperty {string} style - geOps Maps api style.
130
+ * @extends {ol/layer/Layer~Layer}
131
+ * @public
132
+ */
133
+ declare class MaplibreLayer extends MaplibreLayer_base {
134
+ loaded: boolean;
135
+ maplibreMap?: Map;
136
+ get apiKey(): string;
137
+ set apiKey(newValue: string);
138
+ get apiKeyName(): string;
139
+ set apiKeyName(newValue: string);
140
+ get mbMap(): maplibregl.Map | undefined;
141
+ get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions;
142
+ set queryRenderedFeaturesOptions(newValue: maplibregl.QueryRenderedFeaturesOptions);
143
+ get style(): string;
144
+ set style(newValue: string);
145
+ get url(): string;
146
+ set url(newValue: string);
147
+ /**
148
+ * Constructor.
149
+ *
150
+ * @param {MaplibreLayerOptions} options
151
+ * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
152
+ * @param {string} [options.apiKeyName="key"] The geOps Maps api key name.
153
+ * @param {maplibregl.MapOptions} [options.mapOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
154
+ * @param {string} [options.style="travic_v2"] The geOps Maps api style.
155
+ * @param {string} [options.url="https://maps.geops.io"] The geOps Maps api url.
156
+ */
157
+ constructor(options: MaplibreLayerOptions);
158
+ /**
159
+ * Initialize the layer and listen to feature clicks.
160
+ * @param {ol/Map~Map} map
161
+ */
162
+ attachToMap(map: OlMap): void;
163
+ /**
164
+ * Terminate what was initialized in init function. Remove layer, events...
165
+ */
166
+ detachFromMap(): void;
167
+ /**
168
+ * Create the Maplibre map.
169
+ * @private
170
+ */
171
+ loadMbMap(): void;
172
+ getStyle(): string;
173
+ createMap(options: MapOptions): Map;
174
+ createRenderer(): MaplibreLayerRenderer;
175
+ updateMaplibreMap(): void;
176
+ /**
177
+ * Create a copy of the MaplibreLayer.
178
+ * @param {MaplibreLayerOptions} newOptions Options to override
179
+ * @return {MaplibreLayer} A MaplibreLayer layer
180
+ */
181
+ clone(newOptions: MaplibreLayerOptions): MaplibreLayer;
182
+ }
183
+ export default MaplibreLayer;