mobility-toolbox-js 2.0.1-beta.13 → 2.2.0-beta.0
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 +281 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +490 -0
- package/api/RoutingAPI.d.ts +37 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +32 -12
- package/api/StopsAPI.d.ts +38 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +33 -9
- package/api/index.d.ts +4 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +3 -3
- package/api/typedefs.d.ts +179 -0
- package/api/typedefs.d.ts.map +1 -0
- package/api/typedefs.js +75 -0
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +54 -27
- package/common/api/WebSocketAPI.d.ts +153 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +330 -164
- package/common/controls/ControlCommon.d.ts +76 -0
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/ControlCommon.js +150 -0
- 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 +55 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/controls/StopFinderControlCommon.js +144 -0
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/index.js +2 -4
- package/common/layers/LayerCommon.d.ts +94 -0
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/LayerCommon.js +244 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +286 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +779 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +241 -0
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/index.js +4 -4
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +275 -0
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +13 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
- package/common/styles/realtimeHeadingStyle.js +85 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -0
- package/common/typedefs.d.ts +111 -0
- package/common/typedefs.d.ts.map +1 -0
- package/common/typedefs.js +52 -0
- package/common/utils/compareDepartures.d.ts +11 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +35 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +27 -0
- package/common/utils/createRealtimeFilters.d.ts +13 -0
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/createRealtimeFilters.js +74 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
- package/common/utils/debounceDeparturesMessages.js +24 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
- package/common/utils/debounceWebsocketMessages.js +29 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +15 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +26 -15
- package/common/utils/getMapboxRender.d.ts +7 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +87 -0
- package/common/utils/getMaplibreRender.d.ts +7 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +38 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +7 -0
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +18 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +67 -37
- package/common/utils/index.d.ts +17 -0
- package/common/utils/index.d.ts.map +1 -0
- package/common/utils/index.js +17 -5
- package/common/utils/realtimeConfig.d.ts +49 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/realtimeConfig.js +173 -0
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +12 -5
- package/common/utils/renderTrajectories.d.ts +17 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +110 -0
- package/common/utils/sortAndFilterDepartures.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
- package/common/utils/sortAndFilterDepartures.js +58 -0
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +17 -15
- package/common/utils/timeUtils.d.ts +24 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +34 -15
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/iife.js +5 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +8 -6
- package/mapbox/controls/CopyrightControl.d.ts +29 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/mapbox/controls/CopyrightControl.js +44 -25
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/controls/index.js +2 -1
- package/mapbox/index.d.ts +6 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/index.js +5 -4
- package/mapbox/layers/Layer.d.ts +59 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +99 -55
- package/mapbox/layers/RealtimeLayer.d.ts +181 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +276 -0
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/layers/index.js +2 -2
- package/mapbox/utils/getMercatorResolution.d.ts +9 -0
- package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.js +18 -0
- package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
- package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
- package/mapbox/utils/getSourceCoordinates.js +27 -0
- package/mapbox/utils/index.d.ts +3 -0
- package/mapbox/utils/index.d.ts.map +1 -0
- package/mapbox/utils/index.js +2 -0
- package/mbt.js +26074 -16501
- package/mbt.js.map +4 -4
- package/mbt.min.js +205 -126
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +62 -36
- package/ol/controls/RoutingControl.d.ts +193 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +601 -357
- package/ol/controls/StopFinderControl.d.ts +30 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/ol/controls/StopFinderControl.js +30 -8
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/controls/index.js +3 -3
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/index.js +5 -5
- package/ol/layers/Layer.d.ts +86 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +163 -77
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/ol/layers/MapGlLayer.js +218 -0
- package/ol/layers/MapboxLayer.d.ts +50 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +99 -193
- package/ol/layers/MapboxStyleLayer.d.ts +129 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +362 -171
- package/ol/layers/MaplibreLayer.d.ts +28 -0
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +30 -135
- package/ol/layers/RealtimeLayer.d.ts +202 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +340 -0
- package/ol/layers/RoutingLayer.d.ts +34 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +72 -48
- package/ol/layers/VectorLayer.d.ts +25 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +34 -18
- package/ol/layers/WMSLayer.d.ts +42 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +84 -34
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/layers/index.js +8 -8
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +26 -24
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +40 -39
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/ol/styles/index.js +2 -2
- package/package.json +81 -133
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/setupTests.js +26 -0
- package/types/common.d.ts +122 -0
- package/types/index.d.ts +13 -0
- package/types/realtime.d.ts +320 -0
- package/types/routing.d.ts +206 -0
- package/types/stops.d.ts +143 -0
- package/README.md +0 -23
- package/api/RoutingAPI.test.js +0 -25
- package/api/StopsAPI.test.js +0 -22
- package/api/TralisAPI.js +0 -359
- package/api/TralisAPI.test.js +0 -67
- package/api/TralisAPIUtils.js +0 -43
- package/common/Tracker.js +0 -93
- package/common/api/HttpAPI.test.js +0 -50
- package/common/api/WebSocketAPI.test.js +0 -311
- package/common/controls/Control.js +0 -81
- package/common/controls/Control.test.js +0 -87
- package/common/layers/Layer.js +0 -213
- package/common/layers/Layer.test.js +0 -526
- package/common/mixins/CopyrightMixin.js +0 -24
- package/common/mixins/SearchMixin.js +0 -110
- package/common/mixins/TralisLayerMixin.js +0 -479
- package/common/styles/trackerDefaultStyle.js +0 -197
- package/common/styles/trackerDelayStyle.js +0 -8
- package/common/styles/trackerSimpleStyle.js +0 -18
- package/common/trackerConfig.js +0 -152
- package/common/trackerConfig.test.js +0 -23
- package/common/utils/createTrackerFilters.js +0 -56
- package/common/utils/createTrackerFilters.test.js +0 -79
- package/common/utils/getMapboxMapCopyrights.test.js +0 -40
- package/common/utils/getMapboxStyleUrl.js +0 -22
- package/common/utils/removeDuplicate.test.js +0 -19
- package/common/utils/timeUtils.test.js +0 -10
- package/mapbox/layers/Layer.test.js +0 -182
- package/mapbox/layers/TralisLayer.js +0 -182
- package/mapbox/layers/TralisLayer.test.js +0 -38
- package/mapbox/utils.js +0 -32
- package/ol/controls/CopyrightControl.test.js +0 -165
- package/ol/controls/RoutingControl.test.js +0 -151
- package/ol/controls/StopFinderControl.test.js +0 -48
- package/ol/layers/Layer.test.js +0 -174
- package/ol/layers/MapboxLayer.test.js +0 -160
- package/ol/layers/MapboxStyleLayer.test.js +0 -231
- package/ol/layers/RoutingLayer.test.js +0 -40
- package/ol/layers/TralisLayer.js +0 -185
- package/ol/layers/TralisLayer.test.js +0 -79
- package/ol/layers/VectorLayer.test.js +0 -87
- package/ol/layers/WMSLayer.test.js +0 -76
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Feature } from 'geojson';
|
|
2
|
+
import StopFinderControlCommon from '../../common/controls/StopFinderControlCommon';
|
|
3
|
+
/**
|
|
4
|
+
* Search stations.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import { Map } from 'ol';
|
|
8
|
+
* import { StopFinderControl } from 'mobility-toolbox-js/ol';
|
|
9
|
+
*
|
|
10
|
+
* const map = new Map({
|
|
11
|
+
* target: 'map',
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* const control = new StopFinderControl({
|
|
15
|
+
* apiKey: [yourApiKey]
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* control.attachToMap(map);
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* @see <a href="/example/ol-search">Openlayers search example</a>
|
|
22
|
+
*/
|
|
23
|
+
declare class StopFinderControl extends StopFinderControlCommon {
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
onSuggestionClick(suggestion: Feature): void;
|
|
28
|
+
}
|
|
29
|
+
export default StopFinderControl;
|
|
30
|
+
//# sourceMappingURL=StopFinderControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StopFinderControl.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/StopFinderControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,SAAS,CAAC;AAEzC,OAAO,uBAAuB,MAAM,+CAA+C,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAM,iBAAkB,SAAQ,uBAAuB;IACrD;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,OAAO;CAItC;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
import { fromLonLat } from
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { fromLonLat } from 'ol/proj';
|
|
2
|
+
import StopFinderControlCommon from '../../common/controls/StopFinderControlCommon';
|
|
3
|
+
/**
|
|
4
|
+
* Search stations.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import { Map } from 'ol';
|
|
8
|
+
* import { StopFinderControl } from 'mobility-toolbox-js/ol';
|
|
9
|
+
*
|
|
10
|
+
* const map = new Map({
|
|
11
|
+
* target: 'map',
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* const control = new StopFinderControl({
|
|
15
|
+
* apiKey: [yourApiKey]
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* control.attachToMap(map);
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* @see <a href="/example/ol-search">Openlayers search example</a>
|
|
22
|
+
*/
|
|
23
|
+
class StopFinderControl extends StopFinderControlCommon {
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
onSuggestionClick(suggestion) {
|
|
28
|
+
const coord = fromLonLat(suggestion.geometry.coordinates);
|
|
29
|
+
this.map.getView().setCenter(coord);
|
|
30
|
+
}
|
|
9
31
|
}
|
|
10
32
|
export default StopFinderControl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/index.js"],"names":[],"mappings":""}
|
package/ol/controls/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as CopyrightControl } from
|
|
2
|
-
export { default as RoutingControl } from
|
|
3
|
-
export { default as StopFinderControl } from
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ol/index.js"],"names":[],"mappings":""}
|
package/ol/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from '../api';
|
|
2
|
+
export * from '../common';
|
|
3
|
+
export * from './controls';
|
|
4
|
+
export * from './layers';
|
|
5
|
+
export * from './styles';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Map } from 'ol';
|
|
2
|
+
import { EventsKey } from 'ol/events';
|
|
3
|
+
import LayerGroup from 'ol/layer/Group';
|
|
4
|
+
import OlLayer from 'ol/layer/Layer';
|
|
5
|
+
import LayerCommon from '../../common/layers/LayerCommon';
|
|
6
|
+
import type { LayerCommonOptions } from '../../common/layers/LayerCommon';
|
|
7
|
+
import type { UserInteractionCallback } from '../../types';
|
|
8
|
+
export type OlLayerOptions = LayerCommonOptions & {
|
|
9
|
+
olLayer?: OlLayer;
|
|
10
|
+
};
|
|
11
|
+
declare const Layer_base: typeof LayerCommon;
|
|
12
|
+
/**
|
|
13
|
+
* A class representing a layer to display on an OpenLayers map.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { Layer } from 'mobility-toolbox-js/ol';
|
|
17
|
+
*
|
|
18
|
+
* const layer = new Layer({
|
|
19
|
+
* olLayer: ...,
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* @see <a href="/example/ol-map">Map example</a>
|
|
23
|
+
*
|
|
24
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
25
|
+
* @extends {LayerCommon}
|
|
26
|
+
*/
|
|
27
|
+
declare class Layer extends Layer_base {
|
|
28
|
+
olLayer?: OlLayer | LayerGroup;
|
|
29
|
+
olListenersKeys: EventsKey[];
|
|
30
|
+
options: OlLayerOptions;
|
|
31
|
+
visible: boolean;
|
|
32
|
+
copyrights: string[];
|
|
33
|
+
map?: Map;
|
|
34
|
+
singleClickListenerKey: EventsKey;
|
|
35
|
+
pointerMoveListenerKey: EventsKey;
|
|
36
|
+
userInteractions?: boolean;
|
|
37
|
+
userClickInteractions?: boolean;
|
|
38
|
+
userHoverInteractions?: boolean;
|
|
39
|
+
userClickCallbacks?: UserInteractionCallback[];
|
|
40
|
+
userHoverCallbacks?: UserInteractionCallback[];
|
|
41
|
+
onUserClickCallback: () => void;
|
|
42
|
+
onUserMoveCallback: () => void;
|
|
43
|
+
/**
|
|
44
|
+
* Constructor.
|
|
45
|
+
*
|
|
46
|
+
* @param {LayerCommonOptions} options
|
|
47
|
+
* @param {ol/layer/Layer~Layer} options.olLayer The layer (required).
|
|
48
|
+
* @param {string} [options.name=uuid()] Layer name. Default use a generated uuid.
|
|
49
|
+
* @param {string} [options.key=uuid().toLowerCase()] Layer key, will use options.name.toLowerCase() if not specified.
|
|
50
|
+
* @param {string} [options.copyright=undefined] Copyright-Statement.
|
|
51
|
+
* @param {Array<Layer>} [options.children=[]] Sublayers.
|
|
52
|
+
* @param {Object} [options.properties={}] Application-specific layer properties.
|
|
53
|
+
* @param {boolean} [options.visible=true] If true this layer is the currently visible layer on the map.
|
|
54
|
+
*/
|
|
55
|
+
constructor(options: OlLayerOptions);
|
|
56
|
+
/**
|
|
57
|
+
* Define layer's properties.
|
|
58
|
+
*
|
|
59
|
+
* @ignore
|
|
60
|
+
*/
|
|
61
|
+
defineProperties(options: OlLayerOptions): void;
|
|
62
|
+
/**
|
|
63
|
+
* Initialize the layer and listen to feature clicks.
|
|
64
|
+
* @param {ol/Map~Map} map
|
|
65
|
+
*/
|
|
66
|
+
attachToMap(map: Map): void;
|
|
67
|
+
/**
|
|
68
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
69
|
+
*/
|
|
70
|
+
detachFromMap(): void;
|
|
71
|
+
activateUserInteractions(): void;
|
|
72
|
+
deactivateUserInteractions(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Toggle listeners needed when a layer is avisible or not.
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
toggleVisibleListeners(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Create a copy of the Layer.
|
|
80
|
+
* @param {Object} newOptions Options to override
|
|
81
|
+
* @return {Layer} A Layer
|
|
82
|
+
*/
|
|
83
|
+
clone(newOptions: OlLayerOptions): Layer;
|
|
84
|
+
}
|
|
85
|
+
export default Layer;
|
|
86
|
+
//# sourceMappingURL=Layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/Layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,UAAU,MAAM,gBAAgB,CAAC;AACxC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,WAAW,MAAM,iCAAiC,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;;AAEF;;;;;;;;;;;;;;GAcG;AACH,cAAM,KAAM,SAAQ,UAAkC;IACpD,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAE/B,eAAe,EAAG,SAAS,EAAE,CAAC;IAI9B,OAAO,EAAG,cAAc,CAAC;IAEzB,OAAO,EAAG,OAAO,CAAC;IAElB,UAAU,EAAG,MAAM,EAAE,CAAC;IAEtB,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,sBAAsB,EAAG,SAAS,CAAC;IAEnC,sBAAsB,EAAG,SAAS,CAAC;IAInC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,mBAAmB,EAAG,MAAM,IAAI,CAAC;IAEjC,kBAAkB,EAAG,MAAM,IAAI,CAAC;IAEhC;;;;;;;;;;;OAWG;gBACS,OAAO,EAAE,cAAc;IAMnC;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,cAAc;IAUxC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,GAAG;IAiFpB;;OAEG;IACH,aAAa;IAcb,wBAAwB;IA2BxB,0BAA0B;IAI1B;;;OAGG;IACH,sBAAsB;IAQtB;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,cAAc;CAGjC;AACD,eAAe,KAAK,CAAC"}
|
package/ol/layers/Layer.js
CHANGED
|
@@ -1,88 +1,174 @@
|
|
|
1
|
-
import { unByKey } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { unByKey } from 'ol/Observable';
|
|
2
|
+
import LayerCommon from '../../common/layers/LayerCommon';
|
|
3
|
+
import userInteractionsMixin from '../../common/mixins/UserInteractionsLayerMixin';
|
|
4
|
+
/**
|
|
5
|
+
* A class representing a layer to display on an OpenLayers map.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { Layer } from 'mobility-toolbox-js/ol';
|
|
9
|
+
*
|
|
10
|
+
* const layer = new Layer({
|
|
11
|
+
* olLayer: ...,
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* @see <a href="/example/ol-map">Map example</a>
|
|
15
|
+
*
|
|
16
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
17
|
+
* @extends {LayerCommon}
|
|
18
|
+
*/
|
|
19
|
+
class Layer extends userInteractionsMixin(LayerCommon) {
|
|
20
|
+
/**
|
|
21
|
+
* Constructor.
|
|
22
|
+
*
|
|
23
|
+
* @param {LayerCommonOptions} options
|
|
24
|
+
* @param {ol/layer/Layer~Layer} options.olLayer The layer (required).
|
|
25
|
+
* @param {string} [options.name=uuid()] Layer name. Default use a generated uuid.
|
|
26
|
+
* @param {string} [options.key=uuid().toLowerCase()] Layer key, will use options.name.toLowerCase() if not specified.
|
|
27
|
+
* @param {string} [options.copyright=undefined] Copyright-Statement.
|
|
28
|
+
* @param {Array<Layer>} [options.children=[]] Sublayers.
|
|
29
|
+
* @param {Object} [options.properties={}] Application-specific layer properties.
|
|
30
|
+
* @param {boolean} [options.visible=true] If true this layer is the currently visible layer on the map.
|
|
31
|
+
*/
|
|
32
|
+
constructor(options) {
|
|
33
|
+
var _a;
|
|
34
|
+
super(options);
|
|
35
|
+
(_a = this.olLayer) === null || _a === void 0 ? void 0 : _a.setVisible(this.visible);
|
|
9
36
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (!this.map) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (this.map && this.olLayer) {
|
|
26
|
-
this.map.addLayer(this.olLayer);
|
|
27
|
-
}
|
|
28
|
-
this.olListenersKeys.push(this.map.getLayers().on("remove", (evt) => {
|
|
29
|
-
if (evt.element === this.olLayer) {
|
|
30
|
-
this.detachFromMap();
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
if (this.isClickActive || this.isHoverActive) {
|
|
34
|
-
this.toggleVisibleListeners();
|
|
35
|
-
this.olListenersKeys.push(this.on("change:visible", this.toggleVisibleListeners));
|
|
36
|
-
}
|
|
37
|
-
if (this.copyrights && this.olLayer) {
|
|
38
|
-
const attributions = this.copyrights || [];
|
|
39
|
-
if (this.olLayer instanceof Group) {
|
|
40
|
-
this.olLayer.getLayers().getArray().forEach((layer) => {
|
|
41
|
-
layer.getSource().setAttributions(attributions);
|
|
37
|
+
/**
|
|
38
|
+
* Define layer's properties.
|
|
39
|
+
*
|
|
40
|
+
* @ignore
|
|
41
|
+
*/
|
|
42
|
+
defineProperties(options) {
|
|
43
|
+
super.defineProperties(options);
|
|
44
|
+
Object.defineProperties(this, {
|
|
45
|
+
olLayer: { value: options.olLayer, writable: true },
|
|
46
|
+
olListenersKeys: {
|
|
47
|
+
value: [],
|
|
48
|
+
},
|
|
42
49
|
});
|
|
43
|
-
} else if (this.olLayer.getSource) {
|
|
44
|
-
this.olLayer.getSource().setAttributions(attributions);
|
|
45
|
-
}
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Initialize the layer and listen to feature clicks.
|
|
53
|
+
* @param {ol/Map~Map} map
|
|
54
|
+
*/
|
|
55
|
+
attachToMap(map) {
|
|
56
|
+
var _a, _b, _c, _d, _e;
|
|
57
|
+
super.attachToMap(map);
|
|
58
|
+
if (!this.map) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Make sure the visiblity is correct
|
|
62
|
+
(_a = this.olLayer) === null || _a === void 0 ? void 0 : _a.setVisible(this.visible);
|
|
63
|
+
if (this.olLayer &&
|
|
64
|
+
!((_d = (_c = (_b = this.map) === null || _b === void 0 ? void 0 : _b.getLayers()) === null || _c === void 0 ? void 0 : _c.getArray()) === null || _d === void 0 ? void 0 : _d.includes(this.olLayer))) {
|
|
65
|
+
this.map.addLayer(this.olLayer);
|
|
66
|
+
}
|
|
67
|
+
this.olListenersKeys.push(
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
this.on('change:visible', () => {
|
|
70
|
+
if (this.olLayer) {
|
|
71
|
+
this.olLayer.setVisible(this.visible);
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
this.olListenersKeys.push(
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
this.on('change:minZoom', () => {
|
|
77
|
+
if (this.olLayer && this.get('minZoom')) {
|
|
78
|
+
this.olLayer.setMinZoom(this.get('minZoom'));
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
this.olListenersKeys.push(
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
this.on('change:maxZoom', () => {
|
|
84
|
+
if (this.olLayer && this.get('maxZoom')) {
|
|
85
|
+
this.olLayer.setMaxZoom(this.get('maxZoom'));
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
this.olListenersKeys.push(this.map.getLayers().on('remove', (evt) => {
|
|
89
|
+
if (evt.element === this.olLayer) {
|
|
90
|
+
this.detachFromMap();
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
this.toggleVisibleListeners();
|
|
94
|
+
this.olListenersKeys.push(
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
this.on('change:visible', this.toggleVisibleListeners));
|
|
97
|
+
// We set the copyright to the source used by the layer.
|
|
98
|
+
if (this.copyrights && this.olLayer) {
|
|
99
|
+
const attributions = this.copyrights || [];
|
|
100
|
+
if (this.olLayer.getLayers) {
|
|
101
|
+
this.olLayer
|
|
102
|
+
.getLayers()
|
|
103
|
+
.getArray()
|
|
104
|
+
.forEach((layer) => {
|
|
105
|
+
var _a;
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
if (layer.getSource) {
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
(_a = layer.getSource()) === null || _a === void 0 ? void 0 : _a.setAttributions(attributions);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
}
|
|
114
|
+
else if (this.olLayer.getSource) {
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
(_e = this.olLayer.getSource()) === null || _e === void 0 ? void 0 : _e.setAttributions(attributions);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
52
119
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
122
|
+
*/
|
|
123
|
+
detachFromMap() {
|
|
124
|
+
var _a, _b, _c;
|
|
125
|
+
this.deactivateUserInteractions();
|
|
126
|
+
unByKey(this.olListenersKeys);
|
|
127
|
+
if (this.olLayer &&
|
|
128
|
+
((_c = (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getLayers()) === null || _b === void 0 ? void 0 : _b.getArray()) === null || _c === void 0 ? void 0 : _c.includes(this.olLayer))) {
|
|
129
|
+
this.map.removeLayer(this.olLayer);
|
|
130
|
+
}
|
|
131
|
+
super.detachFromMap();
|
|
58
132
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
133
|
+
activateUserInteractions() {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
this.deactivateUserInteractions();
|
|
136
|
+
if (this.map &&
|
|
137
|
+
this.userInteractions &&
|
|
138
|
+
this.userClickInteractions &&
|
|
139
|
+
((_a = this.userClickCallbacks) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
140
|
+
this.singleClickListenerKey = this.map.on('singleclick', this.onUserClickCallback);
|
|
141
|
+
this.olListenersKeys.push(this.singleClickListenerKey);
|
|
142
|
+
}
|
|
143
|
+
if (this.map &&
|
|
144
|
+
this.userInteractions &&
|
|
145
|
+
this.userHoverInteractions &&
|
|
146
|
+
((_b = this.userHoverCallbacks) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
147
|
+
this.pointerMoveListenerKey = this.map.on('pointermove', this.onUserMoveCallback);
|
|
148
|
+
}
|
|
62
149
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
150
|
+
deactivateUserInteractions() {
|
|
151
|
+
unByKey([this.pointerMoveListenerKey, this.singleClickListenerKey]);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Toggle listeners needed when a layer is avisible or not.
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
toggleVisibleListeners() {
|
|
158
|
+
if (this.visible) {
|
|
159
|
+
this.activateUserInteractions();
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.deactivateUserInteractions();
|
|
70
163
|
}
|
|
71
|
-
unByKey([this.isHoverListenerKey, this.isClickListenerKey]);
|
|
72
|
-
});
|
|
73
164
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.olListenersKeys.push(this.isClickListenerKey, this.isHoverListenerKey);
|
|
165
|
+
/**
|
|
166
|
+
* Create a copy of the Layer.
|
|
167
|
+
* @param {Object} newOptions Options to override
|
|
168
|
+
* @return {Layer} A Layer
|
|
169
|
+
*/
|
|
170
|
+
clone(newOptions) {
|
|
171
|
+
return new Layer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
82
172
|
}
|
|
83
|
-
}
|
|
84
|
-
clone(newOptions) {
|
|
85
|
-
return new Layer({ ...this.options, ...newOptions });
|
|
86
|
-
}
|
|
87
173
|
}
|
|
88
174
|
export default Layer;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="mapbox-gl" />
|
|
2
|
+
import { RenderFunction } from 'ol/layer/Layer';
|
|
3
|
+
import GeoJSON from 'ol/format/GeoJSON';
|
|
4
|
+
import OlMap from 'ol/Map';
|
|
5
|
+
import { Coordinate } from 'ol/coordinate';
|
|
6
|
+
import { AnyMapboxMap, AnyMapboxMapClass, LayerGetFeatureInfoResponse } from '../../types';
|
|
7
|
+
import Layer, { OlLayerOptions } from './Layer';
|
|
8
|
+
export type MapGlLayerOptions = OlLayerOptions & {
|
|
9
|
+
url?: string;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
apiKeyName?: string;
|
|
12
|
+
mapOptions?: any;
|
|
13
|
+
tabIndex?: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Common class for Mapbox and Maplibre and potential other fork from Mapbox.
|
|
17
|
+
* It's used to share code between Mapbox and Maplibre layers without importing both libs.
|
|
18
|
+
*/
|
|
19
|
+
declare class MapGlLayer extends Layer {
|
|
20
|
+
mbMap?: AnyMapboxMap;
|
|
21
|
+
styleUrl?: string;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
apiKeyName: string;
|
|
24
|
+
format: GeoJSON;
|
|
25
|
+
loaded: boolean;
|
|
26
|
+
options: MapGlLayerOptions;
|
|
27
|
+
constructor(options: MapGlLayerOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Initialize the layer and listen to feature clicks.
|
|
30
|
+
* @param {ol/Map~Map} map
|
|
31
|
+
*/
|
|
32
|
+
attachToMap(map: OlMap): void;
|
|
33
|
+
/**
|
|
34
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
35
|
+
*/
|
|
36
|
+
detachFromMap(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Create the mapbox map.
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
loadMbMap(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Update attributions of the source.
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
updateAttribution(evt: maplibregl.MapLibreEvent | mapboxgl.MapboxEvent): void;
|
|
47
|
+
/**
|
|
48
|
+
* Request feature information for a given coordinate.
|
|
49
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
50
|
+
* @param {Object} options A [mapboxgl.Map#queryrenderedfeatures](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#queryrenderedfeatures) options parameter.
|
|
51
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate. The original Mapbox feature is available as a property named 'mapboxFeature'.
|
|
52
|
+
*/
|
|
53
|
+
getFeatureInfoAtCoordinate(coordinate: Coordinate, options: any): Promise<LayerGetFeatureInfoResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Return the render function function for the ol layer.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
getOlLayerRender(): RenderFunction;
|
|
59
|
+
/**
|
|
60
|
+
* Return the Class to instanciate for the mapbox map.
|
|
61
|
+
*
|
|
62
|
+
* @return {mapboxgl.Map|maplibregl.Map} map
|
|
63
|
+
*/
|
|
64
|
+
getMapboxMapClass(): AnyMapboxMapClass;
|
|
65
|
+
}
|
|
66
|
+
export default MapGlLayer;
|
|
67
|
+
//# sourceMappingURL=MapGlLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapGlLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapGlLayer.ts"],"names":[],"mappings":";AAEA,OAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,cAAM,UAAW,SAAQ,KAAK;IAC5B,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAG,MAAM,CAAC;IAEpB,MAAM,EAAG,OAAO,CAAC;IAEjB,MAAM,EAAG,OAAO,CAAC;IAEjB,OAAO,EAAG,iBAAiB,CAAC;gBAEhB,OAAO,EAAE,iBAAiB;IAmCtC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,KAAK;IAkBtB;;OAEG;IACH,aAAa;IAab;;;OAGG;IACH,SAAS;IAuET;;;OAGG;IACH,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW;IAStE;;;;;OAKG;IACH,0BAA0B,CACxB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,2BAA2B,CAAC;IAqDvC;;;OAGG;IAEH,gBAAgB,IAAI,cAAc;IAOlC;;;;OAIG;IAEH,iBAAiB,IAAI,iBAAiB;CAMvC;AAED,eAAe,UAAU,CAAC"}
|