mobility-toolbox-js 3.0.0-beta.10 → 3.0.0-beta.12
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 +30 -24
- package/api/RealtimeAPI.js +25 -18
- package/api/RoutingAPI.d.ts +17 -7
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +4 -4
- package/api/StopsAPI.js +4 -4
- package/api/WebSocketAPI.d.ts +2 -2
- package/api/WebSocketAPI.js +2 -2
- package/api/typedefs.d.ts +0 -102
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +1 -1
- package/common/controls/StopFinderControlCommon.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +10 -11
- package/common/mixins/RealtimeLayerMixin.js +17 -9
- package/common/typedefs.d.ts +7 -0
- package/common/typedefs.js +6 -0
- package/common/utils/compareDepartures.d.ts +2 -2
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/debounceWebsocketMessages.d.ts +1 -1
- package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getVehiclePosition.d.ts +3 -2
- package/common/utils/getVehiclePosition.js +9 -3
- package/common/utils/renderTrajectories.d.ts +1 -1
- package/common/utils/renderTrajectories.js +1 -1
- package/common/utils/sortAndFilterDepartures.d.ts +1 -1
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +2 -2
- package/common/utils/sortByDelay.js +5 -1
- package/maplibre/layers/Layer.d.ts +1 -1
- package/maplibre/layers/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +43 -14
- package/maplibre/layers/RealtimeLayer.js +30 -6
- package/mbt.js +5500 -6796
- package/mbt.js.map +4 -4
- package/mbt.min.js +67 -67
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +1 -1
- package/ol/controls/RoutingControl.js +1 -1
- package/ol/controls/StopFinderControl.d.ts +1 -1
- package/ol/controls/StopFinderControl.js +1 -1
- package/ol/layers/{MapGlLayer.d.ts → Layer.d.ts} +23 -66
- package/ol/layers/Layer.js +17 -0
- package/ol/layers/MaplibreLayer.d.ts +133 -13
- package/ol/layers/MaplibreLayer.js +136 -13
- package/ol/layers/MaplibreStyleLayer.d.ts +8 -2
- package/ol/layers/MaplibreStyleLayer.js +37 -22
- package/ol/layers/RealtimeLayer.d.ts +17 -14
- package/ol/layers/RealtimeLayer.js +2 -2
- package/ol/layers/index.d.ts +1 -0
- package/ol/layers/index.js +1 -0
- package/ol/renderers/RealtimeLayerRenderer.js +4 -1
- package/package.json +14 -15
- package/ol/layers/MapGlLayer.js +0 -144
|
@@ -31,7 +31,7 @@ export type AbotControllersByGraph = {
|
|
|
31
31
|
[key: string]: AbortController;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* This OpenLayers control allows the user to add and modifiy via points to a map and request a route from the [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* import { Map } from 'ol';
|
|
@@ -47,7 +47,7 @@ const getFlatCoordinatesFromSegments = (segmentArray) => {
|
|
|
47
47
|
return coords;
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* This OpenLayers control allows the user to add and modifiy via points to a map and request a route from the [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
53
|
* import { Map } from 'ol';
|
|
@@ -5,7 +5,7 @@ export type StopFinderControlOptions = Options & StopFinderControlCommon & {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* This OpenLayers control allows to search stations from the [geOps Stops API](https://developer.geops.io/apis/stops/).
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* import { Map } from 'ol';
|
|
@@ -3,7 +3,7 @@ import Control from 'ol/control/Control';
|
|
|
3
3
|
import StopFinderControlCommon from '../../common/controls/StopFinderControlCommon';
|
|
4
4
|
import createDefaultStopFinderElement from '../../common/utils/createDefaultStopFinderElt';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* This OpenLayers control allows to search stations from the [geOps Stops API](https://developer.geops.io/apis/stops/).
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* import { Map } from 'ol';
|
|
@@ -1,36 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import OlMap from 'ol/Map';
|
|
3
|
-
import BaseEvent from 'ol/events/Event';
|
|
4
|
-
import Layer from 'ol/layer/Layer';
|
|
5
|
-
import { AnyMapGlMap } from '../../types';
|
|
1
|
+
import OLLayer from 'ol/layer/Layer';
|
|
6
2
|
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
7
|
-
|
|
8
|
-
apiKey?: string;
|
|
9
|
-
apiKeyName?: string;
|
|
10
|
-
style?: string | maplibregl.StyleSpecification;
|
|
11
|
-
url?: string;
|
|
12
|
-
mapOptions?: maplibregl.MapOptions;
|
|
13
|
-
queryRenderedFeaturesOptions?: maplibregl.QueryRenderedFeaturesOptions;
|
|
14
|
-
};
|
|
15
|
-
declare const MapGlLayer_base: {
|
|
3
|
+
declare const Layer_base: {
|
|
16
4
|
new (...args: any[]): {
|
|
17
5
|
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions | undefined;
|
|
18
6
|
olListenersKeys: import("ol/events").EventsKey[];
|
|
19
|
-
children:
|
|
7
|
+
children: OLLayer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
20
8
|
get copyrights(): string;
|
|
21
9
|
set copyrights(newCopyrights: string | string[]);
|
|
22
10
|
disabled: boolean;
|
|
23
11
|
readonly group: string;
|
|
24
12
|
readonly hitTolerance: boolean;
|
|
25
13
|
readonly key: string;
|
|
26
|
-
readonly map:
|
|
14
|
+
readonly map: import("ol").Map;
|
|
27
15
|
readonly name: string;
|
|
28
|
-
olLayer:
|
|
29
|
-
parent:
|
|
16
|
+
olLayer: OLLayer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
17
|
+
parent: OLLayer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
30
18
|
visible: boolean;
|
|
31
|
-
setMapInternal: ((map:
|
|
32
|
-
onChildrenChange(oldValue:
|
|
33
|
-
attachToMap(map:
|
|
19
|
+
setMapInternal: ((map: import("ol").Map) => void) & ((map: import("ol").Map | null) => void);
|
|
20
|
+
onChildrenChange(oldValue: OLLayer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[]): void;
|
|
21
|
+
attachToMap(map: import("ol").Map): void;
|
|
34
22
|
detachFromMap(): void;
|
|
35
23
|
flat(): any[];
|
|
36
24
|
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
@@ -39,8 +27,8 @@ declare const MapGlLayer_base: {
|
|
|
39
27
|
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
40
28
|
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
41
29
|
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
42
|
-
getSource: () => Source | null;
|
|
43
|
-
getRenderSource: () => Source | null;
|
|
30
|
+
getSource: () => import("ol/source").Source | null;
|
|
31
|
+
getRenderSource: () => import("ol/source").Source | null;
|
|
44
32
|
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<import("ol/Feature").FeatureLike[]>;
|
|
45
33
|
getData: (pixel: import("ol/pixel").Pixel) => Float32Array | Uint8ClampedArray | Uint8Array | DataView | null;
|
|
46
34
|
isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
@@ -49,15 +37,15 @@ declare const MapGlLayer_base: {
|
|
|
49
37
|
getDeclutter: () => string;
|
|
50
38
|
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
51
39
|
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
52
|
-
getMapInternal: () =>
|
|
53
|
-
setMap: (map:
|
|
54
|
-
setSource: (source: Source | null) => void;
|
|
40
|
+
getMapInternal: () => import("ol").Map | null;
|
|
41
|
+
setMap: (map: import("ol").Map | null) => void;
|
|
42
|
+
setSource: (source: import("ol/source").Source | null) => void;
|
|
55
43
|
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
56
44
|
hasRenderer: () => boolean;
|
|
57
45
|
getBackground: () => false | import("ol/layer/Base").BackgroundColor;
|
|
58
46
|
getClassName: () => string;
|
|
59
47
|
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
60
|
-
getLayersArray: (array?:
|
|
48
|
+
getLayersArray: (array?: OLLayer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[] | undefined) => OLLayer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
61
49
|
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => import("ol/layer/Layer").State[];
|
|
62
50
|
getExtent: () => import("ol/extent").Extent | undefined;
|
|
63
51
|
getMaxResolution: () => number;
|
|
@@ -96,49 +84,18 @@ declare const MapGlLayer_base: {
|
|
|
96
84
|
unset: (key: string, silent?: boolean | undefined) => void;
|
|
97
85
|
changed: () => void;
|
|
98
86
|
getRevision: () => number;
|
|
99
|
-
dispatchEvent: (event: string |
|
|
87
|
+
dispatchEvent: (event: string | import("ol/events/Event").default) => boolean | undefined;
|
|
100
88
|
getListeners: (type: string) => import("ol/events").Listener[] | undefined;
|
|
101
89
|
hasListener: (type?: string | undefined) => boolean;
|
|
102
90
|
dispose: () => void;
|
|
103
91
|
};
|
|
104
|
-
} & typeof
|
|
92
|
+
} & typeof OLLayer;
|
|
105
93
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @private
|
|
94
|
+
* An OpenLayers layer here only for backward compatibility v2.
|
|
95
|
+
* @deprecated
|
|
109
96
|
*/
|
|
110
|
-
declare class
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
get apiKey(): string;
|
|
114
|
-
set apiKey(newValue: string);
|
|
115
|
-
get apiKeyName(): string;
|
|
116
|
-
set apiKeyName(newValue: string);
|
|
117
|
-
get style(): string;
|
|
118
|
-
set style(newValue: string);
|
|
119
|
-
get url(): string;
|
|
120
|
-
set url(newValue: string);
|
|
121
|
-
get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions;
|
|
122
|
-
set queryRenderedFeaturesOptions(newValue: maplibregl.QueryRenderedFeaturesOptions);
|
|
123
|
-
constructor(options: MapGlLayerOptions);
|
|
124
|
-
/**
|
|
125
|
-
* Initialize the layer and listen to feature clicks.
|
|
126
|
-
* @param {ol/Map~Map} map
|
|
127
|
-
*/
|
|
128
|
-
attachToMap(map: OlMap): void;
|
|
129
|
-
/**
|
|
130
|
-
* Terminate what was initialized in init function. Remove layer, events...
|
|
131
|
-
*/
|
|
132
|
-
detachFromMap(): void;
|
|
133
|
-
/**
|
|
134
|
-
* Create the Maplibre map.
|
|
135
|
-
* @private
|
|
136
|
-
*/
|
|
137
|
-
loadMbMap(): void;
|
|
138
|
-
getStyle(): string;
|
|
139
|
-
createMap(options: {
|
|
140
|
-
[id: string]: any;
|
|
141
|
-
}): AnyMapGlMap;
|
|
142
|
-
updateMbMap(): void;
|
|
97
|
+
declare class Layer extends Layer_base {
|
|
98
|
+
constructor(options: MobilityLayerOptions);
|
|
99
|
+
clone(newOptions: MobilityLayerOptions): Layer;
|
|
143
100
|
}
|
|
144
|
-
export default
|
|
101
|
+
export default Layer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import OLLayer from 'ol/layer/Layer';
|
|
2
|
+
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
3
|
+
/**
|
|
4
|
+
* An OpenLayers layer here only for backward compatibility v2.
|
|
5
|
+
* @deprecated
|
|
6
|
+
*/
|
|
7
|
+
class Layer extends MobilityLayerMixin(OLLayer) {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
super(options);
|
|
10
|
+
// eslint-disable-next-line no-console
|
|
11
|
+
console.warn('Layer is deprecated. Use an OpenLayers Layer instead.');
|
|
12
|
+
}
|
|
13
|
+
clone(newOptions) {
|
|
14
|
+
return new Layer(Object.assign(Object.assign({}, (this.options || {})), (newOptions || {})));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export default Layer;
|
|
@@ -1,11 +1,110 @@
|
|
|
1
|
+
import Source from 'ol/source/Source';
|
|
2
|
+
import OlMap from 'ol/Map';
|
|
3
|
+
import BaseEvent from 'ol/events/Event';
|
|
4
|
+
import Layer from 'ol/layer/Layer';
|
|
1
5
|
import { Map, MapOptions } from 'maplibre-gl';
|
|
2
|
-
import
|
|
6
|
+
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
3
7
|
import MaplibreLayerRenderer from '../renderers/MaplibreLayerRenderer';
|
|
4
|
-
export type MaplibreLayerOptions =
|
|
5
|
-
|
|
8
|
+
export type MaplibreLayerOptions = MobilityLayerOptions & {
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
apiKeyName?: string;
|
|
11
|
+
style?: string | maplibregl.StyleSpecification;
|
|
12
|
+
url?: string;
|
|
13
|
+
mapOptions?: maplibregl.MapOptions;
|
|
14
|
+
queryRenderedFeaturesOptions?: maplibregl.QueryRenderedFeaturesOptions;
|
|
6
15
|
};
|
|
16
|
+
declare const MaplibreLayer_base: {
|
|
17
|
+
new (...args: any[]): {
|
|
18
|
+
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions | undefined;
|
|
19
|
+
olListenersKeys: import("ol/events").EventsKey[];
|
|
20
|
+
children: Layer<Source, import("ol/renderer/Layer").default<any>>[];
|
|
21
|
+
get copyrights(): string;
|
|
22
|
+
set copyrights(newCopyrights: string | string[]);
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
readonly group: string;
|
|
25
|
+
readonly hitTolerance: boolean;
|
|
26
|
+
readonly key: string;
|
|
27
|
+
readonly map: OlMap;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
olLayer: Layer<Source, import("ol/renderer/Layer").default<any>>;
|
|
30
|
+
parent: Layer<Source, import("ol/renderer/Layer").default<any>>;
|
|
31
|
+
visible: boolean;
|
|
32
|
+
setMapInternal: ((map: OlMap) => void) & ((map: OlMap | null) => void);
|
|
33
|
+
onChildrenChange(oldValue: Layer<Source, import("ol/renderer/Layer").default<any>>[]): void;
|
|
34
|
+
attachToMap(map: OlMap): void;
|
|
35
|
+
detachFromMap(): void;
|
|
36
|
+
flat(): any[];
|
|
37
|
+
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
38
|
+
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
39
|
+
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
40
|
+
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
41
|
+
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
42
|
+
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
43
|
+
getSource: () => Source | null;
|
|
44
|
+
getRenderSource: () => Source | null;
|
|
45
|
+
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<import("ol/Feature").FeatureLike[]>;
|
|
46
|
+
getData: (pixel: import("ol/pixel").Pixel) => Float32Array | Uint8ClampedArray | Uint8Array | DataView | null;
|
|
47
|
+
isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
48
|
+
getAttributions: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => string[];
|
|
49
|
+
unrender: () => void;
|
|
50
|
+
getDeclutter: () => string;
|
|
51
|
+
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
52
|
+
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
53
|
+
getMapInternal: () => OlMap | null;
|
|
54
|
+
setMap: (map: OlMap | null) => void;
|
|
55
|
+
setSource: (source: Source | null) => void;
|
|
56
|
+
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
57
|
+
hasRenderer: () => boolean;
|
|
58
|
+
getBackground: () => false | import("ol/layer/Base").BackgroundColor;
|
|
59
|
+
getClassName: () => string;
|
|
60
|
+
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
61
|
+
getLayersArray: (array?: Layer<Source, import("ol/renderer/Layer").default<any>>[] | undefined) => Layer<Source, import("ol/renderer/Layer").default<any>>[];
|
|
62
|
+
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => import("ol/layer/Layer").State[];
|
|
63
|
+
getExtent: () => import("ol/extent").Extent | undefined;
|
|
64
|
+
getMaxResolution: () => number;
|
|
65
|
+
getMinResolution: () => number;
|
|
66
|
+
getMinZoom: () => number;
|
|
67
|
+
getMaxZoom: () => number;
|
|
68
|
+
getOpacity: () => number;
|
|
69
|
+
getSourceState: () => import("ol/source/Source").State;
|
|
70
|
+
getVisible: () => boolean;
|
|
71
|
+
getZIndex: () => number | undefined;
|
|
72
|
+
setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
|
|
73
|
+
setExtent: (extent: import("ol/extent").Extent | undefined) => void;
|
|
74
|
+
setMaxResolution: (maxResolution: number) => void;
|
|
75
|
+
setMinResolution: (minResolution: number) => void;
|
|
76
|
+
setMaxZoom: (maxZoom: number) => void;
|
|
77
|
+
setMinZoom: (minZoom: number) => void;
|
|
78
|
+
setOpacity: (opacity: number) => void;
|
|
79
|
+
setVisible: (visible: boolean) => void;
|
|
80
|
+
setZIndex: (zindex: number) => void;
|
|
81
|
+
get: (key: string) => any;
|
|
82
|
+
getKeys: () => string[];
|
|
83
|
+
getProperties: () => {
|
|
84
|
+
[x: string]: any;
|
|
85
|
+
};
|
|
86
|
+
getPropertiesInternal: () => {
|
|
87
|
+
[x: string]: any;
|
|
88
|
+
} | null;
|
|
89
|
+
hasProperties: () => boolean;
|
|
90
|
+
notify: (key: string, oldValue: any) => void;
|
|
91
|
+
addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
92
|
+
removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
93
|
+
set: (key: string, value: any, silent?: boolean | undefined) => void;
|
|
94
|
+
setProperties: (values: {
|
|
95
|
+
[x: string]: any;
|
|
96
|
+
}, silent?: boolean | undefined) => void;
|
|
97
|
+
unset: (key: string, silent?: boolean | undefined) => void;
|
|
98
|
+
changed: () => void;
|
|
99
|
+
getRevision: () => number;
|
|
100
|
+
dispatchEvent: (event: string | BaseEvent) => boolean | undefined;
|
|
101
|
+
getListeners: (type: string) => import("ol/events").Listener[] | undefined;
|
|
102
|
+
hasListener: (type?: string | undefined) => boolean;
|
|
103
|
+
dispose: () => void;
|
|
104
|
+
};
|
|
105
|
+
} & typeof Layer;
|
|
7
106
|
/**
|
|
8
|
-
*
|
|
107
|
+
* An OpenLayers layer able to display data from the [geOps Maps API](https://developer.geops.io/apis/maps).
|
|
9
108
|
*
|
|
10
109
|
* @example
|
|
11
110
|
* import { MaplibreLayer } from 'mobility-toolbox-js/ol';
|
|
@@ -31,29 +130,49 @@ export type MaplibreLayerOptions = MapGlLayerOptions & {
|
|
|
31
130
|
* @extends {ol/layer/Layer~Layer}
|
|
32
131
|
* @public
|
|
33
132
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
get
|
|
133
|
+
declare class MaplibreLayer extends MaplibreLayer_base {
|
|
134
|
+
loaded: boolean;
|
|
135
|
+
maplibreMap?: Map;
|
|
136
|
+
get apiKey(): string;
|
|
137
|
+
set apiKey(newValue: string);
|
|
138
|
+
get apiKeyName(): string;
|
|
139
|
+
set apiKeyName(newValue: string);
|
|
140
|
+
get mbMap(): maplibregl.Map | undefined;
|
|
141
|
+
get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions;
|
|
142
|
+
set queryRenderedFeaturesOptions(newValue: maplibregl.QueryRenderedFeaturesOptions);
|
|
143
|
+
get style(): string;
|
|
144
|
+
set style(newValue: string);
|
|
145
|
+
get url(): string;
|
|
146
|
+
set url(newValue: string);
|
|
38
147
|
/**
|
|
39
148
|
* Constructor.
|
|
40
149
|
*
|
|
41
150
|
* @param {MaplibreLayerOptions} options
|
|
42
151
|
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
43
|
-
* @param {string} [options.apiKeyName="key"] The geOps Maps
|
|
152
|
+
* @param {string} [options.apiKeyName="key"] The geOps Maps API key name.
|
|
44
153
|
* @param {maplibregl.MapOptions} [options.mapOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
|
|
45
|
-
* @param {string} [options.style="travic_v2"] The geOps Maps
|
|
46
|
-
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps
|
|
154
|
+
* @param {string} [options.style="travic_v2"] The geOps Maps API style.
|
|
155
|
+
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
47
156
|
*/
|
|
48
157
|
constructor(options: MaplibreLayerOptions);
|
|
49
158
|
/**
|
|
50
|
-
*
|
|
159
|
+
* Initialize the layer and listen to feature clicks.
|
|
160
|
+
* @param {ol/Map~Map} map
|
|
51
161
|
*/
|
|
52
|
-
|
|
162
|
+
attachToMap(map: OlMap): void;
|
|
53
163
|
/**
|
|
164
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
165
|
+
*/
|
|
166
|
+
detachFromMap(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Create the Maplibre map.
|
|
54
169
|
* @private
|
|
55
170
|
*/
|
|
171
|
+
loadMbMap(): void;
|
|
172
|
+
getStyle(): string;
|
|
56
173
|
createMap(options: MapOptions): Map;
|
|
174
|
+
createRenderer(): MaplibreLayerRenderer;
|
|
175
|
+
updateMaplibreMap(): void;
|
|
57
176
|
/**
|
|
58
177
|
* Create a copy of the MaplibreLayer.
|
|
59
178
|
* @param {MaplibreLayerOptions} newOptions Options to override
|
|
@@ -61,3 +180,4 @@ export default class MaplibreLayer extends MapGlLayer {
|
|
|
61
180
|
*/
|
|
62
181
|
clone(newOptions: MaplibreLayerOptions): MaplibreLayer;
|
|
63
182
|
}
|
|
183
|
+
export default MaplibreLayer;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import Source from 'ol/source/Source';
|
|
2
|
+
import BaseEvent from 'ol/events/Event';
|
|
3
|
+
import Layer from 'ol/layer/Layer';
|
|
4
|
+
import debounce from 'lodash.debounce';
|
|
1
5
|
import { Map } from 'maplibre-gl';
|
|
2
|
-
import
|
|
6
|
+
import { getUrlWithParams, getMapGlCopyrights } from '../../common/utils';
|
|
7
|
+
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
3
8
|
import MaplibreLayerRenderer from '../renderers/MaplibreLayerRenderer';
|
|
4
9
|
/**
|
|
5
|
-
*
|
|
10
|
+
* An OpenLayers layer able to display data from the [geOps Maps API](https://developer.geops.io/apis/maps).
|
|
6
11
|
*
|
|
7
12
|
* @example
|
|
8
13
|
* import { MaplibreLayer } from 'mobility-toolbox-js/ol';
|
|
@@ -28,37 +33,154 @@ import MaplibreLayerRenderer from '../renderers/MaplibreLayerRenderer';
|
|
|
28
33
|
* @extends {ol/layer/Layer~Layer}
|
|
29
34
|
* @public
|
|
30
35
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
class MaplibreLayer extends MobilityLayerMixin(Layer) {
|
|
37
|
+
get apiKey() {
|
|
38
|
+
return this.get('apiKey');
|
|
39
|
+
}
|
|
40
|
+
set apiKey(newValue) {
|
|
41
|
+
this.set('apiKey', newValue);
|
|
42
|
+
}
|
|
43
|
+
get apiKeyName() {
|
|
44
|
+
return this.get('apiKeyName');
|
|
45
|
+
}
|
|
46
|
+
set apiKeyName(newValue) {
|
|
47
|
+
this.set('apiKeyName', newValue);
|
|
48
|
+
}
|
|
49
|
+
get mbMap() {
|
|
50
|
+
console.warn('Deprecated. Use layer.maplibreMap.');
|
|
51
|
+
return this.maplibreMap;
|
|
52
|
+
}
|
|
53
|
+
get queryRenderedFeaturesOptions() {
|
|
54
|
+
return this.get('queryRenderedFeaturesOptions');
|
|
55
|
+
}
|
|
56
|
+
set queryRenderedFeaturesOptions(newValue) {
|
|
57
|
+
this.set('queryRenderedFeaturesOptions', newValue);
|
|
58
|
+
}
|
|
59
|
+
get style() {
|
|
60
|
+
return this.get('style');
|
|
61
|
+
}
|
|
62
|
+
set style(newValue) {
|
|
63
|
+
this.set('style', newValue);
|
|
64
|
+
}
|
|
65
|
+
get url() {
|
|
66
|
+
return this.get('url');
|
|
67
|
+
}
|
|
68
|
+
set url(newValue) {
|
|
69
|
+
this.set('url', newValue);
|
|
35
70
|
}
|
|
36
71
|
/**
|
|
37
72
|
* Constructor.
|
|
38
73
|
*
|
|
39
74
|
* @param {MaplibreLayerOptions} options
|
|
40
75
|
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
41
|
-
* @param {string} [options.apiKeyName="key"] The geOps Maps
|
|
76
|
+
* @param {string} [options.apiKeyName="key"] The geOps Maps API key name.
|
|
42
77
|
* @param {maplibregl.MapOptions} [options.mapOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
|
|
43
|
-
* @param {string} [options.style="travic_v2"] The geOps Maps
|
|
44
|
-
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps
|
|
78
|
+
* @param {string} [options.style="travic_v2"] The geOps Maps API style.
|
|
79
|
+
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
45
80
|
*/
|
|
46
81
|
constructor(options) {
|
|
47
|
-
super(Object.assign({
|
|
82
|
+
super(Object.assign(Object.assign({ source: new Source({
|
|
83
|
+
attributions: () => {
|
|
84
|
+
return ((this.maplibreMap && getMapGlCopyrights(this.maplibreMap)) || []);
|
|
85
|
+
},
|
|
86
|
+
}), apiKeyName: 'key', style: 'travic_v2', url: 'https://maps.geops.io' }, (options || {})), {
|
|
87
|
+
// @ts-expect-error mapOptions must be saved by the mixin in this.options
|
|
88
|
+
mapOptions: Object.assign({ interactive: false, trackResize: false, attributionControl: false }, ((options === null || options === void 0 ? void 0 : options.mapOptions) || {})), queryRenderedFeaturesOptions: Object.assign({}, ((options === null || options === void 0 ? void 0 : options.queryRenderedFeaturesOptions) || {})) }));
|
|
48
89
|
}
|
|
49
90
|
/**
|
|
50
|
-
*
|
|
91
|
+
* Initialize the layer and listen to feature clicks.
|
|
92
|
+
* @param {ol/Map~Map} map
|
|
51
93
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
94
|
+
attachToMap(map) {
|
|
95
|
+
super.attachToMap(map);
|
|
96
|
+
this.loadMbMap();
|
|
97
|
+
const updateMaplibreMapDebounced = debounce(this.updateMaplibreMap.bind(this), 150);
|
|
98
|
+
this.olListenersKeys.push(this.on('propertychange', (evt) => {
|
|
99
|
+
if (/(apiKey|apiKeyName|url|style)/.test(evt.key)) {
|
|
100
|
+
updateMaplibreMapDebounced();
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
106
|
+
*/
|
|
107
|
+
detachFromMap() {
|
|
108
|
+
if (this.maplibreMap) {
|
|
109
|
+
// Some asynchrone repaints are triggered even if the mbMap has been removed,
|
|
110
|
+
// to avoid display of errors we set an empty function.
|
|
111
|
+
this.maplibreMap.triggerRepaint = () => { };
|
|
112
|
+
this.maplibreMap.remove();
|
|
113
|
+
this.maplibreMap = undefined;
|
|
114
|
+
}
|
|
115
|
+
this.loaded = false;
|
|
116
|
+
super.detachFromMap();
|
|
54
117
|
}
|
|
55
118
|
/**
|
|
119
|
+
* Create the Maplibre map.
|
|
56
120
|
* @private
|
|
57
121
|
*/
|
|
122
|
+
loadMbMap() {
|
|
123
|
+
var _a, _b, _c;
|
|
124
|
+
this.loaded = false;
|
|
125
|
+
this.olListenersKeys.push(
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.on('change:target', this.loadMbMap.bind(this)));
|
|
128
|
+
if (!((_b = this.map) === null || _b === void 0 ? void 0 : _b.getTargetElement())) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!this.visible) {
|
|
132
|
+
// On next change of visibility we load the map
|
|
133
|
+
this.olListenersKeys.push(
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
this.once('change:visible', this.loadMbMap.bind(this)));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const container = document.createElement('div');
|
|
139
|
+
container.style.position = 'absolute';
|
|
140
|
+
container.style.width = '100%';
|
|
141
|
+
container.style.height = '100%';
|
|
142
|
+
/**
|
|
143
|
+
* A Maplibre map
|
|
144
|
+
* @type {maplibregl.Map}
|
|
145
|
+
*/
|
|
146
|
+
this.maplibreMap = this.createMap(Object.assign({ style: this.getStyle(), container }, (((_c = this.options) === null || _c === void 0 ? void 0 : _c.mapOptions) || {})));
|
|
147
|
+
this.maplibreMap.on('sourcedata', () => {
|
|
148
|
+
var _a;
|
|
149
|
+
(_a = this.getSource()) === null || _a === void 0 ? void 0 : _a.refresh(); // Refresh attribution
|
|
150
|
+
});
|
|
151
|
+
this.maplibreMap.once('load', () => {
|
|
152
|
+
this.loaded = true;
|
|
153
|
+
this.dispatchEvent(new BaseEvent('load'));
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
getStyle() {
|
|
157
|
+
// If the style is a complete style object, use it directly.
|
|
158
|
+
if (this.style &&
|
|
159
|
+
typeof this.style === 'object' &&
|
|
160
|
+
this.style.name &&
|
|
161
|
+
this.style.version) {
|
|
162
|
+
return this.style;
|
|
163
|
+
}
|
|
164
|
+
// If the url set is already a complete style url, use it directly.
|
|
165
|
+
if (this.url.includes('style.json')) {
|
|
166
|
+
return this.url;
|
|
167
|
+
}
|
|
168
|
+
/// Otherwise build the complete style url.
|
|
169
|
+
return getUrlWithParams(`${this.url}/styles/${this.style}/style.json`, {
|
|
170
|
+
[this.apiKeyName]: this.apiKey,
|
|
171
|
+
}).toString();
|
|
172
|
+
}
|
|
58
173
|
// eslint-disable-next-line class-methods-use-this
|
|
59
174
|
createMap(options) {
|
|
60
175
|
return new Map(options);
|
|
61
176
|
}
|
|
177
|
+
createRenderer() {
|
|
178
|
+
return new MaplibreLayerRenderer(this);
|
|
179
|
+
}
|
|
180
|
+
updateMaplibreMap() {
|
|
181
|
+
var _a;
|
|
182
|
+
(_a = this.maplibreMap) === null || _a === void 0 ? void 0 : _a.setStyle(this.getStyle(), { diff: false });
|
|
183
|
+
}
|
|
62
184
|
/**
|
|
63
185
|
* Create a copy of the MaplibreLayer.
|
|
64
186
|
* @param {MaplibreLayerOptions} newOptions Options to override
|
|
@@ -68,3 +190,4 @@ export default class MaplibreLayer extends MapGlLayer {
|
|
|
68
190
|
return new MaplibreLayer(Object.assign(Object.assign({}, (this.options || {})), (newOptions || {})));
|
|
69
191
|
}
|
|
70
192
|
}
|
|
193
|
+
export default MaplibreLayer;
|
|
@@ -2,6 +2,7 @@ import { Feature, Map } from 'ol';
|
|
|
2
2
|
import { Coordinate } from 'ol/coordinate';
|
|
3
3
|
import { ObjectEvent } from 'ol/Object';
|
|
4
4
|
import { Layer } from 'ol/layer';
|
|
5
|
+
import { FeatureState } from 'maplibre-gl';
|
|
5
6
|
import { Source } from 'ol/source';
|
|
6
7
|
import { LayerGetFeatureInfoResponse } from '../../types';
|
|
7
8
|
import { FilterFunction } from '../../common/typedefs';
|
|
@@ -194,6 +195,13 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
194
195
|
* @private
|
|
195
196
|
*/
|
|
196
197
|
onLoad(): void;
|
|
198
|
+
/**
|
|
199
|
+
* Set the feature state of the features.
|
|
200
|
+
* @param {Array<ol/Feature~Feature>} features
|
|
201
|
+
* @param {{[key:string]:boolean}} state The feature state
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
setFeatureState(features: Feature[], state: FeatureState): void;
|
|
197
205
|
/**
|
|
198
206
|
* Request feature information for a given coordinate.
|
|
199
207
|
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
@@ -221,8 +229,6 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
221
229
|
highlight(features?: Feature[]): void;
|
|
222
230
|
/**
|
|
223
231
|
* Apply visibility to style layers that fits the styleLayersFilter function.
|
|
224
|
-
*
|
|
225
|
-
* @private
|
|
226
232
|
*/
|
|
227
233
|
applyLayoutVisibility(evt?: ObjectEvent): void;
|
|
228
234
|
/**
|