mobility-toolbox-js 3.0.0-beta.9 → 3.0.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/README.md +11 -3
- package/api/HttpAPI.d.ts +5 -16
- package/api/HttpAPI.js +1 -14
- package/api/RealtimeAPI.d.ts +188 -143
- package/api/RealtimeAPI.js +265 -206
- 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 -165
- 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 +13 -13
- package/common/controls/StopFinderControlCommon.js +32 -32
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/styles/realtimeDefaultStyle.js +6 -11
- package/common/styles/realtimeHeadingStyle.js +5 -10
- package/common/styles/realtimeSimpleStyle.d.ts +0 -1
- package/common/styles/realtimeSimpleStyle.js +0 -1
- package/common/typedefs.d.ts +11 -121
- package/common/typedefs.js +6 -31
- package/common/utils/RealtimeEngine.d.ts +214 -0
- package/common/utils/RealtimeEngine.js +554 -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/getLayersAsFlatArray.d.ts +0 -1
- package/common/utils/getLayersAsFlatArray.js +0 -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 +6 -3
- package/common/utils/realtimeConfig.d.ts +1 -1
- package/common/utils/realtimeConfig.js +0 -1
- package/common/utils/renderTrajectories.d.ts +2 -1
- package/common/utils/renderTrajectories.js +7 -6
- package/common/utils/sortAndFilterDepartures.d.ts +2 -1
- package/common/utils/sortAndFilterDepartures.js +2 -1
- package/common/utils/sortByDelay.d.ts +2 -2
- package/common/utils/sortByDelay.js +5 -1
- package/maplibre/controls/CopyrightControl.d.ts +9 -6
- package/maplibre/controls/CopyrightControl.js +11 -8
- package/maplibre/layers/Layer.d.ts +8 -7
- package/maplibre/layers/Layer.js +2 -3
- package/maplibre/layers/RealtimeLayer.d.ts +82 -118
- package/maplibre/layers/RealtimeLayer.js +154 -118
- package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
- package/maplibre/utils/getSourceCoordinates.js +6 -5
- package/mbt.js +14611 -14591
- package/mbt.js.map +4 -4
- package/mbt.min.js +75 -75
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +13 -5
- package/ol/controls/CopyrightControl.js +13 -5
- package/ol/controls/RoutingControl.d.ts +105 -101
- package/ol/controls/RoutingControl.js +250 -264
- package/ol/controls/StopFinderControl.d.ts +24 -5
- package/ol/controls/StopFinderControl.js +24 -5
- package/ol/layers/Layer.d.ts +26 -0
- package/ol/layers/Layer.js +39 -0
- package/ol/layers/MaplibreLayer.d.ts +56 -28
- package/ol/layers/MaplibreLayer.js +154 -31
- package/ol/layers/MaplibreStyleLayer.d.ts +71 -149
- package/ol/layers/MaplibreStyleLayer.js +281 -210
- package/ol/layers/RealtimeLayer.d.ts +95 -230
- package/ol/layers/RealtimeLayer.js +209 -211
- package/ol/layers/VectorLayer.d.ts +17 -0
- package/ol/layers/VectorLayer.js +33 -0
- package/ol/layers/index.d.ts +2 -0
- package/ol/layers/index.js +3 -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 +7 -7
- package/ol/renderers/RealtimeLayerRenderer.js +46 -66
- package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
- package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
- package/ol/styles/fullTrajectoryStyle.js +5 -7
- package/ol/styles/routingStyle.d.ts +0 -1
- package/ol/styles/routingStyle.js +13 -10
- package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
- package/ol/utils/defineDeprecatedProperties.js +180 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
- package/package.json +44 -44
- package/setupTests.js +17 -4
- package/types/common.d.ts +53 -69
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +98 -95
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/common/mixins/RealtimeLayerMixin.d.ts +0 -273
- package/common/mixins/RealtimeLayerMixin.js +0 -743
- package/ol/layers/MapGlLayer.d.ts +0 -144
- package/ol/layers/MapGlLayer.js +0 -144
- package/ol/mixins/MobilityLayerMixin.d.ts +0 -98
- package/ol/mixins/MobilityLayerMixin.js +0 -6
- package/ol/mixins/PropertiesLayerMixin.d.ts +0 -127
- package/ol/mixins/PropertiesLayerMixin.js +0 -143
|
@@ -1,144 +0,0 @@
|
|
|
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';
|
|
5
|
-
import { AnyMapGlMap } from '../../types';
|
|
6
|
-
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
7
|
-
export type MapGlLayerOptions = MobilityLayerOptions & {
|
|
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: {
|
|
16
|
-
new (...args: any[]): {
|
|
17
|
-
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions | undefined;
|
|
18
|
-
olListenersKeys: import("ol/events").EventsKey[];
|
|
19
|
-
children: Layer<Source, import("ol/renderer/Layer").default<any>>[];
|
|
20
|
-
get copyrights(): string;
|
|
21
|
-
set copyrights(newCopyrights: string | string[]);
|
|
22
|
-
disabled: boolean;
|
|
23
|
-
readonly group: string;
|
|
24
|
-
readonly hitTolerance: boolean;
|
|
25
|
-
readonly key: string;
|
|
26
|
-
readonly map: OlMap;
|
|
27
|
-
readonly name: string;
|
|
28
|
-
olLayer: Layer<Source, import("ol/renderer/Layer").default<any>>;
|
|
29
|
-
parent: Layer<Source, import("ol/renderer/Layer").default<any>>;
|
|
30
|
-
visible: boolean;
|
|
31
|
-
setMapInternal: ((map: OlMap) => void) & ((map: OlMap | null) => void);
|
|
32
|
-
onChildrenChange(oldValue: Layer<Source, import("ol/renderer/Layer").default<any>>[]): void;
|
|
33
|
-
attachToMap(map: OlMap): void;
|
|
34
|
-
detachFromMap(): void;
|
|
35
|
-
flat(): any[];
|
|
36
|
-
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
37
|
-
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
38
|
-
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
39
|
-
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
40
|
-
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
41
|
-
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
42
|
-
getSource: () => Source | null;
|
|
43
|
-
getRenderSource: () => Source | null;
|
|
44
|
-
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<import("ol/Feature").FeatureLike[]>;
|
|
45
|
-
getData: (pixel: import("ol/pixel").Pixel) => Float32Array | Uint8ClampedArray | Uint8Array | DataView | null;
|
|
46
|
-
isVisible: (view?: import("ol/View").default | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
47
|
-
getAttributions: (view?: import("ol/View").default | import("ol/View").ViewStateLayerStateExtent | undefined) => string[];
|
|
48
|
-
unrender: () => void;
|
|
49
|
-
getDeclutter: () => string;
|
|
50
|
-
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
51
|
-
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
52
|
-
getMapInternal: () => OlMap | null;
|
|
53
|
-
setMap: (map: OlMap | null) => void;
|
|
54
|
-
setSource: (source: Source | null) => void;
|
|
55
|
-
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
56
|
-
hasRenderer: () => boolean;
|
|
57
|
-
getBackground: () => false | import("ol/layer/Base").BackgroundColor;
|
|
58
|
-
getClassName: () => string;
|
|
59
|
-
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
60
|
-
getLayersArray: (array?: Layer<Source, import("ol/renderer/Layer").default<any>>[] | undefined) => Layer<Source, import("ol/renderer/Layer").default<any>>[];
|
|
61
|
-
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => import("ol/layer/Layer").State[];
|
|
62
|
-
getExtent: () => import("ol/extent").Extent | undefined;
|
|
63
|
-
getMaxResolution: () => number;
|
|
64
|
-
getMinResolution: () => number;
|
|
65
|
-
getMinZoom: () => number;
|
|
66
|
-
getMaxZoom: () => number;
|
|
67
|
-
getOpacity: () => number;
|
|
68
|
-
getSourceState: () => import("ol/source/Source").State;
|
|
69
|
-
getVisible: () => boolean;
|
|
70
|
-
getZIndex: () => number | undefined;
|
|
71
|
-
setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
|
|
72
|
-
setExtent: (extent: import("ol/extent").Extent | undefined) => void;
|
|
73
|
-
setMaxResolution: (maxResolution: number) => void;
|
|
74
|
-
setMinResolution: (minResolution: number) => void;
|
|
75
|
-
setMaxZoom: (maxZoom: number) => void;
|
|
76
|
-
setMinZoom: (minZoom: number) => void;
|
|
77
|
-
setOpacity: (opacity: number) => void;
|
|
78
|
-
setVisible: (visible: boolean) => void;
|
|
79
|
-
setZIndex: (zindex: number) => void;
|
|
80
|
-
get: (key: string) => any;
|
|
81
|
-
getKeys: () => string[];
|
|
82
|
-
getProperties: () => {
|
|
83
|
-
[x: string]: any;
|
|
84
|
-
};
|
|
85
|
-
getPropertiesInternal: () => {
|
|
86
|
-
[x: string]: any;
|
|
87
|
-
} | null;
|
|
88
|
-
hasProperties: () => boolean;
|
|
89
|
-
notify: (key: string, oldValue: any) => void;
|
|
90
|
-
addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
91
|
-
removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
92
|
-
set: (key: string, value: any, silent?: boolean | undefined) => void;
|
|
93
|
-
setProperties: (values: {
|
|
94
|
-
[x: string]: any;
|
|
95
|
-
}, silent?: boolean | undefined) => void;
|
|
96
|
-
unset: (key: string, silent?: boolean | undefined) => void;
|
|
97
|
-
changed: () => void;
|
|
98
|
-
getRevision: () => number;
|
|
99
|
-
dispatchEvent: (event: string | BaseEvent) => boolean | undefined;
|
|
100
|
-
getListeners: (type: string) => import("ol/events").Listener[] | undefined;
|
|
101
|
-
hasListener: (type?: string | undefined) => boolean;
|
|
102
|
-
dispose: () => void;
|
|
103
|
-
};
|
|
104
|
-
} & typeof Layer;
|
|
105
|
-
/**
|
|
106
|
-
* Common class for Maplibre and Maplibre and potential other fork from Maplibre.
|
|
107
|
-
* It's used to share code between Maplibre and Maplibre layers without importing both libs.
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
110
|
-
declare class MapGlLayer extends MapGlLayer_base {
|
|
111
|
-
loaded: boolean;
|
|
112
|
-
mbMap?: AnyMapGlMap;
|
|
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;
|
|
143
|
-
}
|
|
144
|
-
export default MapGlLayer;
|
package/ol/layers/MapGlLayer.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
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';
|
|
5
|
-
import { getUrlWithParams, getMapGlCopyrights } from '../../common/utils';
|
|
6
|
-
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
7
|
-
/**
|
|
8
|
-
* Common class for Maplibre and Maplibre and potential other fork from Maplibre.
|
|
9
|
-
* It's used to share code between Maplibre and Maplibre layers without importing both libs.
|
|
10
|
-
* @private
|
|
11
|
-
*/
|
|
12
|
-
class MapGlLayer extends MobilityLayerMixin(Layer) {
|
|
13
|
-
get apiKey() {
|
|
14
|
-
return this.get('apiKey');
|
|
15
|
-
}
|
|
16
|
-
set apiKey(newValue) {
|
|
17
|
-
this.set('apiKey', newValue);
|
|
18
|
-
}
|
|
19
|
-
get apiKeyName() {
|
|
20
|
-
return this.get('apiKeyName');
|
|
21
|
-
}
|
|
22
|
-
set apiKeyName(newValue) {
|
|
23
|
-
this.set('apiKeyName', newValue);
|
|
24
|
-
}
|
|
25
|
-
get style() {
|
|
26
|
-
return this.get('style');
|
|
27
|
-
}
|
|
28
|
-
set style(newValue) {
|
|
29
|
-
this.set('style', newValue);
|
|
30
|
-
}
|
|
31
|
-
get url() {
|
|
32
|
-
return this.get('url');
|
|
33
|
-
}
|
|
34
|
-
set url(newValue) {
|
|
35
|
-
this.set('url', newValue);
|
|
36
|
-
}
|
|
37
|
-
get queryRenderedFeaturesOptions() {
|
|
38
|
-
return this.get('queryRenderedFeaturesOptions');
|
|
39
|
-
}
|
|
40
|
-
set queryRenderedFeaturesOptions(newValue) {
|
|
41
|
-
this.set('queryRenderedFeaturesOptions', newValue);
|
|
42
|
-
}
|
|
43
|
-
constructor(options) {
|
|
44
|
-
super(Object.assign(Object.assign({ source: new Source({
|
|
45
|
-
attributions: () => {
|
|
46
|
-
return (this.mbMap && getMapGlCopyrights(this.mbMap)) || [];
|
|
47
|
-
},
|
|
48
|
-
}), apiKeyName: 'key', style: 'travic_v2', url: 'https://maps.geops.io' }, (options || {})), {
|
|
49
|
-
// @ts-expect-error mapOptions must be saved by the mixin in this.options
|
|
50
|
-
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) || {})) }));
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Initialize the layer and listen to feature clicks.
|
|
54
|
-
* @param {ol/Map~Map} map
|
|
55
|
-
*/
|
|
56
|
-
attachToMap(map) {
|
|
57
|
-
super.attachToMap(map);
|
|
58
|
-
this.loadMbMap();
|
|
59
|
-
const updateMbMapDebounced = debounce(this.updateMbMap.bind(this), 150);
|
|
60
|
-
this.olListenersKeys.push(this.on('propertychange', (evt) => {
|
|
61
|
-
if (/(apiKey|apiKeyName|url|style)/.test(evt.key)) {
|
|
62
|
-
updateMbMapDebounced();
|
|
63
|
-
}
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Terminate what was initialized in init function. Remove layer, events...
|
|
68
|
-
*/
|
|
69
|
-
detachFromMap() {
|
|
70
|
-
if (this.mbMap) {
|
|
71
|
-
// Some asynchrone repaints are triggered even if the mbMap has been removed,
|
|
72
|
-
// to avoid display of errors we set an empty function.
|
|
73
|
-
this.mbMap.triggerRepaint = () => { };
|
|
74
|
-
this.mbMap.remove();
|
|
75
|
-
this.mbMap = undefined;
|
|
76
|
-
}
|
|
77
|
-
this.loaded = false;
|
|
78
|
-
super.detachFromMap();
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Create the Maplibre map.
|
|
82
|
-
* @private
|
|
83
|
-
*/
|
|
84
|
-
loadMbMap() {
|
|
85
|
-
var _a, _b, _c;
|
|
86
|
-
this.loaded = false;
|
|
87
|
-
this.olListenersKeys.push(
|
|
88
|
-
// @ts-ignore
|
|
89
|
-
(_a = this.map) === null || _a === void 0 ? void 0 : _a.on('change:target', this.loadMbMap.bind(this)));
|
|
90
|
-
if (!((_b = this.map) === null || _b === void 0 ? void 0 : _b.getTargetElement())) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (!this.visible) {
|
|
94
|
-
// On next change of visibility we load the map
|
|
95
|
-
this.olListenersKeys.push(
|
|
96
|
-
// @ts-ignore
|
|
97
|
-
this.once('change:visible', this.loadMbMap.bind(this)));
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const container = document.createElement('div');
|
|
101
|
-
container.style.position = 'absolute';
|
|
102
|
-
container.style.width = '100%';
|
|
103
|
-
container.style.height = '100%';
|
|
104
|
-
/**
|
|
105
|
-
* A Maplibre map
|
|
106
|
-
* @type {maplibregl.Map}
|
|
107
|
-
*/
|
|
108
|
-
this.mbMap = this.createMap(Object.assign({ style: this.getStyle(), container }, (((_c = this.options) === null || _c === void 0 ? void 0 : _c.mapOptions) || {})));
|
|
109
|
-
this.mbMap.on('sourcedata', () => {
|
|
110
|
-
var _a;
|
|
111
|
-
(_a = this.getSource()) === null || _a === void 0 ? void 0 : _a.refresh(); // Refresh attribution
|
|
112
|
-
});
|
|
113
|
-
this.mbMap.once('load', () => {
|
|
114
|
-
this.loaded = true;
|
|
115
|
-
this.dispatchEvent(new BaseEvent('load'));
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
getStyle() {
|
|
119
|
-
// If the style is a complete style object, use it directly.
|
|
120
|
-
if (this.style &&
|
|
121
|
-
typeof this.style === 'object' &&
|
|
122
|
-
this.style.name &&
|
|
123
|
-
this.style.version) {
|
|
124
|
-
return this.style;
|
|
125
|
-
}
|
|
126
|
-
// If the url set is already a complete style url, use it directly.
|
|
127
|
-
if (this.url.includes('style.json')) {
|
|
128
|
-
return this.url;
|
|
129
|
-
}
|
|
130
|
-
/// Otherwise build the complete style url.
|
|
131
|
-
return getUrlWithParams(`${this.url}/styles/${this.style}/style.json`, {
|
|
132
|
-
[this.apiKeyName]: this.apiKey,
|
|
133
|
-
}).toString();
|
|
134
|
-
}
|
|
135
|
-
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
136
|
-
createMap(options) {
|
|
137
|
-
throw new Error('createMap must be implemented in child class');
|
|
138
|
-
}
|
|
139
|
-
updateMbMap() {
|
|
140
|
-
var _a;
|
|
141
|
-
(_a = this.mbMap) === null || _a === void 0 ? void 0 : _a.setStyle(this.getStyle(), { diff: false });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
export default MapGlLayer;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Layer } from 'ol/layer';
|
|
2
|
-
import { PropertiesLayerMixinOptions } from './PropertiesLayerMixin';
|
|
3
|
-
export type MobilityLayerOptions = PropertiesLayerMixinOptions & {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
};
|
|
6
|
-
type GConstructor<T = {}> = new (...args: any[]) => T;
|
|
7
|
-
export type Layerable = GConstructor<Omit<Layer, keyof string>>;
|
|
8
|
-
declare function MobilityLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
9
|
-
new (...args: any[]): {
|
|
10
|
-
options?: PropertiesLayerMixinOptions | undefined;
|
|
11
|
-
olListenersKeys: import("ol/events").EventsKey[];
|
|
12
|
-
children: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[];
|
|
13
|
-
get copyrights(): string;
|
|
14
|
-
set copyrights(newCopyrights: string | string[]);
|
|
15
|
-
disabled: boolean;
|
|
16
|
-
readonly group: string;
|
|
17
|
-
readonly hitTolerance: boolean;
|
|
18
|
-
readonly key: string;
|
|
19
|
-
readonly map: import("ol/Map").default;
|
|
20
|
-
readonly name: string;
|
|
21
|
-
olLayer: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>;
|
|
22
|
-
parent: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>;
|
|
23
|
-
visible: boolean;
|
|
24
|
-
setMapInternal: ((map: import("ol/Map").default) => void) & ((map: import("ol/Map").default | null) => void);
|
|
25
|
-
onChildrenChange(oldValue: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[]): void;
|
|
26
|
-
attachToMap(map: import("ol/Map").default): void;
|
|
27
|
-
detachFromMap(): void;
|
|
28
|
-
flat(): any[];
|
|
29
|
-
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
30
|
-
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
31
|
-
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
32
|
-
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
33
|
-
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
34
|
-
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
35
|
-
getSource: () => import("ol/source/Source").default | null;
|
|
36
|
-
getRenderSource: () => import("ol/source/Source").default | null;
|
|
37
|
-
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<import("ol/Feature").FeatureLike[]>;
|
|
38
|
-
getData: (pixel: import("ol/pixel").Pixel) => Float32Array | Uint8ClampedArray | Uint8Array | DataView | null;
|
|
39
|
-
isVisible: (view?: import("ol/View").default | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
40
|
-
getAttributions: (view?: import("ol/View").default | import("ol/View").ViewStateLayerStateExtent | undefined) => string[];
|
|
41
|
-
unrender: () => void;
|
|
42
|
-
getDeclutter: () => string;
|
|
43
|
-
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
44
|
-
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
45
|
-
getMapInternal: () => import("ol/Map").default | null;
|
|
46
|
-
setMap: (map: import("ol/Map").default | null) => void;
|
|
47
|
-
setSource: (source: import("ol/source/Source").default | null) => void;
|
|
48
|
-
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
49
|
-
hasRenderer: () => boolean;
|
|
50
|
-
getBackground: () => false | import("ol/layer/Base").BackgroundColor;
|
|
51
|
-
getClassName: () => string;
|
|
52
|
-
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
53
|
-
getLayersArray: (array?: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[];
|
|
54
|
-
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => import("ol/layer/Layer").State[];
|
|
55
|
-
getExtent: () => import("ol/extent").Extent | undefined;
|
|
56
|
-
getMaxResolution: () => number;
|
|
57
|
-
getMinResolution: () => number;
|
|
58
|
-
getMinZoom: () => number;
|
|
59
|
-
getMaxZoom: () => number;
|
|
60
|
-
getOpacity: () => number;
|
|
61
|
-
getSourceState: () => import("ol/source/Source").State;
|
|
62
|
-
getVisible: () => boolean;
|
|
63
|
-
getZIndex: () => number | undefined;
|
|
64
|
-
setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
|
|
65
|
-
setExtent: (extent: import("ol/extent").Extent | undefined) => void;
|
|
66
|
-
setMaxResolution: (maxResolution: number) => void;
|
|
67
|
-
setMinResolution: (minResolution: number) => void;
|
|
68
|
-
setMaxZoom: (maxZoom: number) => void;
|
|
69
|
-
setMinZoom: (minZoom: number) => void;
|
|
70
|
-
setOpacity: (opacity: number) => void;
|
|
71
|
-
setVisible: (visible: boolean) => void;
|
|
72
|
-
setZIndex: (zindex: number) => void;
|
|
73
|
-
get: (key: string) => any;
|
|
74
|
-
getKeys: () => string[];
|
|
75
|
-
getProperties: () => {
|
|
76
|
-
[x: string]: any;
|
|
77
|
-
};
|
|
78
|
-
getPropertiesInternal: () => {
|
|
79
|
-
[x: string]: any;
|
|
80
|
-
} | null;
|
|
81
|
-
hasProperties: () => boolean;
|
|
82
|
-
notify: (key: string, oldValue: any) => void;
|
|
83
|
-
addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
84
|
-
removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
85
|
-
set: (key: string, value: any, silent?: boolean | undefined) => void;
|
|
86
|
-
setProperties: (values: {
|
|
87
|
-
[x: string]: any;
|
|
88
|
-
}, silent?: boolean | undefined) => void;
|
|
89
|
-
unset: (key: string, silent?: boolean | undefined) => void;
|
|
90
|
-
changed: () => void;
|
|
91
|
-
getRevision: () => number;
|
|
92
|
-
dispatchEvent: (event: string | import("ol/events/Event").default) => boolean | undefined;
|
|
93
|
-
getListeners: (type: string) => import("ol/events").Listener[] | undefined;
|
|
94
|
-
hasListener: (type?: string | undefined) => boolean;
|
|
95
|
-
dispose: () => void;
|
|
96
|
-
};
|
|
97
|
-
} & TBase;
|
|
98
|
-
export default MobilityLayerMixin;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { Layer } from 'ol/layer';
|
|
2
|
-
import { EventsKey } from 'ol/events';
|
|
3
|
-
import { Map } from 'ol';
|
|
4
|
-
import type { Options } from 'ol/layer/Layer';
|
|
5
|
-
import type { Layerable } from './MobilityLayerMixin';
|
|
6
|
-
export type PropertiesLayerMixinOptions = Options & {
|
|
7
|
-
key?: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
group?: string;
|
|
10
|
-
copyrights?: string[];
|
|
11
|
-
children?: any[];
|
|
12
|
-
visible?: boolean;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
hitTolerance?: number;
|
|
15
|
-
properties?: {
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
};
|
|
18
|
-
map?: Map;
|
|
19
|
-
} & {
|
|
20
|
-
[x: string]: any;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* This mixin adds some properties to access ol custom properties easily.
|
|
24
|
-
*/
|
|
25
|
-
declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
26
|
-
new (...args: any[]): {
|
|
27
|
-
options?: PropertiesLayerMixinOptions | undefined;
|
|
28
|
-
olListenersKeys: EventsKey[];
|
|
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;
|
|
44
|
-
/**
|
|
45
|
-
* Initialize the layer with the map passed in parameters.
|
|
46
|
-
*
|
|
47
|
-
* @param {ol/Map~Map} map A map.
|
|
48
|
-
*/
|
|
49
|
-
attachToMap(map: Map): void;
|
|
50
|
-
/**
|
|
51
|
-
* Terminate what was initialized in init function. Remove layer, events...
|
|
52
|
-
*/
|
|
53
|
-
detachFromMap(): void;
|
|
54
|
-
/**
|
|
55
|
-
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
56
|
-
*/
|
|
57
|
-
flat(): any[];
|
|
58
|
-
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
59
|
-
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
60
|
-
on: import("ol/layer/Layer").LayerOnSignature<EventsKey>;
|
|
61
|
-
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
62
|
-
once: import("ol/layer/Layer").LayerOnSignature<EventsKey>;
|
|
63
|
-
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
64
|
-
getSource: () => import("ol/source/Source").default | null;
|
|
65
|
-
getRenderSource: () => import("ol/source/Source").default | null;
|
|
66
|
-
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<import("ol/Feature").FeatureLike[]>;
|
|
67
|
-
getData: (pixel: import("ol/pixel").Pixel) => Float32Array | Uint8ClampedArray | Uint8Array | DataView | null;
|
|
68
|
-
isVisible: (view?: import("ol/View").default | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
69
|
-
getAttributions: (view?: import("ol/View").default | import("ol/View").ViewStateLayerStateExtent | undefined) => string[];
|
|
70
|
-
unrender: () => void;
|
|
71
|
-
getDeclutter: () => string;
|
|
72
|
-
renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
|
|
73
|
-
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
74
|
-
getMapInternal: () => Map | null;
|
|
75
|
-
setMap: (map: Map | null) => void;
|
|
76
|
-
setSource: (source: import("ol/source/Source").default | null) => void;
|
|
77
|
-
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
78
|
-
hasRenderer: () => boolean;
|
|
79
|
-
getBackground: () => false | import("ol/layer/Base").BackgroundColor;
|
|
80
|
-
getClassName: () => string;
|
|
81
|
-
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
82
|
-
getLayersArray: (array?: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[];
|
|
83
|
-
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => import("ol/layer/Layer").State[];
|
|
84
|
-
getExtent: () => import("ol/extent").Extent | undefined;
|
|
85
|
-
getMaxResolution: () => number;
|
|
86
|
-
getMinResolution: () => number;
|
|
87
|
-
getMinZoom: () => number;
|
|
88
|
-
getMaxZoom: () => number;
|
|
89
|
-
getOpacity: () => number;
|
|
90
|
-
getSourceState: () => import("ol/source/Source").State;
|
|
91
|
-
getVisible: () => boolean;
|
|
92
|
-
getZIndex: () => number | undefined;
|
|
93
|
-
setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
|
|
94
|
-
setExtent: (extent: import("ol/extent").Extent | undefined) => void;
|
|
95
|
-
setMaxResolution: (maxResolution: number) => void;
|
|
96
|
-
setMinResolution: (minResolution: number) => void;
|
|
97
|
-
setMaxZoom: (maxZoom: number) => void;
|
|
98
|
-
setMinZoom: (minZoom: number) => void;
|
|
99
|
-
setOpacity: (opacity: number) => void;
|
|
100
|
-
setVisible: (visible: boolean) => void;
|
|
101
|
-
setZIndex: (zindex: number) => void;
|
|
102
|
-
get: (key: string) => any;
|
|
103
|
-
getKeys: () => string[];
|
|
104
|
-
getProperties: () => {
|
|
105
|
-
[x: string]: any;
|
|
106
|
-
};
|
|
107
|
-
getPropertiesInternal: () => {
|
|
108
|
-
[x: string]: any;
|
|
109
|
-
} | null;
|
|
110
|
-
hasProperties: () => boolean;
|
|
111
|
-
notify: (key: string, oldValue: any) => void;
|
|
112
|
-
addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
113
|
-
removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
114
|
-
set: (key: string, value: any, silent?: boolean | undefined) => void;
|
|
115
|
-
setProperties: (values: {
|
|
116
|
-
[x: string]: any;
|
|
117
|
-
}, silent?: boolean | undefined) => void;
|
|
118
|
-
unset: (key: string, silent?: boolean | undefined) => void;
|
|
119
|
-
changed: () => void;
|
|
120
|
-
getRevision: () => number;
|
|
121
|
-
dispatchEvent: (event: string | import("ol/events/Event").default) => boolean | undefined;
|
|
122
|
-
getListeners: (type: string) => import("ol/events").Listener[] | undefined;
|
|
123
|
-
hasListener: (type?: string | undefined) => boolean;
|
|
124
|
-
dispose: () => void;
|
|
125
|
-
};
|
|
126
|
-
} & TBase;
|
|
127
|
-
export default PropertiesLayerMixin;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { getUid } from 'ol';
|
|
2
|
-
import getLayersAsFlatArray from '../../common/utils/getLayersAsFlatArray';
|
|
3
|
-
/**
|
|
4
|
-
* This mixin adds some properties to access ol custom properties easily.
|
|
5
|
-
*/
|
|
6
|
-
function PropertiesLayerMixin(Base) {
|
|
7
|
-
return class PropertiesLayer extends Base {
|
|
8
|
-
get children() {
|
|
9
|
-
return this.get('children') || [];
|
|
10
|
-
}
|
|
11
|
-
set children(newValue) {
|
|
12
|
-
this.set('children', newValue || []);
|
|
13
|
-
}
|
|
14
|
-
get copyrights() {
|
|
15
|
-
// eslint-disable-next-line no-console
|
|
16
|
-
console.warn('Deprecated. Use the source object to get the attributions');
|
|
17
|
-
return this.get('copyrights');
|
|
18
|
-
}
|
|
19
|
-
set copyrights(newCopyrights) {
|
|
20
|
-
// eslint-disable-next-line no-console
|
|
21
|
-
console.warn('Deprecated. Use the source object to set the attributions');
|
|
22
|
-
const arrValue = newCopyrights && !Array.isArray(newCopyrights)
|
|
23
|
-
? [newCopyrights]
|
|
24
|
-
: newCopyrights;
|
|
25
|
-
this.set('copyrights', arrValue || []);
|
|
26
|
-
}
|
|
27
|
-
get disabled() {
|
|
28
|
-
return this.get('disabled');
|
|
29
|
-
}
|
|
30
|
-
set disabled(newValue) {
|
|
31
|
-
this.set('disabled', newValue);
|
|
32
|
-
}
|
|
33
|
-
get group() {
|
|
34
|
-
return this.get('group');
|
|
35
|
-
}
|
|
36
|
-
get hitTolerance() {
|
|
37
|
-
// eslint-disable-next-line no-console
|
|
38
|
-
console.warn('Deprecated. Pass the pixelTolerance when you request the features.');
|
|
39
|
-
return this.get('hitTolerance') || 5;
|
|
40
|
-
}
|
|
41
|
-
get key() {
|
|
42
|
-
return this.get('key') || this.get('name') || getUid(this);
|
|
43
|
-
}
|
|
44
|
-
get map() {
|
|
45
|
-
return this.getMapInternal();
|
|
46
|
-
}
|
|
47
|
-
get name() {
|
|
48
|
-
return this.get('name');
|
|
49
|
-
}
|
|
50
|
-
get olLayer() {
|
|
51
|
-
// eslint-disable-next-line no-console
|
|
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.");
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
// eslint-disable-next-line class-methods-use-this
|
|
56
|
-
set olLayer(newValue) {
|
|
57
|
-
// eslint-disable-next-line no-console
|
|
58
|
-
console.log('Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.');
|
|
59
|
-
}
|
|
60
|
-
get parent() {
|
|
61
|
-
return this.get('parent');
|
|
62
|
-
}
|
|
63
|
-
set parent(newValue) {
|
|
64
|
-
this.set('parent', newValue);
|
|
65
|
-
}
|
|
66
|
-
get visible() {
|
|
67
|
-
return this.getVisible();
|
|
68
|
-
}
|
|
69
|
-
set visible(newValue) {
|
|
70
|
-
this.setVisible(newValue);
|
|
71
|
-
}
|
|
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
|
-
};
|
|
142
|
-
}
|
|
143
|
-
export default PropertiesLayerMixin;
|