mobility-toolbox-js 3.0.0-beta.7 → 3.0.0-beta.9
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 +31 -0
- package/api/RealtimeAPI.d.ts +359 -0
- package/api/RealtimeAPI.js +96 -89
- package/api/RoutingAPI.d.ts +37 -0
- package/api/StopsAPI.d.ts +38 -0
- package/api/WebSocketAPI.d.ts +153 -0
- package/api/index.d.ts +3 -0
- package/api/typedefs.d.ts +178 -0
- package/common/controls/StopFinderControlCommon.d.ts +53 -0
- package/common/index.d.ts +2 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +273 -0
- package/common/styles/index.d.ts +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/typedefs.d.ts +212 -0
- package/common/utils/compareDepartures.d.ts +10 -0
- 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/getRealtimeModeSuffix.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts +8 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- 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/sortAndFilterDepartures.d.ts +15 -0
- package/common/utils/sortByDelay.d.ts +3 -0
- 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/RealtimeLayer.d.ts +160 -0
- package/maplibre/layers/RealtimeLayer.js +2 -2
- 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/index.d.ts +2 -0
- package/mbt.js +137 -114
- package/mbt.js.map +3 -3
- package/mbt.min.js +13 -13
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.js +18 -8
- package/ol/controls/RoutingControl.d.ts +209 -0
- package/ol/controls/RoutingControl.js +3 -0
- package/ol/controls/StopFinderControl.d.ts +37 -0
- package/ol/controls/StopFinderControl.js +3 -0
- package/ol/controls/index.d.ts +3 -0
- package/ol/index.d.ts +6 -0
- package/ol/layers/MapGlLayer.d.ts +144 -0
- package/ol/layers/MapGlLayer.js +3 -1
- package/ol/layers/MaplibreLayer.d.ts +63 -0
- package/ol/layers/MaplibreStyleLayer.d.ts +235 -0
- package/ol/layers/MaplibreStyleLayer.js +1 -1
- package/ol/layers/RealtimeLayer.d.ts +285 -0
- package/ol/layers/RealtimeLayer.js +13 -7
- package/ol/layers/index.d.ts +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +98 -0
- package/ol/mixins/MobilityLayerMixin.js +1 -4
- package/ol/mixins/PropertiesLayerMixin.d.ts +127 -0
- package/ol/mixins/PropertiesLayerMixin.js +5 -4
- package/ol/renderers/MaplibreLayerRenderer.d.ts +20 -0
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
- package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
- package/ol/renderers/RealtimeLayerRenderer.js +9 -9
- 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 +1 -1
- package/ol/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/setupTests.d.ts +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import HttpAPI from './HttpAPI';
|
|
2
|
+
import { StopsParameters, StopsResponse } from '../types';
|
|
3
|
+
export type StopsAPIOptions = {
|
|
4
|
+
url?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Access to the [geOps Stops api](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { StopsAPI } from 'mobility-toolbox-js/api';
|
|
12
|
+
*
|
|
13
|
+
* const api = new StopsAPI({
|
|
14
|
+
* url: 'https://api.geops.io/stops/v1/',
|
|
15
|
+
* apiKey: [yourApiKey]
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
declare class StopsAPI extends HttpAPI {
|
|
21
|
+
/**
|
|
22
|
+
* Constructor
|
|
23
|
+
*
|
|
24
|
+
* @param {StopsAPIOptions} options Options.
|
|
25
|
+
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Service url.
|
|
26
|
+
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
27
|
+
*/
|
|
28
|
+
constructor(options?: StopsAPIOptions);
|
|
29
|
+
/**
|
|
30
|
+
* Search fo stops.
|
|
31
|
+
*
|
|
32
|
+
* @param {StopsParameters} params Request parameters. See [Stops service documentation](https://developer.geops.io/apis/stops).
|
|
33
|
+
* @param {RequestInit} config Options for the fetch request.
|
|
34
|
+
* @return {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
35
|
+
*/
|
|
36
|
+
search(params: StopsParameters, config: RequestInit): Promise<StopsResponse>;
|
|
37
|
+
}
|
|
38
|
+
export default StopsAPI;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { RealtimeTrajectoryResponse } from '../types';
|
|
2
|
+
export declare type WebSocketAPIParameters = {
|
|
3
|
+
channel?: string;
|
|
4
|
+
args?: string | number;
|
|
5
|
+
id?: string | number;
|
|
6
|
+
};
|
|
7
|
+
export declare type WebSocketAPIMessageEventData<T> = {
|
|
8
|
+
timestamp: number;
|
|
9
|
+
source: string;
|
|
10
|
+
content: T;
|
|
11
|
+
client_reference: string | number | null;
|
|
12
|
+
};
|
|
13
|
+
export type WebSocketAPIBufferMessageEventData = WebSocketAPIMessageEventData<RealtimeTrajectoryResponse[]> & {
|
|
14
|
+
source: 'buffer';
|
|
15
|
+
};
|
|
16
|
+
export type WebSocketAPIMessageEvent = Event & {
|
|
17
|
+
data: string;
|
|
18
|
+
};
|
|
19
|
+
export interface WebSocketAPIMessageEventListener {
|
|
20
|
+
(evt: WebSocketAPIMessageEvent): void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* This type represents a function that has been call with each feature returned by the websocket.
|
|
24
|
+
*/
|
|
25
|
+
export interface WebSocketAPIMessageCallback<T> {
|
|
26
|
+
(data: WebSocketAPIMessageEventData<T>): void;
|
|
27
|
+
}
|
|
28
|
+
export declare type WebSocketAPISubscription = {
|
|
29
|
+
params: WebSocketAPIParameters;
|
|
30
|
+
cb: WebSocketAPIMessageCallback<any>;
|
|
31
|
+
errorCb?: EventListener;
|
|
32
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
33
|
+
onErrorCb?: EventListener;
|
|
34
|
+
quiet: boolean;
|
|
35
|
+
};
|
|
36
|
+
export declare type WebSocketAPISubscribed = {
|
|
37
|
+
[index: string]: boolean;
|
|
38
|
+
};
|
|
39
|
+
export declare type WebSocketAPIRequest = {
|
|
40
|
+
params: WebSocketAPIParameters;
|
|
41
|
+
cb: WebSocketAPIMessageCallback<any>;
|
|
42
|
+
errorCb?: EventListener;
|
|
43
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
44
|
+
onErrorCb?: EventListener;
|
|
45
|
+
requestString: String;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Class used to facilitate connection to a WebSocketAPI and
|
|
49
|
+
* also to manage properly messages send to the WebSocketAPI.
|
|
50
|
+
* This class must not contain any specific implementation.
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
declare class WebSocketAPI {
|
|
54
|
+
websocket?: WebSocket;
|
|
55
|
+
closed?: boolean;
|
|
56
|
+
closing?: boolean;
|
|
57
|
+
connecting?: boolean;
|
|
58
|
+
open?: boolean;
|
|
59
|
+
messagesOnOpen: Array<string>;
|
|
60
|
+
subscriptions: Array<WebSocketAPISubscription>;
|
|
61
|
+
subscribed: WebSocketAPISubscribed;
|
|
62
|
+
requests: Array<WebSocketAPIRequest>;
|
|
63
|
+
constructor();
|
|
64
|
+
defineProperties(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get the websocket request string.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} method Request mehtod {GET, SUB}.
|
|
69
|
+
* @param {WebSocketParameters} params Request parameters.
|
|
70
|
+
* @param {string} params.channel Channel name
|
|
71
|
+
* @param {string} [params.args] Request arguments
|
|
72
|
+
* @param {Number|string} [params.id] Request identifier
|
|
73
|
+
* @return {string} request string
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
static getRequestString(method: string, params?: WebSocketAPIParameters): string;
|
|
77
|
+
/**
|
|
78
|
+
* (Re)connect the websocket.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} url Websocket url.
|
|
81
|
+
* @param {function} onOpen Callback called when the websocket connection is opened and before subscriptions of previous subscriptions.
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
connect(url: string, onOpen?: () => void): void;
|
|
85
|
+
/**
|
|
86
|
+
* Close the websocket definitively.
|
|
87
|
+
*
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
close(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Sends a message to the websocket.
|
|
93
|
+
*
|
|
94
|
+
* @param {message} message Message to send.
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
send(message: string): void;
|
|
98
|
+
addEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
99
|
+
removeEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
100
|
+
/**
|
|
101
|
+
* Listen to websocket messages.
|
|
102
|
+
*
|
|
103
|
+
* @param {WebSocketParameters} params Parameters for the websocket get request
|
|
104
|
+
* @param {function} cb callback on listen
|
|
105
|
+
* @param {function} errorCb Callback on error
|
|
106
|
+
* @return {{onMessage: function, errorCb: function}} Object with onMessage and error callbacks
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
listen(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): {
|
|
110
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
111
|
+
onErrorCb?: EventListener;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Unlisten websocket messages.
|
|
115
|
+
*
|
|
116
|
+
* @param {Object} params Parameters for the websocket get request.
|
|
117
|
+
* @param {function} cb Callback used when listen.
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
unlisten(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>): void;
|
|
121
|
+
/**
|
|
122
|
+
* Sends a get request to the websocket.
|
|
123
|
+
* The callback is called only once, when the response is received or when the call returns an error.
|
|
124
|
+
*
|
|
125
|
+
* @param {Object} params Parameters for the websocket get request
|
|
126
|
+
* @param {function} onMessage callback on message event
|
|
127
|
+
* @param {function} onError Callback on error and close event
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
get(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): void;
|
|
131
|
+
/**
|
|
132
|
+
* Subscribe to a given channel.
|
|
133
|
+
*
|
|
134
|
+
* @param {Object} params Parameters for the websocket get request
|
|
135
|
+
* @param {function} cb callback on listen
|
|
136
|
+
* @param {function} errorCb Callback on error
|
|
137
|
+
* @param {boolean} quiet if false, no GET or SUB requests are send, only the callback is registered.
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
subscribe(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener, quiet?: boolean): void;
|
|
141
|
+
/**
|
|
142
|
+
* Unsubscribe from a channel.
|
|
143
|
+
* @param {string} source source to unsubscribe from
|
|
144
|
+
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
unsubscribe(source: string, cb?: WebSocketAPIMessageCallback<any>): void;
|
|
148
|
+
/**
|
|
149
|
+
* After an auto reconnection we need to re-subscribe to the channels.
|
|
150
|
+
*/
|
|
151
|
+
subscribePreviousSubscriptions(): void;
|
|
152
|
+
}
|
|
153
|
+
export default WebSocketAPI;
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
export default dummy;
|
|
2
|
+
export type Departure = {
|
|
3
|
+
/**
|
|
4
|
+
* Timestamp in ms.
|
|
5
|
+
*/
|
|
6
|
+
time: number;
|
|
7
|
+
no_stop_between: boolean;
|
|
8
|
+
train_number: number;
|
|
9
|
+
to: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Timestamp in ms.
|
|
12
|
+
*/
|
|
13
|
+
ris_aimed_time: number;
|
|
14
|
+
/**
|
|
15
|
+
* Timestamp in ms.
|
|
16
|
+
*/
|
|
17
|
+
updated_at: number;
|
|
18
|
+
new_to: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Timestamp in ms.
|
|
21
|
+
*/
|
|
22
|
+
min_arrival_time: number;
|
|
23
|
+
/**
|
|
24
|
+
* List of next stops. Like value in at_station_ds100.
|
|
25
|
+
*/
|
|
26
|
+
next_stoppoints: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Timestamp in ms.
|
|
29
|
+
*/
|
|
30
|
+
ris_estimated_time: number;
|
|
31
|
+
line: NetworkLine;
|
|
32
|
+
/**
|
|
33
|
+
* if true this departure has realtime data.
|
|
34
|
+
*/
|
|
35
|
+
has_fzo: boolean;
|
|
36
|
+
train_id: number;
|
|
37
|
+
platform: string;
|
|
38
|
+
state: any | null;
|
|
39
|
+
/**
|
|
40
|
+
* Timestamp in ms.
|
|
41
|
+
*/
|
|
42
|
+
fzo_estimated_time: number;
|
|
43
|
+
formation: any | null;
|
|
44
|
+
no_stop_till: any | null;
|
|
45
|
+
train_type: number;
|
|
46
|
+
call_id: number;
|
|
47
|
+
/**
|
|
48
|
+
* Timestamp in ms.
|
|
49
|
+
*/
|
|
50
|
+
created_at: string;
|
|
51
|
+
at_station_ds100: string;
|
|
52
|
+
/**
|
|
53
|
+
* Timestamp in ms.
|
|
54
|
+
*/
|
|
55
|
+
timediff: number;
|
|
56
|
+
};
|
|
57
|
+
export type Station = GeoJSONFeature;
|
|
58
|
+
export type StationProperties = {
|
|
59
|
+
transfers: Transfer[];
|
|
60
|
+
elevatorOutOfOrder: boolean;
|
|
61
|
+
uic: number;
|
|
62
|
+
name: string;
|
|
63
|
+
networkLines: NetworkLine[];
|
|
64
|
+
hasElevator: boolean;
|
|
65
|
+
hasZOB: boolean;
|
|
66
|
+
hasAccessibility: boolean;
|
|
67
|
+
type: string;
|
|
68
|
+
};
|
|
69
|
+
export type NetworkLine = {
|
|
70
|
+
/**
|
|
71
|
+
* Identifier of the line.
|
|
72
|
+
*/
|
|
73
|
+
id: number;
|
|
74
|
+
/**
|
|
75
|
+
* Color of the line (CSS color string).
|
|
76
|
+
*/
|
|
77
|
+
color: string;
|
|
78
|
+
/**
|
|
79
|
+
* Stroke color of the line (CSS color string).
|
|
80
|
+
*/
|
|
81
|
+
stroke: string;
|
|
82
|
+
/**
|
|
83
|
+
* Name of the line.
|
|
84
|
+
*/
|
|
85
|
+
name: string;
|
|
86
|
+
/**
|
|
87
|
+
* Text color of the line (CSS color string).
|
|
88
|
+
*/
|
|
89
|
+
text_color: string;
|
|
90
|
+
};
|
|
91
|
+
export type Transfer = {
|
|
92
|
+
/**
|
|
93
|
+
* Mode of transportation (ex: U-Bahn).
|
|
94
|
+
*/
|
|
95
|
+
mot: string;
|
|
96
|
+
/**
|
|
97
|
+
* Array of lines name (ex: ["U4", "U5"]).
|
|
98
|
+
*/
|
|
99
|
+
lines: string[];
|
|
100
|
+
};
|
|
101
|
+
export type StopSequence = GeoJSONFeature;
|
|
102
|
+
export type RealtimeTrajectory = GeoJSONFeature;
|
|
103
|
+
export type FullTrajectory = GeoJSONFeature;
|
|
104
|
+
export type Vehicle = GeoJSONFeature;
|
|
105
|
+
export type ExtraGeom = GeoJSONFeature;
|
|
106
|
+
/**
|
|
107
|
+
* @typedef {Object} Departure
|
|
108
|
+
* @property {number} time Timestamp in ms.
|
|
109
|
+
* @property {boolean} no_stop_between
|
|
110
|
+
* @property {number} train_number
|
|
111
|
+
* @property {string[]} to
|
|
112
|
+
* @property {number} ris_aimed_time Timestamp in ms.
|
|
113
|
+
* @property {number} updated_at Timestamp in ms.
|
|
114
|
+
* @property {boolean} new_to
|
|
115
|
+
* @property {number} min_arrival_time Timestamp in ms.
|
|
116
|
+
* @property {string[]} next_stoppoints List of next stops. Like value in at_station_ds100.
|
|
117
|
+
* @property {number} ris_estimated_time Timestamp in ms.
|
|
118
|
+
* @property {NetworkLine} line
|
|
119
|
+
* @property {boolean} has_fzo if true this departure has realtime data.
|
|
120
|
+
* @property {number} train_id
|
|
121
|
+
* @property {string} platform
|
|
122
|
+
* @property {?*} state
|
|
123
|
+
* @property {number} fzo_estimated_time Timestamp in ms.
|
|
124
|
+
* @property {?*} formation
|
|
125
|
+
* @property {?*} no_stop_till
|
|
126
|
+
* @property {number} train_type
|
|
127
|
+
* @property {number} call_id
|
|
128
|
+
* @property {string} created_at Timestamp in ms.
|
|
129
|
+
* @property {string} at_station_ds100
|
|
130
|
+
* @property {number} timediff Timestamp in ms.
|
|
131
|
+
*
|
|
132
|
+
*/
|
|
133
|
+
/**
|
|
134
|
+
* @typedef {GeoJSONFeature} Station
|
|
135
|
+
* @property {StationProperties} properties Returns the station's properties.
|
|
136
|
+
* @property {GeoJSONPoint} geometry Returns a point.
|
|
137
|
+
*/
|
|
138
|
+
/**
|
|
139
|
+
* @typedef {Object} StationProperties
|
|
140
|
+
* @property {Transfer[]} transfers
|
|
141
|
+
* @property {boolean} elevatorOutOfOrder
|
|
142
|
+
* @property {number} uic
|
|
143
|
+
* @property {string} name
|
|
144
|
+
* @property {NetworkLine[]} networkLines
|
|
145
|
+
* @property {boolean} hasElevator
|
|
146
|
+
* @property {boolean} hasZOB
|
|
147
|
+
* @property {boolean} hasAccessibility
|
|
148
|
+
* @property {string} type
|
|
149
|
+
*/
|
|
150
|
+
/**
|
|
151
|
+
* @typedef {Object} NetworkLine
|
|
152
|
+
* @property {number} id Identifier of the line.
|
|
153
|
+
* @property {string} color Color of the line (CSS color string).
|
|
154
|
+
* @property {string} stroke Stroke color of the line (CSS color string).
|
|
155
|
+
* @property {string} name Name of the line.
|
|
156
|
+
* @property {string} text_color Text color of the line (CSS color string).
|
|
157
|
+
*/
|
|
158
|
+
/**
|
|
159
|
+
* @typedef {Object} Transfer
|
|
160
|
+
* @property {string} mot Mode of transportation (ex: U-Bahn).
|
|
161
|
+
* @property {string[]} lines Array of lines name (ex: ["U4", "U5"]).
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* @typedef {GeoJSONFeature} StopSequence
|
|
165
|
+
*/
|
|
166
|
+
/**
|
|
167
|
+
* @typedef {GeoJSONFeature} RealtimeTrajectory
|
|
168
|
+
*/
|
|
169
|
+
/**
|
|
170
|
+
* @typedef {GeoJSONFeature} FullTrajectory
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
173
|
+
* @typedef {GeoJSONFeature} Vehicle
|
|
174
|
+
*/
|
|
175
|
+
/**
|
|
176
|
+
* @typedef {GeoJSONFeature} ExtraGeom
|
|
177
|
+
*/
|
|
178
|
+
declare function dummy(): void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Feature, FeatureCollection } from 'geojson';
|
|
2
|
+
import { StopsAPI } from '../../api';
|
|
3
|
+
import { StopsAPIOptions } from '../../api/StopsAPI';
|
|
4
|
+
import { StopsParameters } from '../../types';
|
|
5
|
+
export type StopFinderControlCommonOptions = StopsAPIOptions & {
|
|
6
|
+
element: HTMLElement;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
apiParams: StopsParameters;
|
|
9
|
+
onSuggestionClick?: (suggestion: Feature, evt: MouseEvent) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A class representing a stop finder control to display on map.
|
|
13
|
+
* This class only draw the html elements.
|
|
14
|
+
* The geographic logic must be implemented by subclasses.
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
declare class StopFinderControlCommon {
|
|
19
|
+
apiParams: StopsParameters;
|
|
20
|
+
placeholder: string;
|
|
21
|
+
api: StopsAPI;
|
|
22
|
+
abortController?: AbortController;
|
|
23
|
+
suggestionsElt?: HTMLElement;
|
|
24
|
+
inputElt?: HTMLInputElement;
|
|
25
|
+
clearElt?: HTMLDivElement;
|
|
26
|
+
options?: StopFinderControlCommonOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Constructor.
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} options Options
|
|
31
|
+
* @param {HTMLElement} options.element HTML element where to attach input and suggestions.
|
|
32
|
+
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/). See StopsAPI.
|
|
33
|
+
* @param {string} [options.url='https://api.geops.io/tracker/v1'] Stops service url. See StopsAPI.
|
|
34
|
+
* @param {string} [options.placeholder='Search for a stop...'] Input field placeholder.
|
|
35
|
+
* @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [Stops service documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
36
|
+
*/
|
|
37
|
+
constructor(options: StopFinderControlCommonOptions);
|
|
38
|
+
render(featureCollection?: FeatureCollection): void;
|
|
39
|
+
createElement({ element }: StopFinderControlCommonOptions): void;
|
|
40
|
+
/**
|
|
41
|
+
* Clear the search field and close the control.
|
|
42
|
+
*/
|
|
43
|
+
clear(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Launch a search.
|
|
46
|
+
*
|
|
47
|
+
* @param {String} query The query to search for.
|
|
48
|
+
* @param {AbortController} abortController Abort controller used to cancel the request.
|
|
49
|
+
* @return {Promise<Array<GeoJSONFeature>>} An array of GeoJSON features with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
50
|
+
*/
|
|
51
|
+
search(q: string, abortController: AbortController): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
export default StopFinderControlCommon;
|