mobility-toolbox-js 3.0.0-beta.3 → 3.0.0-beta.32
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 +20 -0
- package/api/HttpAPI.js +0 -11
- package/api/RealtimeAPI.d.ts +404 -0
- package/api/RealtimeAPI.js +342 -276
- package/api/RoutingAPI.d.ts +47 -0
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +44 -0
- package/api/StopsAPI.js +17 -11
- package/api/WebSocketAPI.d.ts +147 -0
- package/api/WebSocketAPI.js +164 -164
- package/api/index.d.ts +3 -0
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +76 -0
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +53 -0
- package/common/controls/StopFinderControlCommon.js +31 -31
- package/common/index.d.ts +2 -0
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +267 -0
- package/common/mixins/RealtimeLayerMixin.js +401 -393
- package/common/styles/index.d.ts +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/typedefs.d.ts +219 -0
- package/common/typedefs.js +7 -1
- package/common/utils/compareDepartures.d.ts +10 -0
- package/common/utils/compareDepartures.js +2 -2
- 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/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getUrlWithParams.d.ts +8 -0
- package/common/utils/getVehiclePosition.d.ts +17 -0
- package/common/utils/getVehiclePosition.js +9 -3
- 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/renderTrajectories.js +6 -6
- package/common/utils/sortAndFilterDepartures.d.ts +15 -0
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.js +5 -1
- 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/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +181 -0
- package/maplibre/layers/RealtimeLayer.js +29 -5
- 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/getSourceCoordinates.js +5 -5
- package/maplibre/utils/index.d.ts +2 -0
- package/mbt.js +39819 -32088
- package/mbt.js.map +4 -4
- package/mbt.min.js +61 -58
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.js +18 -8
- package/ol/controls/RoutingControl.d.ts +202 -0
- package/ol/controls/RoutingControl.js +220 -219
- package/ol/controls/StopFinderControl.d.ts +37 -0
- package/ol/controls/StopFinderControl.js +5 -2
- package/ol/controls/index.d.ts +3 -0
- package/ol/index.d.ts +7 -0
- package/ol/index.js +1 -0
- package/ol/layers/Layer.d.ts +103 -0
- package/ol/layers/Layer.js +38 -0
- package/ol/layers/MaplibreLayer.d.ts +167 -0
- package/ol/layers/MaplibreLayer.js +115 -27
- package/ol/layers/MaplibreStyleLayer.d.ts +237 -0
- package/ol/layers/MaplibreStyleLayer.js +315 -265
- package/ol/layers/RealtimeLayer.d.ts +283 -0
- package/ol/layers/RealtimeLayer.js +143 -128
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +32 -0
- package/ol/layers/index.d.ts +5 -0
- package/ol/layers/index.js +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +96 -0
- package/ol/mixins/MobilityLayerMixin.js +1 -4
- package/ol/mixins/PropertiesLayerMixin.d.ts +136 -0
- package/ol/mixins/PropertiesLayerMixin.js +122 -140
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -0
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
- package/ol/renderers/RealtimeLayerRenderer.js +58 -53
- 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 +12 -18
- package/ol/utils/index.d.ts +1 -0
- package/package.json +31 -31
- package/setupTests.d.ts +1 -0
- package/setupTests.js +3 -4
- package/types/common.d.ts +55 -48
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +91 -93
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/ol/layers/MapGlLayer.js +0 -142
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import OLLayer from 'ol/layer/Layer';
|
|
2
|
+
import LayerRenderer from 'ol/renderer/Layer';
|
|
3
|
+
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
4
|
+
declare const Layer_base: {
|
|
5
|
+
new (...args: any[]): {
|
|
6
|
+
olEventsKeys: import("ol/events").EventsKey[];
|
|
7
|
+
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions;
|
|
8
|
+
attachToMap(map: import("ol").Map): void;
|
|
9
|
+
detachFromMap(): void;
|
|
10
|
+
flat(): any[];
|
|
11
|
+
onChildrenChange(oldValue: OLLayer[]): void;
|
|
12
|
+
setMapInternal: ((map: import("ol").Map) => void) & ((map: import("ol").default | null) => void);
|
|
13
|
+
children: OLLayer<import("ol/source").Source, LayerRenderer<any>>[];
|
|
14
|
+
get copyrights(): string;
|
|
15
|
+
set copyrights(newCopyrights: string | string[]);
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
readonly group: string;
|
|
18
|
+
hitTolerance: number;
|
|
19
|
+
readonly key: string;
|
|
20
|
+
readonly map: import("ol").Map;
|
|
21
|
+
readonly name: string;
|
|
22
|
+
olLayer: OLLayer;
|
|
23
|
+
parent: OLLayer<import("ol/source").Source, LayerRenderer<any>>;
|
|
24
|
+
visible: boolean;
|
|
25
|
+
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
26
|
+
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
27
|
+
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
28
|
+
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
29
|
+
getSource: () => import("ol/source").Source | null;
|
|
30
|
+
getRenderSource: () => import("ol/source").Source | null;
|
|
31
|
+
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
|
|
32
|
+
getData: (pixel: import("ol/pixel").Pixel) => Uint8ClampedArray | Uint8Array | Float32Array | DataView | null;
|
|
33
|
+
isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
34
|
+
getAttributions: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => Array<string>;
|
|
35
|
+
unrender: () => void;
|
|
36
|
+
getDeclutter: () => string;
|
|
37
|
+
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
38
|
+
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
39
|
+
getMapInternal: () => import("ol").default | null;
|
|
40
|
+
setMap: (map: import("ol").default | null) => void;
|
|
41
|
+
setSource: (source: import("ol/source").Source | null) => void;
|
|
42
|
+
getRenderer: () => LayerRenderer<any> | null;
|
|
43
|
+
hasRenderer: () => boolean;
|
|
44
|
+
getBackground: () => import("ol/layer/Base").BackgroundColor | false;
|
|
45
|
+
getClassName: () => string;
|
|
46
|
+
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
47
|
+
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
|
|
48
|
+
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
|
|
49
|
+
getExtent: () => import("ol/extent").Extent | undefined;
|
|
50
|
+
getMaxResolution: () => number;
|
|
51
|
+
getMinResolution: () => number;
|
|
52
|
+
getMinZoom: () => number;
|
|
53
|
+
getMaxZoom: () => number;
|
|
54
|
+
getOpacity: () => number;
|
|
55
|
+
getSourceState: () => import("ol/source/Source").State;
|
|
56
|
+
getVisible: () => boolean;
|
|
57
|
+
getZIndex: () => number | undefined;
|
|
58
|
+
setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
|
|
59
|
+
setExtent: (extent: import("ol/extent").Extent | undefined) => void;
|
|
60
|
+
setMaxResolution: (maxResolution: number) => void;
|
|
61
|
+
setMinResolution: (minResolution: number) => void;
|
|
62
|
+
setMaxZoom: (maxZoom: number) => void;
|
|
63
|
+
setMinZoom: (minZoom: number) => void;
|
|
64
|
+
setOpacity: (opacity: number) => void;
|
|
65
|
+
setVisible: (visible: boolean) => void;
|
|
66
|
+
setZIndex: (zindex: number) => void;
|
|
67
|
+
get: (key: string) => any;
|
|
68
|
+
getKeys: () => Array<string>;
|
|
69
|
+
getProperties: () => {
|
|
70
|
+
[x: string]: any;
|
|
71
|
+
};
|
|
72
|
+
getPropertiesInternal: () => {
|
|
73
|
+
[x: string]: any;
|
|
74
|
+
} | null;
|
|
75
|
+
hasProperties: () => boolean;
|
|
76
|
+
notify: (key: string, oldValue: any) => void;
|
|
77
|
+
addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
78
|
+
removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
79
|
+
set: (key: string, value: any, silent?: boolean | undefined) => void;
|
|
80
|
+
setProperties: (values: {
|
|
81
|
+
[x: string]: any;
|
|
82
|
+
}, silent?: boolean | undefined) => void;
|
|
83
|
+
unset: (key: string, silent?: boolean | undefined) => void;
|
|
84
|
+
changed: () => void;
|
|
85
|
+
getRevision: () => number;
|
|
86
|
+
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
87
|
+
dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
|
|
88
|
+
getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
|
|
89
|
+
hasListener: (type?: string | undefined) => boolean;
|
|
90
|
+
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
91
|
+
dispose: () => void;
|
|
92
|
+
};
|
|
93
|
+
} & typeof OLLayer;
|
|
94
|
+
/**
|
|
95
|
+
* An OpenLayers layer here only for backward compatibility v2.
|
|
96
|
+
* @deprecated Use an OpenLayers Layer instead.
|
|
97
|
+
*/
|
|
98
|
+
declare class Layer extends Layer_base {
|
|
99
|
+
constructor(options: MobilityLayerOptions);
|
|
100
|
+
clone(newOptions: MobilityLayerOptions): Layer;
|
|
101
|
+
createRenderer(): LayerRenderer<OLLayer>;
|
|
102
|
+
}
|
|
103
|
+
export default Layer;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import debounce from 'lodash.debounce';
|
|
2
|
+
import OLLayer from 'ol/layer/Layer';
|
|
3
|
+
import LayerRenderer from 'ol/renderer/Layer';
|
|
4
|
+
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
5
|
+
let deprecated = () => { };
|
|
6
|
+
if (typeof window !== 'undefined' &&
|
|
7
|
+
new URLSearchParams(window.location.search).get('deprecated')) {
|
|
8
|
+
deprecated = debounce((message) => {
|
|
9
|
+
// eslint-disable-next-line no-console
|
|
10
|
+
console.warn(message);
|
|
11
|
+
}, 1000);
|
|
12
|
+
}
|
|
13
|
+
class EmptyLayerRenderer extends LayerRenderer {
|
|
14
|
+
prepareFrame() {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
renderFrame() {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* An OpenLayers layer here only for backward compatibility v2.
|
|
23
|
+
* @deprecated Use an OpenLayers Layer instead.
|
|
24
|
+
*/
|
|
25
|
+
class Layer extends MobilityLayerMixin(OLLayer) {
|
|
26
|
+
constructor(options) {
|
|
27
|
+
super(options);
|
|
28
|
+
deprecated('Layer is deprecated. Use an OpenLayers Layer instead.');
|
|
29
|
+
}
|
|
30
|
+
clone(newOptions) {
|
|
31
|
+
return new Layer(Object.assign(Object.assign({}, (this.options || {})), (newOptions || {})));
|
|
32
|
+
}
|
|
33
|
+
// ol does not like when it returns null.
|
|
34
|
+
createRenderer() {
|
|
35
|
+
return new EmptyLayerRenderer(this);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export default Layer;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
|
|
2
|
+
import OlMap from 'ol/Map';
|
|
3
|
+
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
4
|
+
import type { MapLibreOptions } from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
|
|
5
|
+
import type { QueryRenderedFeaturesOptions } from 'maplibre-gl';
|
|
6
|
+
import type { Options as LayerOptions } from 'ol/layer/Layer';
|
|
7
|
+
export type MaplibreLayerOptions = {
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
apiKeyName?: string;
|
|
10
|
+
mapLibreOptions?: MapLibreOptions;
|
|
11
|
+
queryRenderedFeaturesOptions?: QueryRenderedFeaturesOptions | undefined;
|
|
12
|
+
style?: maplibregl.StyleSpecification | null | string;
|
|
13
|
+
url?: string;
|
|
14
|
+
} & LayerOptions & MobilityLayerOptions;
|
|
15
|
+
declare const MaplibreLayer_base: {
|
|
16
|
+
new (...args: any[]): {
|
|
17
|
+
olEventsKeys: import("ol/events").EventsKey[];
|
|
18
|
+
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions;
|
|
19
|
+
attachToMap(map: OlMap): void;
|
|
20
|
+
detachFromMap(): void;
|
|
21
|
+
flat(): any[];
|
|
22
|
+
onChildrenChange(oldValue: import("ol/layer/Layer").default[]): void;
|
|
23
|
+
setMapInternal: ((map: OlMap) => void) & ((map: import("ol/Map").default | null) => void);
|
|
24
|
+
children: import("ol/layer/Layer").default<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
25
|
+
get copyrights(): string;
|
|
26
|
+
set copyrights(newCopyrights: string | string[]);
|
|
27
|
+
disabled: boolean;
|
|
28
|
+
readonly group: string;
|
|
29
|
+
hitTolerance: number;
|
|
30
|
+
readonly key: string;
|
|
31
|
+
readonly map: OlMap;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
olLayer: import("ol/layer/Layer").default;
|
|
34
|
+
parent: import("ol/layer/Layer").default<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
35
|
+
visible: boolean;
|
|
36
|
+
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
37
|
+
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
38
|
+
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
39
|
+
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
40
|
+
getSource: () => import("ol/source").Source | null;
|
|
41
|
+
getRenderSource: () => import("ol/source").Source | null;
|
|
42
|
+
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
|
|
43
|
+
getData: (pixel: import("ol/pixel").Pixel) => Uint8ClampedArray | Uint8Array | Float32Array | DataView | null;
|
|
44
|
+
isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
45
|
+
getAttributions: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => Array<string>;
|
|
46
|
+
unrender: () => void;
|
|
47
|
+
getDeclutter: () => string;
|
|
48
|
+
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
49
|
+
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
50
|
+
getMapInternal: () => import("ol/Map").default | null;
|
|
51
|
+
setMap: (map: import("ol/Map").default | null) => void;
|
|
52
|
+
setSource: (source: import("ol/source").Source | null) => void;
|
|
53
|
+
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
54
|
+
hasRenderer: () => boolean;
|
|
55
|
+
getBackground: () => import("ol/layer/Base").BackgroundColor | false;
|
|
56
|
+
getClassName: () => string;
|
|
57
|
+
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
58
|
+
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
|
|
59
|
+
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
|
|
60
|
+
getExtent: () => import("ol/extent").Extent | undefined;
|
|
61
|
+
getMaxResolution: () => number;
|
|
62
|
+
getMinResolution: () => number;
|
|
63
|
+
getMinZoom: () => number;
|
|
64
|
+
getMaxZoom: () => number;
|
|
65
|
+
getOpacity: () => number;
|
|
66
|
+
getSourceState: () => import("ol/source/Source").State;
|
|
67
|
+
getVisible: () => boolean;
|
|
68
|
+
getZIndex: () => number | undefined;
|
|
69
|
+
setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
|
|
70
|
+
setExtent: (extent: import("ol/extent").Extent | undefined) => void;
|
|
71
|
+
setMaxResolution: (maxResolution: number) => void;
|
|
72
|
+
setMinResolution: (minResolution: number) => void;
|
|
73
|
+
setMaxZoom: (maxZoom: number) => void;
|
|
74
|
+
setMinZoom: (minZoom: number) => void;
|
|
75
|
+
setOpacity: (opacity: number) => void;
|
|
76
|
+
setVisible: (visible: boolean) => void;
|
|
77
|
+
setZIndex: (zindex: number) => void;
|
|
78
|
+
get: (key: string) => any;
|
|
79
|
+
getKeys: () => Array<string>;
|
|
80
|
+
getProperties: () => {
|
|
81
|
+
[x: string]: any;
|
|
82
|
+
};
|
|
83
|
+
getPropertiesInternal: () => {
|
|
84
|
+
[x: string]: any;
|
|
85
|
+
} | null;
|
|
86
|
+
hasProperties: () => boolean;
|
|
87
|
+
notify: (key: string, oldValue: any) => void;
|
|
88
|
+
addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
89
|
+
removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
90
|
+
set: (key: string, value: any, silent?: boolean | undefined) => void;
|
|
91
|
+
setProperties: (values: {
|
|
92
|
+
[x: string]: any;
|
|
93
|
+
}, silent?: boolean | undefined) => void;
|
|
94
|
+
unset: (key: string, silent?: boolean | undefined) => void;
|
|
95
|
+
changed: () => void;
|
|
96
|
+
getRevision: () => number;
|
|
97
|
+
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
98
|
+
dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
|
|
99
|
+
getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
|
|
100
|
+
hasListener: (type?: string | undefined) => boolean;
|
|
101
|
+
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
102
|
+
dispose: () => void;
|
|
103
|
+
};
|
|
104
|
+
} & typeof MapLibreLayer;
|
|
105
|
+
/**
|
|
106
|
+
* An OpenLayers layer able to display data from the [geOps Maps API](https://developer.geops.io/apis/maps).
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* import { MaplibreLayer } from 'mobility-toolbox-js/ol';
|
|
110
|
+
*
|
|
111
|
+
* const layer = new MaplibreLayer({
|
|
112
|
+
* apiKey: 'yourApiKey',
|
|
113
|
+
* // apiKeyName: 'key',
|
|
114
|
+
* // mapLibreOptions: {
|
|
115
|
+
* // interactive: false,
|
|
116
|
+
* // trackResize: false,
|
|
117
|
+
* // attributionControl: false,
|
|
118
|
+
* // }
|
|
119
|
+
* // queryRenderedFeaturesOptions: {
|
|
120
|
+
* // layers: ['waters_lakes'], // map.getFeaturesAtPixel will only return lakes.
|
|
121
|
+
* // },
|
|
122
|
+
* // style: 'travic_v2',
|
|
123
|
+
* // url: 'https://maps.geops.io',
|
|
124
|
+
* });
|
|
125
|
+
*
|
|
126
|
+
* @classproperty {maplibregl.Map} mapLibreMap - The Maplibre map object. Readonly.
|
|
127
|
+
* @classproperty {string} style - geOps Maps api style.
|
|
128
|
+
* @extends {ol/layer/Layer~Layer}
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
declare class MaplibreLayer extends MaplibreLayer_base {
|
|
132
|
+
/**
|
|
133
|
+
* Constructor.
|
|
134
|
+
*
|
|
135
|
+
* @param {MaplibreLayerOptions} options
|
|
136
|
+
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
137
|
+
* @param {string} [options.apiKeyName="key"] The geOps Maps API key name.
|
|
138
|
+
* @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
|
|
139
|
+
* @param {string} [options.style="travic_v2"] The geOps Maps API style.
|
|
140
|
+
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
141
|
+
*/
|
|
142
|
+
constructor(options: MaplibreLayerOptions);
|
|
143
|
+
/**
|
|
144
|
+
* Initialize the layer and listen to feature clicks.
|
|
145
|
+
* @param {ol/Map~Map} map
|
|
146
|
+
*/
|
|
147
|
+
attachToMap(map: OlMap): void;
|
|
148
|
+
/**
|
|
149
|
+
* Create a copy of the MaplibreLayer.
|
|
150
|
+
* @param {MaplibreLayerOptions} newOptions Options to override
|
|
151
|
+
* @return {MaplibreLayer} A MaplibreLayer layer
|
|
152
|
+
*/
|
|
153
|
+
clone(newOptions: MaplibreLayerOptions): MaplibreLayer;
|
|
154
|
+
getStyle(): string;
|
|
155
|
+
updateMaplibreMap(): void;
|
|
156
|
+
set apiKey(newValue: string);
|
|
157
|
+
get apiKey(): string;
|
|
158
|
+
set apiKeyName(newValue: string);
|
|
159
|
+
get apiKeyName(): string;
|
|
160
|
+
get maplibreMap(): maplibregl.Map | undefined;
|
|
161
|
+
get mbMap(): maplibregl.Map | undefined;
|
|
162
|
+
get style(): string;
|
|
163
|
+
set style(newValue: string);
|
|
164
|
+
get url(): string;
|
|
165
|
+
set url(newValue: string);
|
|
166
|
+
}
|
|
167
|
+
export default MaplibreLayer;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
|
|
2
|
+
import debounce from 'lodash.debounce';
|
|
3
|
+
import { getUrlWithParams } from '../../common/utils';
|
|
4
|
+
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
5
|
+
const buildStyleUrl = (url, style, apiKey, apiKeyName) => {
|
|
6
|
+
return getUrlWithParams(`${url}/styles/${style}/style.json`, {
|
|
7
|
+
[apiKeyName]: apiKey,
|
|
8
|
+
}).toString();
|
|
9
|
+
};
|
|
10
|
+
let deprecated = () => { };
|
|
11
|
+
if (typeof window !== 'undefined' &&
|
|
12
|
+
new URLSearchParams(window.location.search).get('deprecated')) {
|
|
13
|
+
deprecated = debounce((message) => {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn(message);
|
|
16
|
+
}, 1000);
|
|
17
|
+
}
|
|
4
18
|
/**
|
|
5
|
-
*
|
|
19
|
+
* An OpenLayers layer able to display data from the [geOps Maps API](https://developer.geops.io/apis/maps).
|
|
6
20
|
*
|
|
7
21
|
* @example
|
|
8
22
|
* import { MaplibreLayer } from 'mobility-toolbox-js/ol';
|
|
@@ -10,7 +24,7 @@ import MaplibreLayerRenderer from '../renderers/MaplibreLayerRenderer';
|
|
|
10
24
|
* const layer = new MaplibreLayer({
|
|
11
25
|
* apiKey: 'yourApiKey',
|
|
12
26
|
* // apiKeyName: 'key',
|
|
13
|
-
* //
|
|
27
|
+
* // mapLibreOptions: {
|
|
14
28
|
* // interactive: false,
|
|
15
29
|
* // trackResize: false,
|
|
16
30
|
* // attributionControl: false,
|
|
@@ -22,43 +36,59 @@ import MaplibreLayerRenderer from '../renderers/MaplibreLayerRenderer';
|
|
|
22
36
|
* // url: 'https://maps.geops.io',
|
|
23
37
|
* });
|
|
24
38
|
*
|
|
25
|
-
* @classproperty {maplibregl.Map}
|
|
26
|
-
* @classproperty {maplibregl.QueryRenderedFeaturesOptions} queryRenderedFeaturesOptions - Options used when we query features using map.getFeaturesAtPixel().
|
|
39
|
+
* @classproperty {maplibregl.Map} mapLibreMap - The Maplibre map object. Readonly.
|
|
27
40
|
* @classproperty {string} style - geOps Maps api style.
|
|
28
41
|
* @extends {ol/layer/Layer~Layer}
|
|
29
42
|
* @public
|
|
30
43
|
*/
|
|
31
|
-
|
|
32
|
-
/** @private */
|
|
33
|
-
get maplibreMap() {
|
|
34
|
-
return this.mbMap;
|
|
35
|
-
}
|
|
44
|
+
class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
36
45
|
/**
|
|
37
46
|
* Constructor.
|
|
38
47
|
*
|
|
39
48
|
* @param {MaplibreLayerOptions} options
|
|
40
49
|
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
41
|
-
* @param {string} [options.apiKeyName="key"] The geOps Maps
|
|
42
|
-
* @param {maplibregl.MapOptions} [options.
|
|
43
|
-
* @param {string} [options.style="travic_v2"] The geOps Maps
|
|
44
|
-
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps
|
|
50
|
+
* @param {string} [options.apiKeyName="key"] The geOps Maps API key name.
|
|
51
|
+
* @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
|
|
52
|
+
* @param {string} [options.style="travic_v2"] The geOps Maps API style.
|
|
53
|
+
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
45
54
|
*/
|
|
46
55
|
constructor(options) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
var _a;
|
|
57
|
+
const newOptions = Object.assign(Object.assign({ apiKeyName: 'key', style: 'travic_v2', url: 'https://maps.geops.io' }, (options || {})), { mapLibreOptions: Object.assign({}, (options.mapLibreOptions || {})) });
|
|
58
|
+
if (!newOptions.mapLibreOptions.style &&
|
|
59
|
+
((_a = newOptions.url) === null || _a === void 0 ? void 0 : _a.includes('style.json'))) {
|
|
60
|
+
newOptions.mapLibreOptions.style = newOptions.url;
|
|
61
|
+
}
|
|
62
|
+
else if (!newOptions.mapLibreOptions.style &&
|
|
63
|
+
newOptions.apiKey &&
|
|
64
|
+
newOptions.style &&
|
|
65
|
+
typeof newOptions.style === 'string') {
|
|
66
|
+
newOptions.mapLibreOptions.style = buildStyleUrl(newOptions.url, newOptions.style, newOptions.apiKey, newOptions.apiKeyName);
|
|
67
|
+
}
|
|
68
|
+
super(newOptions);
|
|
54
69
|
}
|
|
55
70
|
/**
|
|
56
|
-
*
|
|
71
|
+
* Initialize the layer and listen to feature clicks.
|
|
72
|
+
* @param {ol/Map~Map} map
|
|
57
73
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
attachToMap(map) {
|
|
75
|
+
super.attachToMap(map);
|
|
76
|
+
const updateMaplibreMapDebounced = debounce(this.updateMaplibreMap.bind(this), 150);
|
|
77
|
+
updateMaplibreMapDebounced();
|
|
78
|
+
this.olEventsKeys.push(this.on('propertychange', (evt) => {
|
|
79
|
+
if (/(url|style|apiKey|apiKeyName)/.test(evt.key)) {
|
|
80
|
+
updateMaplibreMapDebounced();
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
61
83
|
}
|
|
84
|
+
// get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
|
|
85
|
+
// return this.get('queryRenderedFeaturesOptions');
|
|
86
|
+
// }
|
|
87
|
+
// set queryRenderedFeaturesOptions(
|
|
88
|
+
// newValue: maplibregl.QueryRenderedFeaturesOptions,
|
|
89
|
+
// ) {
|
|
90
|
+
// this.set('queryRenderedFeaturesOptions', newValue);
|
|
91
|
+
// }
|
|
62
92
|
/**
|
|
63
93
|
* Create a copy of the MaplibreLayer.
|
|
64
94
|
* @param {MaplibreLayerOptions} newOptions Options to override
|
|
@@ -67,4 +97,62 @@ export default class MaplibreLayer extends MapGlLayer {
|
|
|
67
97
|
clone(newOptions) {
|
|
68
98
|
return new MaplibreLayer(Object.assign(Object.assign({}, (this.options || {})), (newOptions || {})));
|
|
69
99
|
}
|
|
100
|
+
getStyle() {
|
|
101
|
+
// If the style is a complete style object, use it directly.
|
|
102
|
+
if (this.style &&
|
|
103
|
+
typeof this.style === 'object' &&
|
|
104
|
+
this.style.name &&
|
|
105
|
+
this.style.version) {
|
|
106
|
+
return this.style;
|
|
107
|
+
}
|
|
108
|
+
// If the url set is already a complete style url, use it directly.
|
|
109
|
+
if (this.url.includes('style.json')) {
|
|
110
|
+
return this.url;
|
|
111
|
+
}
|
|
112
|
+
/// Otherwise build the complete style url.
|
|
113
|
+
return buildStyleUrl(this.url, this.style, this.apiKey, this.apiKeyName);
|
|
114
|
+
}
|
|
115
|
+
updateMaplibreMap() {
|
|
116
|
+
var _a;
|
|
117
|
+
try {
|
|
118
|
+
(_a = this.mapLibreMap) === null || _a === void 0 ? void 0 : _a.setStyle(this.getStyle(), { diff: false });
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
// eslint-disable-next-line no-console
|
|
122
|
+
console.error('Error while updating MaplibreMap', e);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
set apiKey(newValue) {
|
|
126
|
+
this.set('apiKey', newValue);
|
|
127
|
+
}
|
|
128
|
+
get apiKey() {
|
|
129
|
+
return this.get('apiKey');
|
|
130
|
+
}
|
|
131
|
+
set apiKeyName(newValue) {
|
|
132
|
+
this.set('apiKeyName', newValue);
|
|
133
|
+
}
|
|
134
|
+
get apiKeyName() {
|
|
135
|
+
return this.get('apiKeyName');
|
|
136
|
+
}
|
|
137
|
+
get maplibreMap() {
|
|
138
|
+
deprecated('MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap.');
|
|
139
|
+
return this.mapLibreMap;
|
|
140
|
+
}
|
|
141
|
+
get mbMap() {
|
|
142
|
+
deprecated('MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap.');
|
|
143
|
+
return this.maplibreMap;
|
|
144
|
+
}
|
|
145
|
+
get style() {
|
|
146
|
+
return this.get('style');
|
|
147
|
+
}
|
|
148
|
+
set style(newValue) {
|
|
149
|
+
this.set('style', newValue);
|
|
150
|
+
}
|
|
151
|
+
get url() {
|
|
152
|
+
return this.get('url');
|
|
153
|
+
}
|
|
154
|
+
set url(newValue) {
|
|
155
|
+
this.set('url', newValue);
|
|
156
|
+
}
|
|
70
157
|
}
|
|
158
|
+
export default MaplibreLayer;
|