mobility-toolbox-js 3.0.0-beta.36 → 3.0.0-beta.38
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/README.md +11 -3
- package/common/typedefs.d.ts +0 -117
- package/common/typedefs.js +0 -31
- package/common/utils/RealtimeEngine.d.ts +5 -5
- package/common/utils/RealtimeEngine.js +0 -1
- package/common/utils/getVehiclePosition.js +1 -4
- package/mbt.js +515 -364
- package/mbt.js.map +4 -4
- package/mbt.min.js +15 -15
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +1 -1
- package/ol/controls/RoutingControl.js +2 -2
- package/ol/index.d.ts +0 -1
- package/ol/index.js +0 -1
- package/ol/layers/Layer.d.ts +15 -92
- package/ol/layers/Layer.js +4 -3
- package/ol/layers/MaplibreLayer.d.ts +8 -96
- package/ol/layers/MaplibreLayer.js +36 -19
- package/ol/layers/MaplibreStyleLayer.d.ts +4 -92
- package/ol/layers/MaplibreStyleLayer.js +25 -9
- package/ol/layers/RealtimeLayer.d.ts +6 -94
- package/ol/layers/RealtimeLayer.js +34 -19
- package/ol/layers/VectorLayer.d.ts +1 -2
- package/ol/layers/VectorLayer.js +7 -6
- package/ol/styles/routingStyle.js +11 -3
- package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
- package/ol/utils/defineDeprecatedProperties.js +180 -0
- package/package.json +13 -14
- package/types/common.d.ts +2 -26
- package/types/realtime.d.ts +6 -1
- package/ol/mixins/MobilityLayerMixin.d.ts +0 -96
- package/ol/mixins/MobilityLayerMixin.js +0 -6
- package/ol/mixins/PropertiesLayerMixin.d.ts +0 -134
- package/ol/mixins/PropertiesLayerMixin.js +0 -181
- package/ol/mixins/index.d.ts +0 -1
- package/ol/mixins/index.js +0 -2
package/types/common.d.ts
CHANGED
|
@@ -4,9 +4,6 @@ import { ObjectEvent } from 'ol/Object';
|
|
|
4
4
|
import { Pixel } from 'ol/pixel';
|
|
5
5
|
|
|
6
6
|
import { RealtimeTrajectory } from '../api/typedefs';
|
|
7
|
-
import CommonLayer, {
|
|
8
|
-
LayerCommonOptions,
|
|
9
|
-
} from '../ol/mixins/PropertiesLayerMixin';
|
|
10
7
|
|
|
11
8
|
import type {
|
|
12
9
|
CopyrightControl as MbCopyrightControl,
|
|
@@ -86,12 +83,6 @@ export interface RealtimeRenderState {
|
|
|
86
83
|
zoom?: number;
|
|
87
84
|
}
|
|
88
85
|
|
|
89
|
-
export type AnyMap = MapboxMap | MaplibreMap | OlMap;
|
|
90
|
-
export type AnyLayer = MbLayer | OlLayer;
|
|
91
|
-
export type AnyOlLayer = OlLayer;
|
|
92
|
-
export type AnyMapboxLayer = MapboxLayer | MaplibreLayer;
|
|
93
|
-
export type AnyRealtimeLayer = MbRealtimeLayer | OlRealtimeLayer;
|
|
94
|
-
export type AnyCopyrightControl = MbCopyrightControl | OlCopyrightControl;
|
|
95
86
|
export type AnyMapGlMap = maplibregl.Map;
|
|
96
87
|
export type AnyMapGlMapOptions = maplibregl.MapOptions;
|
|
97
88
|
export type AnyCanvas = HTMLCanvasElement | OffscreenCanvas;
|
|
@@ -100,19 +91,10 @@ export type AnyCanvasContext =
|
|
|
100
91
|
| null
|
|
101
92
|
| OffscreenCanvasRenderingContext2D
|
|
102
93
|
| undefined;
|
|
103
|
-
export type GConstructor<T extends CommonLayer> = new (options?: any) => T;
|
|
104
|
-
export type CommonLayerClass = GConstructor<CommonLayer>;
|
|
105
|
-
export type GConstructor2<T extends OlLayer> = new (options?: any) => T;
|
|
106
|
-
export type OlLayerClass = GConstructor<AnyOlLayer>;
|
|
107
|
-
export type AnyLayerClass = GConstructor<AnyLayer>;
|
|
108
94
|
|
|
109
|
-
type
|
|
110
|
-
export type
|
|
95
|
+
export type AnyRealtimeLayer = MbRealtimeLayer | OlRealtimeLayer;
|
|
96
|
+
export type AnyCopyrightControl = MbCopyrightControl | OlCopyrightControl;
|
|
111
97
|
|
|
112
|
-
export type AnyMapboxLayerClass = GConstructor<AnyMapboxLayer>;
|
|
113
|
-
export type AnyRealtimeLayerClass = GConstructor<AnyRealtimeLayer>;
|
|
114
|
-
export type AnyMapGlMapClass = GConstructor<AnyMapGlMap>;
|
|
115
|
-
export type AnyCopyrightControlClass = GConstructor<AnyCopyrightControl>;
|
|
116
98
|
|
|
117
99
|
export interface LayerGetFeatureInfoResponse {
|
|
118
100
|
coordinate: Coordinate;
|
|
@@ -125,12 +107,6 @@ export interface LayerGetFeatureInfoOptions {
|
|
|
125
107
|
hitTolerance: number = 5;
|
|
126
108
|
}
|
|
127
109
|
|
|
128
|
-
export type UserInteractionCallback = (
|
|
129
|
-
features: Feature[],
|
|
130
|
-
layer: LayerCommonOptions,
|
|
131
|
-
coordinate: Coordinate,
|
|
132
|
-
event: ObjectEvent,
|
|
133
|
-
) => void;
|
|
134
110
|
|
|
135
111
|
export type RoutingGraph = [RoutingParameters.graph, number, number];
|
|
136
112
|
export type RoutingMot = RoutingParameters.mot;
|
package/types/realtime.d.ts
CHANGED
|
@@ -74,7 +74,12 @@ export type RealtimeChannelName =
|
|
|
74
74
|
export interface RealtimeTrajectoryProperties {
|
|
75
75
|
// Tralis and trafimage
|
|
76
76
|
bounds: [number, number, number, number];
|
|
77
|
+
|
|
78
|
+
// Only after first rendering on a map
|
|
79
|
+
coordinate?: [number, number];
|
|
80
|
+
|
|
77
81
|
delay: null | number;
|
|
82
|
+
|
|
78
83
|
// Tralis
|
|
79
84
|
event?: string;
|
|
80
85
|
event_delay?: number;
|
|
@@ -139,7 +144,7 @@ export interface RealtimeStop {
|
|
|
139
144
|
aimedDepartureTime: number;
|
|
140
145
|
arrivalDelay?: number;
|
|
141
146
|
arrivalTime: number;
|
|
142
|
-
cancelled:
|
|
147
|
+
cancelled: boolean;
|
|
143
148
|
coordinate: number[];
|
|
144
149
|
departureDelay: number;
|
|
145
150
|
departureTime: number;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Layer } from 'ol/layer';
|
|
2
|
-
import { PropertiesLayerMixinOptions } from './PropertiesLayerMixin';
|
|
3
|
-
export type MobilityLayerOptions = PropertiesLayerMixinOptions & Record<string, any>;
|
|
4
|
-
type GConstructor<T = object> = new (...args: any[]) => T;
|
|
5
|
-
export type Layerable = GConstructor<Omit<Layer, keyof string>>;
|
|
6
|
-
declare function MobilityLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
7
|
-
new (...args: any[]): {
|
|
8
|
-
olEventsKeys: import("ol/events").EventsKey[];
|
|
9
|
-
options?: PropertiesLayerMixinOptions;
|
|
10
|
-
attachToMap(map: import("ol").Map): void;
|
|
11
|
-
detachFromMap(): void;
|
|
12
|
-
flat(): any[];
|
|
13
|
-
onChildrenChange(oldValue: Layer[]): void;
|
|
14
|
-
setMapInternal: ((map: import("ol").Map) => void) & ((map: import("ol").default | null) => void);
|
|
15
|
-
children: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
16
|
-
get copyrights(): string;
|
|
17
|
-
set copyrights(newCopyrights: string | string[]);
|
|
18
|
-
disabled: boolean;
|
|
19
|
-
readonly group: string;
|
|
20
|
-
hitTolerance: number;
|
|
21
|
-
readonly key: string;
|
|
22
|
-
readonly map: import("ol").Map;
|
|
23
|
-
readonly name: string;
|
|
24
|
-
olLayer: Layer;
|
|
25
|
-
parent: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
26
|
-
visible: boolean;
|
|
27
|
-
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
28
|
-
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
29
|
-
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
30
|
-
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
31
|
-
getSource: () => import("ol/source").Source | null;
|
|
32
|
-
getRenderSource: () => import("ol/source").Source | null;
|
|
33
|
-
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
|
|
34
|
-
getData: (pixel: import("ol/pixel").Pixel) => Uint8ClampedArray | Uint8Array | Float32Array | DataView | null;
|
|
35
|
-
isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
36
|
-
getAttributions: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => Array<string>;
|
|
37
|
-
unrender: () => void;
|
|
38
|
-
getDeclutter: () => string;
|
|
39
|
-
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
40
|
-
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
41
|
-
getMapInternal: () => import("ol").default | null;
|
|
42
|
-
setMap: (map: import("ol").default | null) => void;
|
|
43
|
-
setSource: (source: import("ol/source").Source | null) => void;
|
|
44
|
-
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
45
|
-
hasRenderer: () => boolean;
|
|
46
|
-
getBackground: () => import("ol/layer/Base").BackgroundColor | false;
|
|
47
|
-
getClassName: () => string;
|
|
48
|
-
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
49
|
-
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
|
|
50
|
-
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
|
|
51
|
-
getExtent: () => import("ol/extent").Extent | undefined;
|
|
52
|
-
getMaxResolution: () => number;
|
|
53
|
-
getMinResolution: () => number;
|
|
54
|
-
getMinZoom: () => number;
|
|
55
|
-
getMaxZoom: () => number;
|
|
56
|
-
getOpacity: () => number;
|
|
57
|
-
getSourceState: () => import("ol/source/Source").State;
|
|
58
|
-
getVisible: () => boolean;
|
|
59
|
-
getZIndex: () => number | undefined;
|
|
60
|
-
setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
|
|
61
|
-
setExtent: (extent: import("ol/extent").Extent | undefined) => void;
|
|
62
|
-
setMaxResolution: (maxResolution: number) => void;
|
|
63
|
-
setMinResolution: (minResolution: number) => void;
|
|
64
|
-
setMaxZoom: (maxZoom: number) => void;
|
|
65
|
-
setMinZoom: (minZoom: number) => void;
|
|
66
|
-
setOpacity: (opacity: number) => void;
|
|
67
|
-
setVisible: (visible: boolean) => void;
|
|
68
|
-
setZIndex: (zindex: number) => void;
|
|
69
|
-
get: (key: string) => any;
|
|
70
|
-
getKeys: () => Array<string>;
|
|
71
|
-
getProperties: () => {
|
|
72
|
-
[x: string]: any;
|
|
73
|
-
};
|
|
74
|
-
getPropertiesInternal: () => {
|
|
75
|
-
[x: string]: any;
|
|
76
|
-
} | null;
|
|
77
|
-
hasProperties: () => boolean;
|
|
78
|
-
notify: (key: string, oldValue: any) => void;
|
|
79
|
-
addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
80
|
-
removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
81
|
-
set: (key: string, value: any, silent?: boolean | undefined) => void;
|
|
82
|
-
setProperties: (values: {
|
|
83
|
-
[x: string]: any;
|
|
84
|
-
}, silent?: boolean | undefined) => void;
|
|
85
|
-
unset: (key: string, silent?: boolean | undefined) => void;
|
|
86
|
-
changed: () => void;
|
|
87
|
-
getRevision: () => number;
|
|
88
|
-
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
89
|
-
dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
|
|
90
|
-
getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
|
|
91
|
-
hasListener: (type?: string | undefined) => boolean;
|
|
92
|
-
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
93
|
-
dispose: () => void;
|
|
94
|
-
};
|
|
95
|
-
} & TBase;
|
|
96
|
-
export default MobilityLayerMixin;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { Map } from 'ol';
|
|
2
|
-
import { EventsKey } from 'ol/events';
|
|
3
|
-
import { Layer } from 'ol/layer';
|
|
4
|
-
import type { Options } from 'ol/layer/Layer';
|
|
5
|
-
import type { Layerable } from './MobilityLayerMixin';
|
|
6
|
-
export type PropertiesLayerMixinOptions = {
|
|
7
|
-
children?: any[];
|
|
8
|
-
copyrights?: string[];
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
group?: string;
|
|
11
|
-
hitTolerance?: number;
|
|
12
|
-
key?: string;
|
|
13
|
-
map?: Map;
|
|
14
|
-
name?: string;
|
|
15
|
-
properties?: Record<string, any>;
|
|
16
|
-
visible?: boolean;
|
|
17
|
-
} & Options & Record<string, any>;
|
|
18
|
-
/**
|
|
19
|
-
* This mixin adds some properties to access ol custom properties easily.
|
|
20
|
-
*/
|
|
21
|
-
declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
22
|
-
new (...args: any[]): {
|
|
23
|
-
olEventsKeys: EventsKey[];
|
|
24
|
-
options?: PropertiesLayerMixinOptions;
|
|
25
|
-
/**
|
|
26
|
-
* Initialize the layer with the map passed in parameters.
|
|
27
|
-
*
|
|
28
|
-
* @param {ol/Map~Map} map A map.
|
|
29
|
-
*/
|
|
30
|
-
attachToMap(map: Map): void;
|
|
31
|
-
/**
|
|
32
|
-
* Terminate what was initialized in init function. Remove layer, events...
|
|
33
|
-
*/
|
|
34
|
-
detachFromMap(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
37
|
-
* @deprecated
|
|
38
|
-
*/
|
|
39
|
-
flat(): any[];
|
|
40
|
-
onChildrenChange(oldValue: Layer[]): void;
|
|
41
|
-
setMapInternal(map: Map): void;
|
|
42
|
-
/** @deprecated */
|
|
43
|
-
children: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
44
|
-
/** @deprecated */
|
|
45
|
-
get copyrights(): string;
|
|
46
|
-
/** @deprecated */
|
|
47
|
-
set copyrights(newCopyrights: string | string[]);
|
|
48
|
-
/** @deprecated */
|
|
49
|
-
disabled: boolean;
|
|
50
|
-
/** @deprecated */
|
|
51
|
-
readonly group: string;
|
|
52
|
-
/** @deprecated */
|
|
53
|
-
hitTolerance: number;
|
|
54
|
-
readonly key: string;
|
|
55
|
-
readonly map: Map;
|
|
56
|
-
/** @deprecated */
|
|
57
|
-
readonly name: string;
|
|
58
|
-
/** @deprecated */
|
|
59
|
-
olLayer: Layer;
|
|
60
|
-
/** @deprecated */
|
|
61
|
-
/** @deprecated */
|
|
62
|
-
parent: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
63
|
-
/** @deprecated */
|
|
64
|
-
visible: boolean;
|
|
65
|
-
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
66
|
-
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
67
|
-
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
68
|
-
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
69
|
-
getSource: () => import("ol/source").Source | null;
|
|
70
|
-
getRenderSource: () => import("ol/source").Source | null;
|
|
71
|
-
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
|
|
72
|
-
getData: (pixel: import("ol/pixel").Pixel) => Uint8ClampedArray | Uint8Array | Float32Array | DataView | null;
|
|
73
|
-
isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
74
|
-
getAttributions: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => Array<string>;
|
|
75
|
-
unrender: () => void;
|
|
76
|
-
getDeclutter: () => string;
|
|
77
|
-
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
78
|
-
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
79
|
-
getMapInternal: () => import("ol/Map").default | null;
|
|
80
|
-
setMap: (map: import("ol/Map").default | null) => void;
|
|
81
|
-
setSource: (source: import("ol/source").Source | null) => void;
|
|
82
|
-
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
83
|
-
hasRenderer: () => boolean;
|
|
84
|
-
getBackground: () => import("ol/layer/Base").BackgroundColor | false;
|
|
85
|
-
getClassName: () => string;
|
|
86
|
-
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
87
|
-
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
|
|
88
|
-
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
|
|
89
|
-
getExtent: () => import("ol/extent").Extent | undefined;
|
|
90
|
-
getMaxResolution: () => number;
|
|
91
|
-
getMinResolution: () => number;
|
|
92
|
-
getMinZoom: () => number;
|
|
93
|
-
getMaxZoom: () => number;
|
|
94
|
-
getOpacity: () => number;
|
|
95
|
-
getSourceState: () => import("ol/source/Source").State;
|
|
96
|
-
getVisible: () => boolean;
|
|
97
|
-
getZIndex: () => number | undefined;
|
|
98
|
-
setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
|
|
99
|
-
setExtent: (extent: import("ol/extent").Extent | undefined) => void;
|
|
100
|
-
setMaxResolution: (maxResolution: number) => void;
|
|
101
|
-
setMinResolution: (minResolution: number) => void;
|
|
102
|
-
setMaxZoom: (maxZoom: number) => void;
|
|
103
|
-
setMinZoom: (minZoom: number) => void;
|
|
104
|
-
setOpacity: (opacity: number) => void;
|
|
105
|
-
setVisible: (visible: boolean) => void;
|
|
106
|
-
setZIndex: (zindex: number) => void;
|
|
107
|
-
get: (key: string) => any;
|
|
108
|
-
getKeys: () => Array<string>;
|
|
109
|
-
getProperties: () => {
|
|
110
|
-
[x: string]: any;
|
|
111
|
-
};
|
|
112
|
-
getPropertiesInternal: () => {
|
|
113
|
-
[x: string]: any;
|
|
114
|
-
} | null;
|
|
115
|
-
hasProperties: () => boolean;
|
|
116
|
-
notify: (key: string, oldValue: any) => void;
|
|
117
|
-
addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
118
|
-
removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
119
|
-
set: (key: string, value: any, silent?: boolean | undefined) => void;
|
|
120
|
-
setProperties: (values: {
|
|
121
|
-
[x: string]: any;
|
|
122
|
-
}, silent?: boolean | undefined) => void;
|
|
123
|
-
unset: (key: string, silent?: boolean | undefined) => void;
|
|
124
|
-
changed: () => void;
|
|
125
|
-
getRevision: () => number;
|
|
126
|
-
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
127
|
-
dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
|
|
128
|
-
getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
|
|
129
|
-
hasListener: (type?: string | undefined) => boolean;
|
|
130
|
-
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
131
|
-
dispose: () => void;
|
|
132
|
-
};
|
|
133
|
-
} & TBase;
|
|
134
|
-
export default PropertiesLayerMixin;
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line max-classes-per-file
|
|
2
|
-
import debounce from 'lodash.debounce';
|
|
3
|
-
import { unByKey } from 'ol/Observable';
|
|
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
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* This mixin adds some properties to access ol custom properties easily.
|
|
15
|
-
*/
|
|
16
|
-
function PropertiesLayerMixin(Base) {
|
|
17
|
-
return class PropertiesLayer extends Base {
|
|
18
|
-
constructor(...args) {
|
|
19
|
-
const options = args[0];
|
|
20
|
-
super(options);
|
|
21
|
-
this.olEventsKeys = [];
|
|
22
|
-
this.options = {};
|
|
23
|
-
if (options.properties) {
|
|
24
|
-
deprecated("Deprecated. Don't use properties options. Pass the values directly in options object.");
|
|
25
|
-
this.setProperties(options.properties);
|
|
26
|
-
}
|
|
27
|
-
// Update parent property
|
|
28
|
-
this.on('propertychange', (evt) => {
|
|
29
|
-
if (evt.key === 'children') {
|
|
30
|
-
this.onChildrenChange(evt.oldValue);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
this.options = options;
|
|
34
|
-
this.set('children', options.children || []); // Trigger the on children change event
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Initialize the layer with the map passed in parameters.
|
|
38
|
-
*
|
|
39
|
-
* @param {ol/Map~Map} map A map.
|
|
40
|
-
*/
|
|
41
|
-
attachToMap(map) {
|
|
42
|
-
// @ts-expect-error attachToMap not necessarily exists
|
|
43
|
-
(super.attachToMap || (() => { }))(map);
|
|
44
|
-
(this.get('children') || []).forEach((child) => {
|
|
45
|
-
map.addLayer(child);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Terminate what was initialized in init function. Remove layer, events...
|
|
50
|
-
*/
|
|
51
|
-
detachFromMap() {
|
|
52
|
-
unByKey(this.olEventsKeys);
|
|
53
|
-
(this.get('children') || []).forEach((child) => {
|
|
54
|
-
this.map.removeLayer(child);
|
|
55
|
-
});
|
|
56
|
-
// @ts-expect-error detachToMap not necessarily exists
|
|
57
|
-
(super.detachFromMap || (() => { }))();
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
61
|
-
* @deprecated
|
|
62
|
-
*/
|
|
63
|
-
flat() {
|
|
64
|
-
deprecated('Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead.');
|
|
65
|
-
return getLayersAsFlatArray(this);
|
|
66
|
-
}
|
|
67
|
-
onChildrenChange(oldValue) {
|
|
68
|
-
// Set the parent property
|
|
69
|
-
(oldValue || []).forEach((child) => {
|
|
70
|
-
child.set('parent', undefined);
|
|
71
|
-
});
|
|
72
|
-
(this.get('children') || []).forEach((child) => {
|
|
73
|
-
child.set('parent', this);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
// @ts-expect-error - this is a mixin
|
|
77
|
-
setMapInternal(map) {
|
|
78
|
-
if (map) {
|
|
79
|
-
super.setMapInternal(map);
|
|
80
|
-
this.attachToMap(map);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
this.detachFromMap();
|
|
84
|
-
super.setMapInternal(map);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/** @deprecated */
|
|
88
|
-
get children() {
|
|
89
|
-
deprecated("Layer.children is deprecated. Use the Layer.get('children') method instead.");
|
|
90
|
-
return this.get('children') || [];
|
|
91
|
-
}
|
|
92
|
-
/** @deprecated */
|
|
93
|
-
set children(newValue) {
|
|
94
|
-
deprecated("Layer.children is deprecated. Use the Layer.set('children', children) method instead.");
|
|
95
|
-
this.set('children', newValue || []);
|
|
96
|
-
}
|
|
97
|
-
/** @deprecated */
|
|
98
|
-
get copyrights() {
|
|
99
|
-
deprecated('Layer.copyrights is deprecated. Get the attributions from the source object');
|
|
100
|
-
return this.get('copyrights');
|
|
101
|
-
}
|
|
102
|
-
/** @deprecated */
|
|
103
|
-
set copyrights(newCopyrights) {
|
|
104
|
-
deprecated('Layer.copyrights is deprecated. Set the attributions to the source object.');
|
|
105
|
-
const arrValue = newCopyrights && !Array.isArray(newCopyrights)
|
|
106
|
-
? [newCopyrights]
|
|
107
|
-
: newCopyrights;
|
|
108
|
-
this.set('copyrights', arrValue || []);
|
|
109
|
-
}
|
|
110
|
-
/** @deprecated */
|
|
111
|
-
get disabled() {
|
|
112
|
-
deprecated("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead.");
|
|
113
|
-
return this.get('disabled');
|
|
114
|
-
}
|
|
115
|
-
/** @deprecated */
|
|
116
|
-
set disabled(newValue) {
|
|
117
|
-
deprecated("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead.");
|
|
118
|
-
this.set('disabled', newValue);
|
|
119
|
-
}
|
|
120
|
-
/** @deprecated */
|
|
121
|
-
get group() {
|
|
122
|
-
deprecated("Layer.group is deprecated. Use the Layer.get('group') method instead.");
|
|
123
|
-
return this.get('group');
|
|
124
|
-
}
|
|
125
|
-
/** @deprecated */
|
|
126
|
-
get hitTolerance() {
|
|
127
|
-
deprecated('Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features.');
|
|
128
|
-
return this.get('hitTolerance') || 5;
|
|
129
|
-
}
|
|
130
|
-
/** @deprecated */
|
|
131
|
-
set hitTolerance(newValue) {
|
|
132
|
-
deprecated('Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features.');
|
|
133
|
-
this.set('hitTolerance', newValue);
|
|
134
|
-
}
|
|
135
|
-
get key() {
|
|
136
|
-
return this.get('key') || this.get('name');
|
|
137
|
-
}
|
|
138
|
-
get map() {
|
|
139
|
-
return this.getMapInternal();
|
|
140
|
-
}
|
|
141
|
-
/** @deprecated */
|
|
142
|
-
get name() {
|
|
143
|
-
deprecated("Layer.name is deprecated. Use the Layer.get('name') method instead.");
|
|
144
|
-
return this.get('name');
|
|
145
|
-
}
|
|
146
|
-
/** @deprecated */
|
|
147
|
-
get olLayer() {
|
|
148
|
-
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.");
|
|
149
|
-
return this;
|
|
150
|
-
}
|
|
151
|
-
// eslint-disable-next-line class-methods-use-this
|
|
152
|
-
set olLayer(newValue) {
|
|
153
|
-
deprecated('Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.');
|
|
154
|
-
}
|
|
155
|
-
/** @deprecated */
|
|
156
|
-
// get olListenersKeys(): EventsKey[] {
|
|
157
|
-
// return this.olEventsKeys;
|
|
158
|
-
// }
|
|
159
|
-
/** @deprecated */
|
|
160
|
-
get parent() {
|
|
161
|
-
deprecated("Layer.parent is deprecated. Use the Layer.get('parent') method instead.");
|
|
162
|
-
return this.get('parent');
|
|
163
|
-
}
|
|
164
|
-
/** @deprecated */
|
|
165
|
-
set parent(newValue) {
|
|
166
|
-
deprecated("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead.");
|
|
167
|
-
this.set('parent', newValue);
|
|
168
|
-
}
|
|
169
|
-
/** @deprecated */
|
|
170
|
-
get visible() {
|
|
171
|
-
deprecated('Layer.visible is deprecated. Use the Layer.getVisible() method instead.');
|
|
172
|
-
return this.getVisible();
|
|
173
|
-
}
|
|
174
|
-
/** @deprecated */
|
|
175
|
-
set visible(newValue) {
|
|
176
|
-
deprecated('Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead.');
|
|
177
|
-
this.setVisible(newValue);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
export default PropertiesLayerMixin;
|
package/ol/mixins/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as MobilityLayerMixin } from './MobilityLayerMixin';
|
package/ol/mixins/index.js
DELETED