mobility-toolbox-js 3.0.0-beta.9 → 3.0.1-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/HttpAPI.d.ts +5 -16
- package/api/HttpAPI.js +0 -11
- package/api/RealtimeAPI.d.ts +221 -176
- package/api/RealtimeAPI.js +317 -258
- package/api/RoutingAPI.d.ts +21 -11
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +20 -14
- package/api/StopsAPI.js +17 -11
- package/api/WebSocketAPI.d.ts +60 -66
- package/api/WebSocketAPI.js +164 -164
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +0 -102
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +12 -12
- package/common/controls/StopFinderControlCommon.js +31 -31
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +157 -163
- package/common/mixins/RealtimeLayerMixin.js +401 -393
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/typedefs.d.ts +13 -6
- package/common/typedefs.js +7 -1
- 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/getMapGlCopyrights.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getVehiclePosition.d.ts +5 -4
- package/common/utils/getVehiclePosition.js +9 -3
- package/common/utils/renderTrajectories.d.ts +1 -1
- package/common/utils/renderTrajectories.js +6 -6
- 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 +87 -66
- package/maplibre/layers/RealtimeLayer.js +30 -6
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/mbt.js +20988 -13287
- package/mbt.js.map +4 -4
- package/mbt.min.js +61 -58
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +82 -89
- package/ol/controls/RoutingControl.js +217 -219
- package/ol/controls/StopFinderControl.d.ts +3 -3
- package/ol/controls/StopFinderControl.js +2 -2
- package/ol/index.d.ts +1 -0
- package/ol/index.js +1 -0
- package/ol/layers/Layer.d.ts +101 -0
- package/ol/layers/Layer.js +25 -0
- package/ol/layers/MaplibreLayer.d.ts +121 -24
- package/ol/layers/MaplibreLayer.js +98 -27
- package/ol/layers/MaplibreStyleLayer.d.ts +93 -91
- package/ol/layers/MaplibreStyleLayer.js +281 -257
- package/ol/layers/RealtimeLayer.d.ts +119 -121
- package/ol/layers/RealtimeLayer.js +143 -134
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +32 -0
- package/ol/layers/index.d.ts +2 -0
- package/ol/layers/index.js +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +32 -34
- package/ol/mixins/PropertiesLayerMixin.d.ts +60 -51
- package/ol/mixins/PropertiesLayerMixin.js +114 -79
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +6 -6
- package/ol/renderers/RealtimeLayerRenderer.js +56 -51
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
- package/package.json +31 -31
- 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.d.ts +0 -144
- package/ol/layers/MapGlLayer.js +0 -144
|
@@ -1,46 +1,27 @@
|
|
|
1
|
-
import { Layer } from 'ol/layer';
|
|
2
|
-
import { EventsKey } from 'ol/events';
|
|
3
1
|
import { Map } from 'ol';
|
|
2
|
+
import { EventsKey } from 'ol/events';
|
|
3
|
+
import { Layer } from 'ol/layer';
|
|
4
4
|
import type { Options } from 'ol/layer/Layer';
|
|
5
5
|
import type { Layerable } from './MobilityLayerMixin';
|
|
6
|
-
export type PropertiesLayerMixinOptions =
|
|
7
|
-
key?: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
group?: string;
|
|
10
|
-
copyrights?: string[];
|
|
6
|
+
export type PropertiesLayerMixinOptions = {
|
|
11
7
|
children?: any[];
|
|
12
|
-
|
|
8
|
+
copyrights?: string[];
|
|
13
9
|
disabled?: boolean;
|
|
10
|
+
group?: string;
|
|
14
11
|
hitTolerance?: number;
|
|
15
|
-
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
};
|
|
12
|
+
key?: string;
|
|
18
13
|
map?: Map;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
name?: string;
|
|
15
|
+
properties?: Record<string, any>;
|
|
16
|
+
visible?: boolean;
|
|
17
|
+
} & Options & Record<string, any>;
|
|
22
18
|
/**
|
|
23
19
|
* This mixin adds some properties to access ol custom properties easily.
|
|
24
20
|
*/
|
|
25
21
|
declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
26
22
|
new (...args: any[]): {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
children: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[];
|
|
30
|
-
get copyrights(): string;
|
|
31
|
-
set copyrights(newCopyrights: string | string[]);
|
|
32
|
-
disabled: boolean;
|
|
33
|
-
readonly group: string;
|
|
34
|
-
readonly hitTolerance: boolean;
|
|
35
|
-
readonly key: string;
|
|
36
|
-
readonly map: Map;
|
|
37
|
-
readonly name: string;
|
|
38
|
-
olLayer: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>;
|
|
39
|
-
parent: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>;
|
|
40
|
-
visible: boolean;
|
|
41
|
-
setMapInternal(map: Map): void;
|
|
42
|
-
/** @private */
|
|
43
|
-
onChildrenChange(oldValue: Layer[]): void;
|
|
23
|
+
olEventsKeys: EventsKey[];
|
|
24
|
+
options?: PropertiesLayerMixinOptions;
|
|
44
25
|
/**
|
|
45
26
|
* Initialize the layer with the map passed in parameters.
|
|
46
27
|
*
|
|
@@ -53,34 +34,60 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
53
34
|
detachFromMap(): void;
|
|
54
35
|
/**
|
|
55
36
|
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
37
|
+
* @deprecated
|
|
56
38
|
*/
|
|
57
39
|
flat(): any[];
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
40
|
+
/** @private */
|
|
41
|
+
onChildrenChange(oldValue: Layer[]): void;
|
|
42
|
+
setMapInternal(map: Map): void;
|
|
43
|
+
/** @deprecated */
|
|
44
|
+
children: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
45
|
+
/** @deprecated */
|
|
46
|
+
get copyrights(): string;
|
|
47
|
+
/** @deprecated */
|
|
48
|
+
set copyrights(newCopyrights: string | string[]);
|
|
49
|
+
/** @deprecated */
|
|
50
|
+
disabled: boolean;
|
|
51
|
+
/** @deprecated */
|
|
52
|
+
/** @deprecated */
|
|
53
|
+
readonly group: string;
|
|
54
|
+
/** @deprecated */
|
|
55
|
+
readonly hitTolerance: number;
|
|
56
|
+
readonly key: string;
|
|
57
|
+
readonly map: Map;
|
|
58
|
+
/** @deprecated */
|
|
59
|
+
readonly name: string;
|
|
60
|
+
/** @deprecated */
|
|
61
|
+
olLayer: Layer;
|
|
62
|
+
/** @deprecated */
|
|
63
|
+
/** @deprecated */
|
|
64
|
+
parent: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
65
|
+
/** @deprecated */
|
|
66
|
+
visible: boolean;
|
|
67
|
+
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
68
|
+
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
63
69
|
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
71
|
+
getSource: () => import("ol/source").Source | null;
|
|
72
|
+
getRenderSource: () => import("ol/source").Source | null;
|
|
73
|
+
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
|
|
74
|
+
getData: (pixel: import("ol/pixel").Pixel) => Uint8ClampedArray | Uint8Array | Float32Array | DataView | null;
|
|
75
|
+
isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
76
|
+
getAttributions: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => Array<string>;
|
|
70
77
|
unrender: () => void;
|
|
71
78
|
getDeclutter: () => string;
|
|
72
79
|
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
73
80
|
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
74
|
-
getMapInternal: () => Map | null;
|
|
75
|
-
setMap: (map: Map | null) => void;
|
|
76
|
-
setSource: (source: import("ol/source
|
|
81
|
+
getMapInternal: () => import("ol/Map").default | null;
|
|
82
|
+
setMap: (map: import("ol/Map").default | null) => void;
|
|
83
|
+
setSource: (source: import("ol/source").Source | null) => void;
|
|
77
84
|
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
78
85
|
hasRenderer: () => boolean;
|
|
79
|
-
getBackground: () =>
|
|
86
|
+
getBackground: () => import("ol/layer/Base").BackgroundColor | false;
|
|
80
87
|
getClassName: () => string;
|
|
81
88
|
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
82
|
-
getLayersArray: (array?: Layer<import("ol/source
|
|
83
|
-
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => import("ol/layer/Layer").State
|
|
89
|
+
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
|
|
90
|
+
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
|
|
84
91
|
getExtent: () => import("ol/extent").Extent | undefined;
|
|
85
92
|
getMaxResolution: () => number;
|
|
86
93
|
getMinResolution: () => number;
|
|
@@ -100,7 +107,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
100
107
|
setVisible: (visible: boolean) => void;
|
|
101
108
|
setZIndex: (zindex: number) => void;
|
|
102
109
|
get: (key: string) => any;
|
|
103
|
-
getKeys: () => string
|
|
110
|
+
getKeys: () => Array<string>;
|
|
104
111
|
getProperties: () => {
|
|
105
112
|
[x: string]: any;
|
|
106
113
|
};
|
|
@@ -118,9 +125,11 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
118
125
|
unset: (key: string, silent?: boolean | undefined) => void;
|
|
119
126
|
changed: () => void;
|
|
120
127
|
getRevision: () => number;
|
|
121
|
-
|
|
122
|
-
|
|
128
|
+
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
129
|
+
dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
|
|
130
|
+
getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
|
|
123
131
|
hasListener: (type?: string | undefined) => boolean;
|
|
132
|
+
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
124
133
|
dispose: () => void;
|
|
125
134
|
};
|
|
126
135
|
} & TBase;
|
|
@@ -1,41 +1,132 @@
|
|
|
1
|
+
// eslint-disable-next-line max-classes-per-file
|
|
2
|
+
import debounce from 'lodash.debounce';
|
|
1
3
|
import { getUid } from 'ol';
|
|
2
4
|
import getLayersAsFlatArray from '../../common/utils/getLayersAsFlatArray';
|
|
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
|
+
}
|
|
3
13
|
/**
|
|
4
14
|
* This mixin adds some properties to access ol custom properties easily.
|
|
5
15
|
*/
|
|
6
16
|
function PropertiesLayerMixin(Base) {
|
|
7
17
|
return class PropertiesLayer extends Base {
|
|
18
|
+
constructor(...args) {
|
|
19
|
+
var _a;
|
|
20
|
+
const options = args[0];
|
|
21
|
+
super(options);
|
|
22
|
+
this.olEventsKeys = [];
|
|
23
|
+
this.options = {};
|
|
24
|
+
if (options.properties) {
|
|
25
|
+
deprecated("Deprecated. Don't use properties options. Pass the values directly in options object.");
|
|
26
|
+
this.setProperties(options.properties);
|
|
27
|
+
}
|
|
28
|
+
(_a = this.olEventsKeys) === null || _a === void 0 ? void 0 : _a.push(
|
|
29
|
+
// Update parent property
|
|
30
|
+
this.on('propertychange', (evt) => {
|
|
31
|
+
if (evt.key === 'children') {
|
|
32
|
+
this.onChildrenChange(evt.oldValue);
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
this.options = options;
|
|
36
|
+
this.set('children', options.children || []); // Trigger the on children change event
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Initialize the layer with the map passed in parameters.
|
|
40
|
+
*
|
|
41
|
+
* @param {ol/Map~Map} map A map.
|
|
42
|
+
*/
|
|
43
|
+
attachToMap(map) {
|
|
44
|
+
// @ts-expect-error attachToMap not necessarily exists
|
|
45
|
+
(super.attachToMap || (() => { }))(map);
|
|
46
|
+
(this.get('children') || []).forEach((child) => {
|
|
47
|
+
map.addLayer(child);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
52
|
+
*/
|
|
53
|
+
detachFromMap() {
|
|
54
|
+
(this.get('children') || []).forEach((child) => {
|
|
55
|
+
this.map.removeLayer(child);
|
|
56
|
+
});
|
|
57
|
+
// @ts-expect-error detachToMap not necessarily exists
|
|
58
|
+
(super.detachFromMap || (() => { }))();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
62
|
+
* @deprecated
|
|
63
|
+
*/
|
|
64
|
+
flat() {
|
|
65
|
+
deprecated('Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead.');
|
|
66
|
+
return getLayersAsFlatArray(this);
|
|
67
|
+
}
|
|
68
|
+
/** @private */
|
|
69
|
+
onChildrenChange(oldValue) {
|
|
70
|
+
// Set the parent property
|
|
71
|
+
(oldValue || []).forEach((child) => {
|
|
72
|
+
child.set('parent', undefined);
|
|
73
|
+
});
|
|
74
|
+
(this.get('children') || []).forEach((child) => {
|
|
75
|
+
child.set('parent', this);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// @ts-expect-error - this is a mixin
|
|
79
|
+
setMapInternal(map) {
|
|
80
|
+
super.setMapInternal(map);
|
|
81
|
+
if (map) {
|
|
82
|
+
this.attachToMap(map);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.detachFromMap();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** @deprecated */
|
|
8
89
|
get children() {
|
|
90
|
+
deprecated("Layer.children is deprecated. Use the Layer.get('children') method instead.");
|
|
9
91
|
return this.get('children') || [];
|
|
10
92
|
}
|
|
93
|
+
/** @deprecated */
|
|
11
94
|
set children(newValue) {
|
|
95
|
+
deprecated("Layer.children is deprecated. Use the Layer.set('children', children) method instead.");
|
|
12
96
|
this.set('children', newValue || []);
|
|
13
97
|
}
|
|
98
|
+
/** @deprecated */
|
|
14
99
|
get copyrights() {
|
|
15
|
-
|
|
16
|
-
console.warn('Deprecated. Use the source object to get the attributions');
|
|
100
|
+
deprecated('Layer.copyrights is deprecated. Get the attributions from the source object');
|
|
17
101
|
return this.get('copyrights');
|
|
18
102
|
}
|
|
103
|
+
/** @deprecated */
|
|
19
104
|
set copyrights(newCopyrights) {
|
|
20
|
-
|
|
21
|
-
console.warn('Deprecated. Use the source object to set the attributions');
|
|
105
|
+
deprecated('Layer.copyrights is deprecated. Set the attributions to the source object.');
|
|
22
106
|
const arrValue = newCopyrights && !Array.isArray(newCopyrights)
|
|
23
107
|
? [newCopyrights]
|
|
24
108
|
: newCopyrights;
|
|
25
109
|
this.set('copyrights', arrValue || []);
|
|
26
110
|
}
|
|
111
|
+
/** @deprecated */
|
|
27
112
|
get disabled() {
|
|
113
|
+
deprecated("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead.");
|
|
28
114
|
return this.get('disabled');
|
|
29
115
|
}
|
|
116
|
+
/** @deprecated */
|
|
30
117
|
set disabled(newValue) {
|
|
118
|
+
deprecated("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead.");
|
|
31
119
|
this.set('disabled', newValue);
|
|
32
120
|
}
|
|
121
|
+
/** @deprecated */
|
|
122
|
+
/** @deprecated */
|
|
33
123
|
get group() {
|
|
124
|
+
deprecated("Layer.group is deprecated. Use the Layer.get('group') method instead.");
|
|
34
125
|
return this.get('group');
|
|
35
126
|
}
|
|
127
|
+
/** @deprecated */
|
|
36
128
|
get hitTolerance() {
|
|
37
|
-
|
|
38
|
-
console.warn('Deprecated. Pass the pixelTolerance when you request the features.');
|
|
129
|
+
deprecated('Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features.');
|
|
39
130
|
return this.get('hitTolerance') || 5;
|
|
40
131
|
}
|
|
41
132
|
get key() {
|
|
@@ -44,100 +135,44 @@ function PropertiesLayerMixin(Base) {
|
|
|
44
135
|
get map() {
|
|
45
136
|
return this.getMapInternal();
|
|
46
137
|
}
|
|
138
|
+
/** @deprecated */
|
|
47
139
|
get name() {
|
|
140
|
+
deprecated("Layer.name is deprecated. Use the Layer.get('name') method instead.");
|
|
48
141
|
return this.get('name');
|
|
49
142
|
}
|
|
143
|
+
/** @deprecated */
|
|
50
144
|
get olLayer() {
|
|
51
|
-
|
|
52
|
-
console.warn("Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object.");
|
|
145
|
+
deprecated("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object.");
|
|
53
146
|
return this;
|
|
54
147
|
}
|
|
55
148
|
// eslint-disable-next-line class-methods-use-this
|
|
56
149
|
set olLayer(newValue) {
|
|
57
|
-
|
|
58
|
-
console.log('Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.');
|
|
150
|
+
deprecated('Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.');
|
|
59
151
|
}
|
|
152
|
+
/** @deprecated */
|
|
153
|
+
// get olListenersKeys(): EventsKey[] {
|
|
154
|
+
// return this.olEventsKeys;
|
|
155
|
+
// }
|
|
156
|
+
/** @deprecated */
|
|
60
157
|
get parent() {
|
|
158
|
+
deprecated("Layer.parent is deprecated. Use the Layer.get('parent') method instead.");
|
|
61
159
|
return this.get('parent');
|
|
62
160
|
}
|
|
161
|
+
/** @deprecated */
|
|
63
162
|
set parent(newValue) {
|
|
163
|
+
deprecated("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead.");
|
|
64
164
|
this.set('parent', newValue);
|
|
65
165
|
}
|
|
166
|
+
/** @deprecated */
|
|
66
167
|
get visible() {
|
|
168
|
+
deprecated('Layer.visible is deprecated. Use the Layer.getVisible() method instead.');
|
|
67
169
|
return this.getVisible();
|
|
68
170
|
}
|
|
171
|
+
/** @deprecated */
|
|
69
172
|
set visible(newValue) {
|
|
173
|
+
deprecated('Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead.');
|
|
70
174
|
this.setVisible(newValue);
|
|
71
175
|
}
|
|
72
|
-
constructor(...args) {
|
|
73
|
-
var _a;
|
|
74
|
-
const options = args[0];
|
|
75
|
-
super(options);
|
|
76
|
-
this.options = {};
|
|
77
|
-
this.olListenersKeys = [];
|
|
78
|
-
if (options.properties) {
|
|
79
|
-
// eslint-disable-next-line no-console
|
|
80
|
-
console.warn("Deprecated. Don't use properties options. Pass the values directly in options object.");
|
|
81
|
-
this.setProperties(options.properties);
|
|
82
|
-
}
|
|
83
|
-
(_a = this.olListenersKeys) === null || _a === void 0 ? void 0 : _a.push(
|
|
84
|
-
// Update parent property
|
|
85
|
-
this.on('propertychange', (evt) => {
|
|
86
|
-
if (evt.key === 'children') {
|
|
87
|
-
this.onChildrenChange(evt.oldValue);
|
|
88
|
-
}
|
|
89
|
-
}));
|
|
90
|
-
this.options = options;
|
|
91
|
-
this.children = options.children || []; // Trigger the on children change event
|
|
92
|
-
}
|
|
93
|
-
// @ts-expect-error - this is a mixin
|
|
94
|
-
setMapInternal(map) {
|
|
95
|
-
super.setMapInternal(map);
|
|
96
|
-
if (map) {
|
|
97
|
-
this.attachToMap(map);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
this.detachFromMap();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/** @private */
|
|
104
|
-
onChildrenChange(oldValue) {
|
|
105
|
-
// Set the parent property
|
|
106
|
-
(oldValue || []).forEach((child) => {
|
|
107
|
-
child.set('parent', undefined);
|
|
108
|
-
});
|
|
109
|
-
(this.children || []).forEach((child) => {
|
|
110
|
-
child.set('parent', this);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Initialize the layer with the map passed in parameters.
|
|
115
|
-
*
|
|
116
|
-
* @param {ol/Map~Map} map A map.
|
|
117
|
-
*/
|
|
118
|
-
attachToMap(map) {
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
(super.attachToMap || (() => { }))(map);
|
|
121
|
-
(this.get('children') || []).forEach((child) => {
|
|
122
|
-
map.addLayer(child);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Terminate what was initialized in init function. Remove layer, events...
|
|
127
|
-
*/
|
|
128
|
-
detachFromMap() {
|
|
129
|
-
(this.get('children') || []).forEach((child) => {
|
|
130
|
-
this.map.removeLayer(child);
|
|
131
|
-
});
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
(super.detachFromMap || (() => { }))();
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
137
|
-
*/
|
|
138
|
-
flat() {
|
|
139
|
-
return getLayersAsFlatArray(this);
|
|
140
|
-
}
|
|
141
176
|
};
|
|
142
177
|
}
|
|
143
178
|
export default PropertiesLayerMixin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MobilityLayerMixin } from './MobilityLayerMixin';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FrameState } from 'ol/Map';
|
|
2
|
-
import LayerRenderer from 'ol/renderer/Layer';
|
|
3
|
-
import { Coordinate } from 'ol/coordinate';
|
|
4
|
-
import { FeatureCallback } from 'ol/renderer/vector';
|
|
5
|
-
import { Feature } from 'ol';
|
|
6
|
-
import { Geometry } from 'ol/geom';
|
|
7
|
-
import { Pixel } from 'ol/pixel';
|
|
8
|
-
import type MaplibreLayer from '../layers/MaplibreLayer';
|
|
9
|
-
/**
|
|
10
|
-
* This class is a renderer for Maplibre Layer to be able to use the native ol
|
|
11
|
-
* functionnalities like map.getFeaturesAtPixel or map.hasFeatureAtPixel.
|
|
12
|
-
* @private
|
|
13
|
-
*/
|
|
14
|
-
export default class MaplibreLayerRenderer extends LayerRenderer<MaplibreLayer> {
|
|
15
|
-
getFeaturesAtCoordinate(coordinate: Coordinate | undefined, hitTolerance?: number): Feature<Geometry>[];
|
|
16
|
-
prepareFrame(): boolean;
|
|
17
|
-
renderFrame(frameState: FrameState): HTMLElement | null;
|
|
18
|
-
getFeatures(pixel: Pixel): Promise<Feature<Geometry>[]>;
|
|
19
|
-
forEachFeatureAtCoordinate<Feature>(coordinate: Coordinate, frameState: FrameState, hitTolerance: number, callback: FeatureCallback<Feature>): Feature | undefined;
|
|
20
|
-
}
|