mobility-toolbox-js 2.0.0-beta.46 → 2.0.0-beta.47
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/RealtimeAPI.d.ts +80 -64
- package/api/RealtimeAPI.d.ts.map +1 -1
- package/api/RealtimeAPI.js +58 -45
- package/api/RoutingAPI.d.ts +2 -2
- package/api/RoutingAPI.d.ts.map +1 -1
- package/api/RoutingAPI.js +1 -1
- package/api/StopsAPI.d.ts +14 -12
- package/api/StopsAPI.d.ts.map +1 -1
- package/api/StopsAPI.js +7 -9
- package/api/typedefs.d.ts +84 -10
- package/api/typedefs.d.ts.map +1 -1
- package/api/typedefs.js +3 -1
- package/common/api/WebSocketAPI.d.ts +80 -24
- package/common/api/WebSocketAPI.d.ts.map +1 -1
- package/common/api/WebSocketAPI.js +28 -16
- package/common/controls/{Control.d.ts → ControlCommon.d.ts} +21 -19
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/{Control.js → ControlCommon.js} +21 -8
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +54 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/{mixins/StopFinderMixin.js → controls/StopFinderControlCommon.js} +25 -38
- package/common/layers/{Layer.d.ts → LayerCommon.d.ts} +34 -21
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/{Layer.js → LayerCommon.js} +15 -9
- package/common/mixins/RealtimeLayerMixin.d.ts +243 -19
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
- package/common/mixins/RealtimeLayerMixin.js +598 -569
- package/common/mixins/UserInteractionsLayerMixin.d.ts +18 -8
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -1
- package/common/mixins/UserInteractionsLayerMixin.js +170 -159
- package/common/styles/realtimeDefaultStyle.d.ts +30 -9
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -1
- package/common/styles/realtimeDefaultStyle.js +41 -17
- package/common/styles/realtimeDelayStyle.d.ts +3 -2
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -1
- package/common/styles/realtimeSimpleStyle.d.ts +1 -1
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -1
- package/common/styles/realtimeSimpleStyle.js +9 -7
- package/common/typedefs.d.ts +64 -3
- package/common/typedefs.d.ts.map +1 -1
- package/common/typedefs.js +34 -4
- package/common/utils/cleanStopTime.d.ts +3 -2
- package/common/utils/cleanStopTime.d.ts.map +1 -1
- package/common/utils/cleanStopTime.js +0 -3
- package/common/utils/compareDepartures.d.ts +6 -4
- package/common/utils/compareDepartures.d.ts.map +1 -1
- package/common/utils/compareDepartures.js +3 -2
- package/common/utils/createCanvas.d.ts +3 -2
- package/common/utils/createCanvas.d.ts.map +1 -1
- package/common/utils/createTrackerFilters.d.ts +3 -2
- package/common/utils/createTrackerFilters.d.ts.map +1 -1
- package/common/utils/createTrackerFilters.js +3 -3
- package/common/utils/getLayersAsFlatArray.d.ts +1 -1
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -1
- package/common/utils/getLayersAsFlatArray.js +1 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +13 -3
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -1
- package/common/utils/getMapboxMapCopyrights.js +10 -4
- package/common/utils/getMapboxRender.d.ts +3 -1
- package/common/utils/getMapboxRender.d.ts.map +1 -1
- package/common/utils/getMapboxRender.js +1 -2
- package/common/utils/getVehiclePosition.d.ts +1 -1
- package/common/utils/getVehiclePosition.d.ts.map +1 -1
- package/common/utils/removeDuplicate.d.ts +2 -2
- package/common/utils/removeDuplicate.d.ts.map +1 -1
- package/common/utils/renderTrajectories.d.ts +3 -6
- package/common/utils/renderTrajectories.d.ts.map +1 -1
- package/common/utils/renderTrajectories.js +17 -8
- package/common/utils/trackerConfig.d.ts.map +1 -1
- package/common/utils/trackerConfig.js +3 -0
- package/mapbox/controls/CopyrightControl.d.ts +6 -8
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -1
- package/mapbox/controls/CopyrightControl.js +3 -8
- package/mapbox/layers/Layer.js +1 -1
- package/mapbox/layers/RealtimeLayer.d.ts +1 -1
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -1
- package/mapbox/utils.d.ts +1 -1
- package/mapbox/utils.d.ts.map +1 -1
- package/mbt.js +824 -702
- package/mbt.js.map +3 -3
- package/mbt.min.js +84 -84
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.d.ts +10 -10
- package/ol/controls/CopyrightControl.d.ts.map +1 -1
- package/ol/controls/CopyrightControl.js +8 -8
- package/ol/controls/RoutingControl.d.ts +10 -3
- package/ol/controls/RoutingControl.d.ts.map +1 -1
- package/ol/controls/RoutingControl.js +2 -2
- package/ol/controls/StopFinderControl.d.ts +5 -7
- package/ol/controls/StopFinderControl.d.ts.map +1 -1
- package/ol/controls/StopFinderControl.js +4 -8
- package/ol/layers/Layer.d.ts +57 -9
- package/ol/layers/Layer.d.ts.map +1 -1
- package/ol/layers/Layer.js +17 -8
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/{common/mixins/MapboxLayerMixin.js → ol/layers/MapGlLayer.js} +66 -44
- package/ol/layers/MapboxLayer.d.ts +15 -17
- package/ol/layers/MapboxLayer.d.ts.map +1 -1
- package/ol/layers/MapboxLayer.js +10 -7
- package/ol/layers/MapboxStyleLayer.d.ts +6 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -1
- package/ol/layers/MaplibreLayer.d.ts +4 -4
- package/ol/layers/MaplibreLayer.d.ts.map +1 -1
- package/ol/layers/MaplibreLayer.js +2 -3
- package/ol/layers/RealtimeLayer.d.ts +106 -30
- package/ol/layers/RealtimeLayer.d.ts.map +1 -1
- package/ol/layers/RealtimeLayer.js +22 -14
- package/ol/styles/fullTrajectoryStyle.d.ts +3 -2
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
- package/package.json +15 -9
- package/types/common.d.ts +111 -0
- package/types/index.d.ts +1 -0
- package/types/realtime.d.ts +290 -9
- package/api/RealtimeAPI.test.d.ts +0 -2
- package/api/RealtimeAPI.test.d.ts.map +0 -1
- package/api/RealtimeAPI.test.js +0 -67
- package/api/RoutingAPI.test.d.ts +0 -2
- package/api/RoutingAPI.test.d.ts.map +0 -1
- package/api/RoutingAPI.test.js +0 -29
- package/api/StopsAPI.test.d.ts +0 -2
- package/api/StopsAPI.test.d.ts.map +0 -1
- package/api/StopsAPI.test.js +0 -26
- package/common/api/HttpAPI.test.d.ts +0 -2
- package/common/api/HttpAPI.test.d.ts.map +0 -1
- package/common/api/HttpAPI.test.js +0 -54
- package/common/api/WebSocketAPI.test.d.ts +0 -2
- package/common/api/WebSocketAPI.test.d.ts.map +0 -1
- package/common/api/WebSocketAPI.test.js +0 -380
- package/common/controls/Control.d.ts.map +0 -1
- package/common/controls/Control.test.d.ts +0 -2
- package/common/controls/Control.test.d.ts.map +0 -1
- package/common/controls/Control.test.js +0 -89
- package/common/layers/Layer.d.ts.map +0 -1
- package/common/layers/Layer.test.d.ts +0 -2
- package/common/layers/Layer.test.d.ts.map +0 -1
- package/common/layers/Layer.test.js +0 -137
- package/common/mixins/CopyrightMixin.d.ts +0 -22
- package/common/mixins/CopyrightMixin.d.ts.map +0 -1
- package/common/mixins/CopyrightMixin.js +0 -43
- package/common/mixins/MapboxLayerMixin.d.ts +0 -27
- package/common/mixins/MapboxLayerMixin.d.ts.map +0 -1
- package/common/mixins/StopFinderMixin.d.ts +0 -40
- package/common/mixins/StopFinderMixin.d.ts.map +0 -1
- package/common/mixins/UserInteractionsLayerMixin.test.d.ts +0 -2
- package/common/mixins/UserInteractionsLayerMixin.test.d.ts.map +0 -1
- package/common/mixins/UserInteractionsLayerMixin.test.js +0 -214
- package/common/utils/createTrackerFilters.test.d.ts +0 -2
- package/common/utils/createTrackerFilters.test.d.ts.map +0 -1
- package/common/utils/createTrackerFilters.test.js +0 -79
- package/common/utils/getMapboxMapCopyrights.test.d.ts +0 -2
- package/common/utils/getMapboxMapCopyrights.test.d.ts.map +0 -1
- package/common/utils/getMapboxMapCopyrights.test.js +0 -40
- package/common/utils/removeDuplicate.test.d.ts +0 -2
- package/common/utils/removeDuplicate.test.d.ts.map +0 -1
- package/common/utils/removeDuplicate.test.js +0 -19
- package/common/utils/timeUtils.test.d.ts +0 -2
- package/common/utils/timeUtils.test.d.ts.map +0 -1
- package/common/utils/timeUtils.test.js +0 -10
- package/common/utils/trackerConfig.test.d.ts +0 -2
- package/common/utils/trackerConfig.test.d.ts.map +0 -1
- package/common/utils/trackerConfig.test.js +0 -23
- package/mapbox/layers/Layer.test.d.ts +0 -2
- package/mapbox/layers/Layer.test.d.ts.map +0 -1
- package/mapbox/layers/Layer.test.js +0 -204
- package/mapbox/layers/RealtimeLayer.test.d.ts +0 -2
- package/mapbox/layers/RealtimeLayer.test.d.ts.map +0 -1
- package/mapbox/layers/RealtimeLayer.test.js +0 -10
- package/ol/controls/CopyrightControl.test.d.ts +0 -2
- package/ol/controls/CopyrightControl.test.d.ts.map +0 -1
- package/ol/controls/CopyrightControl.test.js +0 -177
- package/ol/controls/RoutingControl.test.d.ts +0 -2
- package/ol/controls/RoutingControl.test.d.ts.map +0 -1
- package/ol/controls/RoutingControl.test.js +0 -150
- package/ol/controls/StopFinderControl.test.d.ts +0 -2
- package/ol/controls/StopFinderControl.test.d.ts.map +0 -1
- package/ol/controls/StopFinderControl.test.js +0 -49
- package/ol/layers/Layer.test.d.ts +0 -2
- package/ol/layers/Layer.test.d.ts.map +0 -1
- package/ol/layers/Layer.test.js +0 -196
- package/ol/layers/MapboxLayer.test.d.ts +0 -2
- package/ol/layers/MapboxLayer.test.d.ts.map +0 -1
- package/ol/layers/MapboxLayer.test.js +0 -164
- package/ol/layers/MapboxStyleLayer.test.d.ts +0 -2
- package/ol/layers/MapboxStyleLayer.test.d.ts.map +0 -1
- package/ol/layers/MapboxStyleLayer.test.js +0 -232
- package/ol/layers/RealtimeLayer.test.d.ts +0 -2
- package/ol/layers/RealtimeLayer.test.d.ts.map +0 -1
- package/ol/layers/RealtimeLayer.test.js +0 -71
- package/ol/layers/RoutingLayer.test.d.ts +0 -2
- package/ol/layers/RoutingLayer.test.d.ts.map +0 -1
- package/ol/layers/RoutingLayer.test.js +0 -39
- package/ol/layers/VectorLayer.test.d.ts +0 -2
- package/ol/layers/VectorLayer.test.d.ts.map +0 -1
- package/ol/layers/VectorLayer.test.js +0 -87
- package/ol/layers/WMSLayer.test.d.ts +0 -2
- package/ol/layers/WMSLayer.test.d.ts.map +0 -1
- package/ol/layers/WMSLayer.test.js +0 -66
package/api/StopsAPI.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StopsAPI.d.ts","sourceRoot":"","sources":["../../src/api/StopsAPI.
|
|
1
|
+
{"version":3,"file":"StopsAPI.d.ts","sourceRoot":"","sources":["../../src/api/StopsAPI.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE1D,oBAAY,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,cAAM,QAAS,SAAQ,OAAO;IAC5B;;;;;;OAMG;gBACS,OAAO,GAAE,eAAoB;IAIzC;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAG7E;AAED,eAAe,QAAQ,CAAC"}
|
package/api/StopsAPI.js
CHANGED
|
@@ -15,7 +15,7 @@ class StopsAPI extends HttpAPI {
|
|
|
15
15
|
/**
|
|
16
16
|
* Constructor
|
|
17
17
|
*
|
|
18
|
-
* @param {
|
|
18
|
+
* @param {StopsAPIOptions} options Options.
|
|
19
19
|
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Service url.
|
|
20
20
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
21
21
|
*/
|
|
@@ -23,16 +23,14 @@ class StopsAPI extends HttpAPI {
|
|
|
23
23
|
super(Object.assign({ url: 'https://api.geops.io/stops/v1/' }, options));
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Search.
|
|
26
|
+
* Search fo stops.
|
|
27
27
|
*
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
30
|
-
* @return {Promise<
|
|
28
|
+
* @param {StopsParameters} params Request parameters. See [Stops service documentation](https://developer.geops.io/apis/stops).
|
|
29
|
+
* @param {RequestInit} config Options for the fetch request.
|
|
30
|
+
* @return {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
31
31
|
*/
|
|
32
|
-
search(params,
|
|
33
|
-
return this.fetch('', params,
|
|
34
|
-
signal: abortController.signal,
|
|
35
|
-
});
|
|
32
|
+
search(params, config) {
|
|
33
|
+
return this.fetch('', params, config);
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
export default StopsAPI;
|
package/api/typedefs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export default dummy;
|
|
2
|
+
export type Departure = {
|
|
2
3
|
/**
|
|
3
4
|
* Timestamp in ms.
|
|
4
5
|
*/
|
|
@@ -53,8 +54,8 @@ type Departure = {
|
|
|
53
54
|
*/
|
|
54
55
|
timediff: number;
|
|
55
56
|
};
|
|
56
|
-
type Station = GeoJSONFeature;
|
|
57
|
-
type StationProperties = {
|
|
57
|
+
export type Station = GeoJSONFeature;
|
|
58
|
+
export type StationProperties = {
|
|
58
59
|
transfers: Transfer[];
|
|
59
60
|
elevatorOutOfOrder: boolean;
|
|
60
61
|
uic: number;
|
|
@@ -65,7 +66,7 @@ type StationProperties = {
|
|
|
65
66
|
hasAccessibility: boolean;
|
|
66
67
|
type: string;
|
|
67
68
|
};
|
|
68
|
-
type NetworkLine = {
|
|
69
|
+
export type NetworkLine = {
|
|
69
70
|
/**
|
|
70
71
|
* Identifier of the line.
|
|
71
72
|
*/
|
|
@@ -87,7 +88,7 @@ type NetworkLine = {
|
|
|
87
88
|
*/
|
|
88
89
|
text_color: string;
|
|
89
90
|
};
|
|
90
|
-
type Transfer = {
|
|
91
|
+
export type Transfer = {
|
|
91
92
|
/**
|
|
92
93
|
* Mode of transportation (ex: U-Bahn).
|
|
93
94
|
*/
|
|
@@ -97,9 +98,82 @@ type Transfer = {
|
|
|
97
98
|
*/
|
|
98
99
|
lines: string[];
|
|
99
100
|
};
|
|
100
|
-
type StopSequence = GeoJSONFeature;
|
|
101
|
-
type RealtimeTrajectory = GeoJSONFeature;
|
|
102
|
-
type FullTrajectory = GeoJSONFeature;
|
|
103
|
-
type Vehicle = GeoJSONFeature;
|
|
104
|
-
type ExtraGeom = GeoJSONFeature;
|
|
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;
|
|
105
179
|
//# sourceMappingURL=typedefs.d.ts.map
|
package/api/typedefs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../../src/api/typedefs.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../../src/api/typedefs.js"],"names":[],"mappings":";;;;;UAEc,MAAM;qBACN,OAAO;kBACP,MAAM;QACN,MAAM,EAAE;;;;oBACR,MAAM;;;;gBACN,MAAM;YACN,OAAO;;;;sBACP,MAAM;;;;qBACN,MAAM,EAAE;;;;wBACR,MAAM;UACN,WAAW;;;;aACX,OAAO;cACP,MAAM;cACN,MAAM;;;;;wBAEN,MAAM;;;gBAGN,MAAM;aACN,MAAM;;;;gBACN,MAAM;sBACN,MAAM;;;;cACN,MAAM;;;;eAYN,QAAQ,EAAE;wBACV,OAAO;SACP,MAAM;UACN,MAAM;kBACN,WAAW,EAAE;iBACb,OAAO;YACP,OAAO;sBACP,OAAO;UACP,MAAM;;;;;;QAKN,MAAM;;;;WACN,MAAM;;;;YACN,MAAM;;;;UACN,MAAM;;;;gBACN,MAAM;;;;;;SAKN,MAAM;;;;WACN,MAAM,EAAE;;;;;;;AA3DtB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;GAOG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAGH,+BAAsB"}
|
package/api/typedefs.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @typedef {Object} Departure
|
|
4
3
|
* @property {number} time Timestamp in ms.
|
|
@@ -71,3 +70,6 @@
|
|
|
71
70
|
/**
|
|
72
71
|
* @typedef {GeoJSONFeature} ExtraGeom
|
|
73
72
|
*/
|
|
73
|
+
// These lines is to block TypeScript to add "use strict;" in the outputed file.
|
|
74
|
+
const dummy = () => { };
|
|
75
|
+
export default dummy;
|
|
@@ -1,59 +1,116 @@
|
|
|
1
|
-
|
|
1
|
+
import { Feature } from 'geojson';
|
|
2
|
+
import { RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrajectory, RealtimeTrajectoryResponse, RealtimeStopSequence, RealtimeFullTrajectory } from '../../types';
|
|
3
|
+
export declare type WebSocketAPIParameters = {
|
|
4
|
+
channel?: string;
|
|
5
|
+
args?: string | number;
|
|
6
|
+
id?: string | number;
|
|
7
|
+
};
|
|
8
|
+
export declare type WebSocketAPIMessageEventData = {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
source: string;
|
|
11
|
+
content: string | Feature | RealtimeTrajectoryResponse[] | RealtimeDeparture | RealtimeNews[] | RealtimeStation | RealtimeExtraGeom | RealtimeTrajectory | RealtimeStopSequence[] | RealtimeFullTrajectory;
|
|
12
|
+
client_reference: string | number | null;
|
|
13
|
+
};
|
|
14
|
+
export declare type WebSocketAPIBufferMessageEventData = Omit<WebSocketAPIMessageEventData, 'content'> & {
|
|
15
|
+
source: 'buffer';
|
|
16
|
+
content: Array<WebSocketAPIMessageEventData>;
|
|
17
|
+
};
|
|
18
|
+
export declare type WebSocketAPIMessageEvent = Event & {
|
|
19
|
+
data: string;
|
|
20
|
+
};
|
|
21
|
+
export interface WebSocketAPIMessageEventListener {
|
|
22
|
+
(evt: WebSocketAPIMessageEvent): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* This type represents a function that has been call with each feature returned by the websocket.
|
|
26
|
+
*/
|
|
27
|
+
export interface WebSocketAPIDataCallback {
|
|
28
|
+
(data: WebSocketAPIMessageEventData): void;
|
|
29
|
+
}
|
|
30
|
+
export declare type WebSocketAPISubscription = {
|
|
31
|
+
params: WebSocketAPIParameters;
|
|
32
|
+
cb: WebSocketAPIDataCallback;
|
|
33
|
+
errorCb?: EventListener;
|
|
34
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
35
|
+
onErrorCb?: EventListener;
|
|
36
|
+
quiet: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare type WebSocketAPISubscribed = {
|
|
39
|
+
[index: string]: boolean;
|
|
40
|
+
};
|
|
41
|
+
export declare type WebSocketAPIRequest = {
|
|
42
|
+
params: WebSocketAPIParameters;
|
|
43
|
+
cb: WebSocketAPIDataCallback;
|
|
44
|
+
errorCb?: EventListener;
|
|
45
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
46
|
+
onErrorCb?: EventListener;
|
|
47
|
+
requestString: String;
|
|
48
|
+
};
|
|
2
49
|
/**
|
|
3
|
-
* Class used to facilitate connection to a
|
|
4
|
-
* also to manage properly messages send to the
|
|
50
|
+
* Class used to facilitate connection to a WebSocketAPI and
|
|
51
|
+
* also to manage properly messages send to the WebSocketAPI.
|
|
5
52
|
* This class must not contain any specific implementation.
|
|
6
53
|
*/
|
|
7
54
|
declare class WebSocketAPI {
|
|
55
|
+
websocket?: WebSocket;
|
|
56
|
+
closed?: boolean;
|
|
57
|
+
closing?: boolean;
|
|
58
|
+
connecting?: boolean;
|
|
59
|
+
open?: boolean;
|
|
60
|
+
messagesOnOpen: Array<string>;
|
|
61
|
+
subscriptions: Array<WebSocketAPISubscription>;
|
|
62
|
+
subscribed: WebSocketAPISubscribed;
|
|
63
|
+
requests: Array<WebSocketAPIRequest>;
|
|
64
|
+
constructor();
|
|
65
|
+
defineProperties(): void;
|
|
8
66
|
/**
|
|
9
67
|
* Get the websocket request string.
|
|
10
68
|
*
|
|
11
69
|
* @param {string} method Request mehtod {GET, SUB}.
|
|
12
|
-
* @param {
|
|
70
|
+
* @param {WebSocketParameters} params Request parameters.
|
|
13
71
|
* @param {string} params.channel Channel name
|
|
14
72
|
* @param {string} [params.args] Request arguments
|
|
15
|
-
* @param {Number} [params.id] Request identifier
|
|
73
|
+
* @param {Number|string} [params.id] Request identifier
|
|
16
74
|
* @return {string} request string
|
|
17
75
|
* @private
|
|
18
76
|
*/
|
|
19
|
-
|
|
20
|
-
defineProperties(): void;
|
|
77
|
+
static getRequestString(method: string, params?: WebSocketAPIParameters): string;
|
|
21
78
|
/**
|
|
22
79
|
* (Re)connect the websocket.
|
|
23
80
|
*
|
|
24
|
-
* @param {
|
|
81
|
+
* @param {string} url Websocket url.
|
|
25
82
|
* @param {function} onOpen Callback called when the websocket connection is opened and before subscriptions of previous subscriptions.
|
|
26
83
|
* @private
|
|
27
84
|
*/
|
|
28
|
-
|
|
29
|
-
/** @ignore */
|
|
30
|
-
websocket: WebSocket | null | undefined;
|
|
85
|
+
connect(url: string, onOpen?: () => void): void;
|
|
31
86
|
/**
|
|
32
87
|
* Close the websocket definitively.
|
|
33
88
|
*
|
|
34
89
|
* @private
|
|
35
90
|
*/
|
|
36
|
-
|
|
37
|
-
messagesOnOpen: any[] | undefined;
|
|
91
|
+
close(): void;
|
|
38
92
|
/**
|
|
39
93
|
* Sends a message to the websocket.
|
|
40
94
|
*
|
|
41
95
|
* @param {message} message Message to send.
|
|
42
96
|
* @private
|
|
43
97
|
*/
|
|
44
|
-
|
|
45
|
-
addEvents(onMessage:
|
|
46
|
-
removeEvents(onMessage:
|
|
98
|
+
send(message: string): void;
|
|
99
|
+
addEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
100
|
+
removeEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
47
101
|
/**
|
|
48
102
|
* Listen to websocket messages.
|
|
49
103
|
*
|
|
50
|
-
* @param {
|
|
104
|
+
* @param {WebSocketParameters} params Parameters for the websocket get request
|
|
51
105
|
* @param {function} cb callback on listen
|
|
52
106
|
* @param {function} errorCb Callback on error
|
|
53
107
|
* @return {{onMessage: function, errorCb: function}} Object with onMessage and error callbacks
|
|
54
108
|
* @private
|
|
55
109
|
*/
|
|
56
|
-
|
|
110
|
+
listen(params: WebSocketAPIParameters, cb: WebSocketAPIDataCallback, errorCb?: EventListener): {
|
|
111
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
112
|
+
onErrorCb?: EventListener;
|
|
113
|
+
};
|
|
57
114
|
/**
|
|
58
115
|
* Unlisten websocket messages.
|
|
59
116
|
*
|
|
@@ -61,7 +118,7 @@ declare class WebSocketAPI {
|
|
|
61
118
|
* @param {function} cb Callback used when listen.
|
|
62
119
|
* @private
|
|
63
120
|
*/
|
|
64
|
-
|
|
121
|
+
unlisten(params: WebSocketAPIParameters, cb: WebSocketAPIDataCallback): void;
|
|
65
122
|
/**
|
|
66
123
|
* Sends a get request to the websocket.
|
|
67
124
|
* The callback is called only once, when the response is received or when the call returns an error.
|
|
@@ -71,8 +128,7 @@ declare class WebSocketAPI {
|
|
|
71
128
|
* @param {function} onError Callback on error and close event
|
|
72
129
|
* @private
|
|
73
130
|
*/
|
|
74
|
-
|
|
75
|
-
requests: any[] | undefined;
|
|
131
|
+
get(params: WebSocketAPIParameters, cb: WebSocketAPIDataCallback, errorCb?: EventListener): void;
|
|
76
132
|
/**
|
|
77
133
|
* Subscribe to a given channel.
|
|
78
134
|
*
|
|
@@ -82,18 +138,18 @@ declare class WebSocketAPI {
|
|
|
82
138
|
* @param {boolean} quiet if false, no GET or SUB requests are send, only the callback is registered.
|
|
83
139
|
* @private
|
|
84
140
|
*/
|
|
85
|
-
|
|
141
|
+
subscribe(params: WebSocketAPIParameters, cb: WebSocketAPIDataCallback, errorCb?: EventListener, quiet?: boolean): void;
|
|
86
142
|
/**
|
|
87
143
|
* Unsubscribe from a channel.
|
|
88
144
|
* @param {string} source source to unsubscribe from
|
|
89
145
|
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
90
146
|
* @private
|
|
91
147
|
*/
|
|
92
|
-
|
|
93
|
-
subscriptions: any;
|
|
148
|
+
unsubscribe(source: string, cb?: WebSocketAPIDataCallback): void;
|
|
94
149
|
/**
|
|
95
150
|
* After an auto reconnection we need to re-subscribe to the channels.
|
|
96
151
|
*/
|
|
97
152
|
subscribePreviousSubscriptions(): void;
|
|
98
153
|
}
|
|
154
|
+
export default WebSocketAPI;
|
|
99
155
|
//# sourceMappingURL=WebSocketAPI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocketAPI.d.ts","sourceRoot":"","sources":["../../../src/common/api/WebSocketAPI.
|
|
1
|
+
{"version":3,"file":"WebSocketAPI.d.ts","sourceRoot":"","sources":["../../../src/common/api/WebSocketAPI.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Class used to facilitate connection to a
|
|
3
|
-
* also to manage properly messages send to the
|
|
2
|
+
* Class used to facilitate connection to a WebSocketAPI and
|
|
3
|
+
* also to manage properly messages send to the WebSocketAPI.
|
|
4
4
|
* This class must not contain any specific implementation.
|
|
5
5
|
*/
|
|
6
6
|
class WebSocketAPI {
|
|
@@ -35,7 +35,7 @@ class WebSocketAPI {
|
|
|
35
35
|
},
|
|
36
36
|
/**
|
|
37
37
|
* Array of subscriptions.
|
|
38
|
-
* @type {Array<
|
|
38
|
+
* @type {Array<WebSocketSubscription>}
|
|
39
39
|
* @private
|
|
40
40
|
*/
|
|
41
41
|
subscriptions: {
|
|
@@ -44,7 +44,7 @@ class WebSocketAPI {
|
|
|
44
44
|
},
|
|
45
45
|
/**
|
|
46
46
|
* List of channels subscribed.
|
|
47
|
-
* @type {
|
|
47
|
+
* @type {WebSocketSubscribed}
|
|
48
48
|
* @private
|
|
49
49
|
*/
|
|
50
50
|
subscribed: {
|
|
@@ -57,14 +57,14 @@ class WebSocketAPI {
|
|
|
57
57
|
* Get the websocket request string.
|
|
58
58
|
*
|
|
59
59
|
* @param {string} method Request mehtod {GET, SUB}.
|
|
60
|
-
* @param {
|
|
60
|
+
* @param {WebSocketParameters} params Request parameters.
|
|
61
61
|
* @param {string} params.channel Channel name
|
|
62
62
|
* @param {string} [params.args] Request arguments
|
|
63
|
-
* @param {Number} [params.id] Request identifier
|
|
63
|
+
* @param {Number|string} [params.id] Request identifier
|
|
64
64
|
* @return {string} request string
|
|
65
65
|
* @private
|
|
66
66
|
*/
|
|
67
|
-
static getRequestString(method, params) {
|
|
67
|
+
static getRequestString(method, params = {}) {
|
|
68
68
|
let reqStr = `${method} ${params.channel}`;
|
|
69
69
|
reqStr += params.args ? ` ${params.args}` : '';
|
|
70
70
|
reqStr += params.id ? ` ${params.id}` : '';
|
|
@@ -73,7 +73,7 @@ class WebSocketAPI {
|
|
|
73
73
|
/**
|
|
74
74
|
* (Re)connect the websocket.
|
|
75
75
|
*
|
|
76
|
-
* @param {
|
|
76
|
+
* @param {string} url Websocket url.
|
|
77
77
|
* @param {function} onOpen Callback called when the websocket connection is opened and before subscriptions of previous subscriptions.
|
|
78
78
|
* @private
|
|
79
79
|
*/
|
|
@@ -103,7 +103,7 @@ class WebSocketAPI {
|
|
|
103
103
|
if (this.websocket) {
|
|
104
104
|
this.websocket.onclose = null;
|
|
105
105
|
this.websocket.close();
|
|
106
|
-
this.websocket =
|
|
106
|
+
this.websocket = undefined;
|
|
107
107
|
this.messagesOnOpen = [];
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -118,7 +118,8 @@ class WebSocketAPI {
|
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
const send = () => {
|
|
121
|
-
|
|
121
|
+
var _a;
|
|
122
|
+
(_a = this.websocket) === null || _a === void 0 ? void 0 : _a.send(message);
|
|
122
123
|
};
|
|
123
124
|
if (!this.open) {
|
|
124
125
|
// This 'if' avoid sending 2 identical BBOX message on open,
|
|
@@ -158,7 +159,7 @@ class WebSocketAPI {
|
|
|
158
159
|
/**
|
|
159
160
|
* Listen to websocket messages.
|
|
160
161
|
*
|
|
161
|
-
* @param {
|
|
162
|
+
* @param {WebSocketParameters} params Parameters for the websocket get request
|
|
162
163
|
* @param {function} cb callback on listen
|
|
163
164
|
* @param {function} errorCb Callback on error
|
|
164
165
|
* @return {{onMessage: function, errorCb: function}} Object with onMessage and error callbacks
|
|
@@ -166,21 +167,29 @@ class WebSocketAPI {
|
|
|
166
167
|
*/
|
|
167
168
|
listen(params, cb, errorCb) {
|
|
168
169
|
// Remove the previous identical callback
|
|
169
|
-
this.unlisten(params, cb
|
|
170
|
+
this.unlisten(params, cb);
|
|
170
171
|
// We wrap the message callback to be sure we only propagate the message if it is for the right channel.
|
|
171
172
|
const onMessage = (evt) => {
|
|
172
|
-
let data
|
|
173
|
+
let data;
|
|
173
174
|
try {
|
|
174
175
|
data = JSON.parse(evt.data);
|
|
175
176
|
}
|
|
176
177
|
catch (err) {
|
|
177
178
|
// eslint-disable-next-line no-console
|
|
178
179
|
console.error('WebSocket: unable to parse JSON data', err, evt.data);
|
|
180
|
+
return;
|
|
179
181
|
}
|
|
180
182
|
let source = params.channel;
|
|
181
183
|
source += params.args ? ` ${params.args}` : '';
|
|
182
184
|
// Buffer channel message return a list of other channels to propagate to proper callbacks.
|
|
183
|
-
|
|
185
|
+
let contents;
|
|
186
|
+
if (data.source === 'buffer') {
|
|
187
|
+
contents = data
|
|
188
|
+
.content;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
contents = [data];
|
|
192
|
+
}
|
|
184
193
|
contents.forEach((content) => {
|
|
185
194
|
// Because of backend optimization, the last content is null.
|
|
186
195
|
if ((content === null || content === void 0 ? void 0 : content.source) === source &&
|
|
@@ -219,14 +228,17 @@ class WebSocketAPI {
|
|
|
219
228
|
const requestString = WebSocketAPI.getRequestString('GET', params);
|
|
220
229
|
this.send(requestString);
|
|
221
230
|
// We wrap the callbacks to make sure they are called only once.
|
|
222
|
-
const once = (callback) =>
|
|
231
|
+
const once = (callback) =>
|
|
232
|
+
// @ts-ignore: Spread error
|
|
233
|
+
(...args) => {
|
|
234
|
+
// @ts-ignore: Spread error
|
|
223
235
|
callback(...args);
|
|
224
236
|
const index = this.requests.findIndex((request) => requestString === request.requestString && cb === request.cb);
|
|
225
237
|
const { onMessageCb, onErrorCb } = this.requests[index];
|
|
226
238
|
this.removeEvents(onMessageCb, onErrorCb);
|
|
227
239
|
this.requests.splice(index, 1);
|
|
228
240
|
};
|
|
229
|
-
const { onMessageCb, onErrorCb } = this.listen(params, once(cb), once(errorCb));
|
|
241
|
+
const { onMessageCb, onErrorCb } = this.listen(params, once(cb), errorCb && once(errorCb));
|
|
230
242
|
// Store requests and callbacks to be able to remove them.
|
|
231
243
|
if (!this.requests) {
|
|
232
244
|
this.requests = [];
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import BaseObject from 'ol/Object';
|
|
2
|
+
import { AnyMap } from '../../types';
|
|
3
|
+
export declare type ControlCommonOptions = {
|
|
4
|
+
active?: Boolean;
|
|
5
|
+
element?: HTMLElement;
|
|
6
|
+
target?: HTMLElement;
|
|
7
|
+
render?: () => void;
|
|
8
|
+
};
|
|
2
9
|
/**
|
|
3
10
|
* A class representing a control to display on map.
|
|
4
11
|
*
|
|
@@ -10,7 +17,11 @@ export default Control;
|
|
|
10
17
|
* @classproperty {HTMLElement} element - The HTML element used to render the control.
|
|
11
18
|
* @classproperty {HTMLElement} target - The HTML element where to render the element property. Default is the map's element. Read only.
|
|
12
19
|
*/
|
|
13
|
-
declare class
|
|
20
|
+
declare class ControlCommon extends BaseObject {
|
|
21
|
+
active: Boolean;
|
|
22
|
+
map?: AnyMap;
|
|
23
|
+
target?: HTMLElement;
|
|
24
|
+
element?: HTMLElement;
|
|
14
25
|
/**
|
|
15
26
|
* Constructor
|
|
16
27
|
*
|
|
@@ -20,27 +31,18 @@ declare class Control extends BaseObject {
|
|
|
20
31
|
* @param {HTMLElement} [options.target] The HTML element where to render the element property. Default is the map's element.
|
|
21
32
|
* @param {function} [options.render] Render function called whenever the control needs to be rerendered.
|
|
22
33
|
*/
|
|
23
|
-
constructor(options?:
|
|
24
|
-
active?: boolean | undefined;
|
|
25
|
-
element?: HTMLElement | undefined;
|
|
26
|
-
target?: HTMLElement | undefined;
|
|
27
|
-
render?: Function | undefined;
|
|
28
|
-
} | undefined);
|
|
29
|
-
/**
|
|
30
|
-
* @ignore
|
|
31
|
-
*/
|
|
32
|
-
active: boolean;
|
|
34
|
+
constructor(options?: ControlCommonOptions);
|
|
33
35
|
/**
|
|
34
36
|
* Define control's properties.
|
|
35
37
|
*
|
|
36
38
|
* @private
|
|
39
|
+
* @ignore
|
|
37
40
|
*/
|
|
38
|
-
|
|
41
|
+
defineProperties(options: ControlCommonOptions): void;
|
|
39
42
|
/**
|
|
40
43
|
* Attach the control to the map. Add events, html element ...
|
|
41
44
|
*/
|
|
42
|
-
attachToMap(map:
|
|
43
|
-
map: any;
|
|
45
|
+
attachToMap(map: AnyMap): void;
|
|
44
46
|
/**
|
|
45
47
|
* Detach the control From the map. Remove events, html element ..
|
|
46
48
|
*/
|
|
@@ -61,14 +63,14 @@ declare class Control extends BaseObject {
|
|
|
61
63
|
*
|
|
62
64
|
* @private
|
|
63
65
|
*/
|
|
64
|
-
|
|
66
|
+
render(options?: any): void;
|
|
65
67
|
/**
|
|
66
68
|
* The default element to display if this.element is not defined.
|
|
67
69
|
* To be defined in inherited classes.
|
|
68
70
|
*
|
|
69
71
|
* @private
|
|
70
72
|
*/
|
|
71
|
-
|
|
73
|
+
createDefaultElement(): void;
|
|
72
74
|
}
|
|
73
|
-
|
|
74
|
-
//# sourceMappingURL=
|
|
75
|
+
export default ControlCommon;
|
|
76
|
+
//# sourceMappingURL=ControlCommon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControlCommon.d.ts","sourceRoot":"","sources":["../../../src/common/controls/ControlCommon.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,oBAAY,oBAAoB,GAAG;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,cAAM,aAAc,SAAQ,UAAU;IACpC,MAAM,EAAE,OAAO,CAAC;IAEhB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB;;;;;;;;OAQG;gBACS,OAAO,GAAE,oBAAyB;IAe9C;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,oBAAoB;IAuE9C;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM;IAIvB;;OAEG;IACH,aAAa;IAIb;;;OAGG;IACH,QAAQ;IAIR;;;OAGG;IAEH,UAAU;IAKV;;;;;OAKG;IAEH,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG;IAKpB;;;;;OAKG;IAEH,oBAAoB;CAIrB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -10,7 +10,7 @@ import BaseObject from 'ol/Object';
|
|
|
10
10
|
* @classproperty {HTMLElement} element - The HTML element used to render the control.
|
|
11
11
|
* @classproperty {HTMLElement} target - The HTML element where to render the element property. Default is the map's element. Read only.
|
|
12
12
|
*/
|
|
13
|
-
class
|
|
13
|
+
class ControlCommon extends BaseObject {
|
|
14
14
|
/**
|
|
15
15
|
* Constructor
|
|
16
16
|
*
|
|
@@ -33,6 +33,7 @@ class Control extends BaseObject {
|
|
|
33
33
|
* Define control's properties.
|
|
34
34
|
*
|
|
35
35
|
* @private
|
|
36
|
+
* @ignore
|
|
36
37
|
*/
|
|
37
38
|
defineProperties(options) {
|
|
38
39
|
const { target, element, render } = Object.assign({}, options);
|
|
@@ -63,8 +64,10 @@ class Control extends BaseObject {
|
|
|
63
64
|
if (this.map) {
|
|
64
65
|
// Add new node
|
|
65
66
|
const targett = this.target ||
|
|
66
|
-
(this.map.getTargetElement &&
|
|
67
|
-
|
|
67
|
+
(this.map.getTargetElement &&
|
|
68
|
+
this.map.getTargetElement()) ||
|
|
69
|
+
(this.map.getContainer &&
|
|
70
|
+
this.map.getContainer());
|
|
68
71
|
if (!this.element) {
|
|
69
72
|
this.createDefaultElement();
|
|
70
73
|
}
|
|
@@ -103,7 +106,7 @@ class Control extends BaseObject {
|
|
|
103
106
|
* Detach the control From the map. Remove events, html element ..
|
|
104
107
|
*/
|
|
105
108
|
detachFromMap() {
|
|
106
|
-
this.map =
|
|
109
|
+
this.map = undefined;
|
|
107
110
|
}
|
|
108
111
|
/**
|
|
109
112
|
* Add listeners then renders the control.
|
|
@@ -117,14 +120,21 @@ class Control extends BaseObject {
|
|
|
117
120
|
* To be defined in inherited classes.
|
|
118
121
|
*/
|
|
119
122
|
// eslint-disable-next-line class-methods-use-this
|
|
120
|
-
deactivate() {
|
|
123
|
+
deactivate() {
|
|
124
|
+
// eslint-disable-next-line no-console
|
|
125
|
+
console.error('This function must be implemented in subclasses');
|
|
126
|
+
}
|
|
121
127
|
/**
|
|
122
128
|
* The default render function. It renders content in the HTML element.
|
|
123
129
|
* To be defined in inherited classes.
|
|
124
130
|
*
|
|
125
131
|
* @private
|
|
126
132
|
*/
|
|
127
|
-
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
134
|
+
render(options) {
|
|
135
|
+
// eslint-disable-next-line no-console
|
|
136
|
+
console.error('This function must be implemented in subclasses');
|
|
137
|
+
}
|
|
128
138
|
/**
|
|
129
139
|
* The default element to display if this.element is not defined.
|
|
130
140
|
* To be defined in inherited classes.
|
|
@@ -132,6 +142,9 @@ class Control extends BaseObject {
|
|
|
132
142
|
* @private
|
|
133
143
|
*/
|
|
134
144
|
// eslint-disable-next-line class-methods-use-this
|
|
135
|
-
createDefaultElement() {
|
|
145
|
+
createDefaultElement() {
|
|
146
|
+
// eslint-disable-next-line no-console
|
|
147
|
+
console.error('This function must be implemented in subclasses');
|
|
148
|
+
}
|
|
136
149
|
}
|
|
137
|
-
export default
|
|
150
|
+
export default ControlCommon;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ControlCommon from './ControlCommon';
|
|
2
|
+
/**
|
|
3
|
+
* A class representing a copyright control to display on map.
|
|
4
|
+
* This class only draw an html element, with an empty string in it.
|
|
5
|
+
* Use subclasses to use it in an ol or mapbox map.
|
|
6
|
+
*/
|
|
7
|
+
declare class CopyrightControlCommon extends ControlCommon {
|
|
8
|
+
render(): void;
|
|
9
|
+
createDefaultElement(): void;
|
|
10
|
+
getCopyrights(): string[];
|
|
11
|
+
}
|
|
12
|
+
export default CopyrightControlCommon;
|
|
13
|
+
//# sourceMappingURL=CopyrightControlCommon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyrightControlCommon.d.ts","sourceRoot":"","sources":["../../../src/common/controls/CopyrightControlCommon.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,cAAM,sBAAuB,SAAQ,aAAa;IAChD,MAAM;IASN,oBAAoB;IAYpB,aAAa;CAQd;AAED,eAAe,sBAAsB,CAAC"}
|