mobility-toolbox-js 3.0.0-beta.13 → 3.0.0-beta.15
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/common/typedefs.d.ts +2 -2
- package/common/typedefs.js +1 -1
- package/mbt.js +357 -216
- package/mbt.js.map +4 -4
- package/mbt.min.js +12 -12
- package/mbt.min.js.map +4 -4
- package/ol/layers/Layer.d.ts +2 -2
- package/ol/layers/MaplibreLayer.d.ts +19 -43
- package/ol/layers/MaplibreLayer.js +31 -98
- package/ol/layers/MaplibreStyleLayer.d.ts +3 -3
- package/ol/layers/MaplibreStyleLayer.js +15 -4
- package/ol/layers/RealtimeLayer.d.ts +4 -5
- package/ol/layers/RealtimeLayer.js +1 -1
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +31 -0
- package/ol/layers/index.d.ts +1 -0
- package/ol/layers/index.js +2 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +2 -2
- package/ol/mixins/PropertiesLayerMixin.d.ts +13 -2
- package/ol/mixins/PropertiesLayerMixin.js +40 -14
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/package.json +2 -1
package/ol/layers/Layer.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
|
3
3
|
declare const Layer_base: {
|
|
4
4
|
new (...args: any[]): {
|
|
5
5
|
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions | undefined;
|
|
6
|
-
|
|
6
|
+
olEventsKeys: import("ol/events").EventsKey[];
|
|
7
7
|
children: OLLayer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
8
8
|
get copyrights(): string;
|
|
9
9
|
set copyrights(newCopyrights: string | string[]);
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
readonly group: string;
|
|
12
|
-
readonly hitTolerance:
|
|
12
|
+
readonly hitTolerance: number;
|
|
13
13
|
readonly key: string;
|
|
14
14
|
readonly map: import("ol").Map;
|
|
15
15
|
readonly name: string;
|
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
import Source from 'ol/source/Source';
|
|
2
1
|
import OlMap from 'ol/Map';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { Map, MapOptions } from 'maplibre-gl';
|
|
2
|
+
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
|
|
3
|
+
import type { MapLibreLayerOptions } from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
|
|
6
4
|
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
7
|
-
|
|
8
|
-
export type MaplibreLayerOptions = MobilityLayerOptions & {
|
|
5
|
+
export type MaplibreLayerOptions = MobilityLayerOptions & MapLibreLayerOptions & {
|
|
9
6
|
apiKey?: string;
|
|
10
7
|
apiKeyName?: string;
|
|
11
8
|
style?: string | maplibregl.StyleSpecification;
|
|
12
9
|
url?: string;
|
|
13
|
-
mapOptions?: maplibregl.MapOptions;
|
|
14
|
-
queryRenderedFeaturesOptions?: maplibregl.QueryRenderedFeaturesOptions;
|
|
15
10
|
};
|
|
16
11
|
declare const MaplibreLayer_base: {
|
|
17
12
|
new (...args: any[]): {
|
|
18
13
|
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions | undefined;
|
|
19
|
-
|
|
20
|
-
children: Layer<Source, import("ol/renderer/Layer").default<any>>[];
|
|
14
|
+
olEventsKeys: import("ol/events").EventsKey[];
|
|
15
|
+
children: import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
21
16
|
get copyrights(): string;
|
|
22
17
|
set copyrights(newCopyrights: string | string[]);
|
|
23
18
|
disabled: boolean;
|
|
24
19
|
readonly group: string;
|
|
25
|
-
readonly hitTolerance:
|
|
20
|
+
readonly hitTolerance: number;
|
|
26
21
|
readonly key: string;
|
|
27
22
|
readonly map: OlMap;
|
|
28
23
|
readonly name: string;
|
|
29
|
-
olLayer: Layer<Source, import("ol/renderer/Layer").default<any>>;
|
|
30
|
-
parent: Layer<Source, import("ol/renderer/Layer").default<any>>;
|
|
24
|
+
olLayer: import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
25
|
+
parent: import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
31
26
|
visible: boolean;
|
|
32
27
|
setMapInternal: ((map: OlMap) => void) & ((map: OlMap | null) => void);
|
|
33
|
-
onChildrenChange(oldValue: Layer<Source, import("ol/renderer/Layer").default<any>>[]): void;
|
|
28
|
+
onChildrenChange(oldValue: import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[]): void;
|
|
34
29
|
attachToMap(map: OlMap): void;
|
|
35
30
|
detachFromMap(): void;
|
|
36
31
|
flat(): any[];
|
|
@@ -40,8 +35,8 @@ declare const MaplibreLayer_base: {
|
|
|
40
35
|
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
41
36
|
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
42
37
|
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
43
|
-
getSource: () => Source | null;
|
|
44
|
-
getRenderSource: () => Source | null;
|
|
38
|
+
getSource: () => import("ol/source").Source | null;
|
|
39
|
+
getRenderSource: () => import("ol/source").Source | null;
|
|
45
40
|
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<import("ol/Feature").FeatureLike[]>;
|
|
46
41
|
getData: (pixel: import("ol/pixel").Pixel) => Float32Array | Uint8ClampedArray | Uint8Array | DataView | null;
|
|
47
42
|
isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
|
|
@@ -52,13 +47,13 @@ declare const MaplibreLayer_base: {
|
|
|
52
47
|
renderDeferred: (frameState: import("ol/Map").FrameState) => void;
|
|
53
48
|
getMapInternal: () => OlMap | null;
|
|
54
49
|
setMap: (map: OlMap | null) => void;
|
|
55
|
-
setSource: (source: Source | null) => void;
|
|
50
|
+
setSource: (source: import("ol/source").Source | null) => void;
|
|
56
51
|
getRenderer: () => import("ol/renderer/Layer").default<any> | null;
|
|
57
52
|
hasRenderer: () => boolean;
|
|
58
53
|
getBackground: () => false | import("ol/layer/Base").BackgroundColor;
|
|
59
54
|
getClassName: () => string;
|
|
60
55
|
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>>[];
|
|
56
|
+
getLayersArray: (array?: import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[] | undefined) => import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
62
57
|
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => import("ol/layer/Layer").State[];
|
|
63
58
|
getExtent: () => import("ol/extent").Extent | undefined;
|
|
64
59
|
getMaxResolution: () => number;
|
|
@@ -97,12 +92,12 @@ declare const MaplibreLayer_base: {
|
|
|
97
92
|
unset: (key: string, silent?: boolean | undefined) => void;
|
|
98
93
|
changed: () => void;
|
|
99
94
|
getRevision: () => number;
|
|
100
|
-
dispatchEvent: (event: string |
|
|
95
|
+
dispatchEvent: (event: string | import("ol/events/Event").default) => boolean | undefined;
|
|
101
96
|
getListeners: (type: string) => import("ol/events").Listener[] | undefined;
|
|
102
97
|
hasListener: (type?: string | undefined) => boolean;
|
|
103
98
|
dispose: () => void;
|
|
104
99
|
};
|
|
105
|
-
} & typeof
|
|
100
|
+
} & typeof MapLibreLayer;
|
|
106
101
|
/**
|
|
107
102
|
* An OpenLayers layer able to display data from the [geOps Maps API](https://developer.geops.io/apis/maps).
|
|
108
103
|
*
|
|
@@ -112,7 +107,7 @@ declare const MaplibreLayer_base: {
|
|
|
112
107
|
* const layer = new MaplibreLayer({
|
|
113
108
|
* apiKey: 'yourApiKey',
|
|
114
109
|
* // apiKeyName: 'key',
|
|
115
|
-
* //
|
|
110
|
+
* // mapLibreOptions: {
|
|
116
111
|
* // interactive: false,
|
|
117
112
|
* // trackResize: false,
|
|
118
113
|
* // attributionControl: false,
|
|
@@ -124,22 +119,14 @@ declare const MaplibreLayer_base: {
|
|
|
124
119
|
* // url: 'https://maps.geops.io',
|
|
125
120
|
* });
|
|
126
121
|
*
|
|
127
|
-
* @classproperty {maplibregl.Map}
|
|
128
|
-
* @classproperty {maplibregl.QueryRenderedFeaturesOptions} queryRenderedFeaturesOptions - Options used when we query features using map.getFeaturesAtPixel().
|
|
122
|
+
* @classproperty {maplibregl.Map} mapLibreMap - The Maplibre map object. Readonly.
|
|
129
123
|
* @classproperty {string} style - geOps Maps api style.
|
|
130
124
|
* @extends {ol/layer/Layer~Layer}
|
|
131
125
|
* @public
|
|
132
126
|
*/
|
|
133
127
|
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
128
|
get mbMap(): maplibregl.Map | undefined;
|
|
141
|
-
get
|
|
142
|
-
set queryRenderedFeaturesOptions(newValue: maplibregl.QueryRenderedFeaturesOptions);
|
|
129
|
+
get maplibreMap(): maplibregl.Map | undefined;
|
|
143
130
|
get style(): string;
|
|
144
131
|
set style(newValue: string);
|
|
145
132
|
get url(): string;
|
|
@@ -150,7 +137,7 @@ declare class MaplibreLayer extends MaplibreLayer_base {
|
|
|
150
137
|
* @param {MaplibreLayerOptions} options
|
|
151
138
|
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
152
139
|
* @param {string} [options.apiKeyName="key"] The geOps Maps API key name.
|
|
153
|
-
* @param {maplibregl.MapOptions} [options.
|
|
140
|
+
* @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
|
|
154
141
|
* @param {string} [options.style="travic_v2"] The geOps Maps API style.
|
|
155
142
|
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
156
143
|
*/
|
|
@@ -160,18 +147,7 @@ declare class MaplibreLayer extends MaplibreLayer_base {
|
|
|
160
147
|
* @param {ol/Map~Map} map
|
|
161
148
|
*/
|
|
162
149
|
attachToMap(map: OlMap): void;
|
|
163
|
-
/**
|
|
164
|
-
* Terminate what was initialized in init function. Remove layer, events...
|
|
165
|
-
*/
|
|
166
|
-
detachFromMap(): void;
|
|
167
|
-
/**
|
|
168
|
-
* Create the Maplibre map.
|
|
169
|
-
* @private
|
|
170
|
-
*/
|
|
171
|
-
loadMbMap(): void;
|
|
172
150
|
getStyle(): string;
|
|
173
|
-
createMap(options: MapOptions): Map;
|
|
174
|
-
createRenderer(): MaplibreLayerRenderer;
|
|
175
151
|
updateMaplibreMap(): void;
|
|
176
152
|
/**
|
|
177
153
|
* Create a copy of the MaplibreLayer.
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import Source from 'ol/source/Source';
|
|
2
|
-
import BaseEvent from 'ol/events/Event';
|
|
3
|
-
import Layer from 'ol/layer/Layer';
|
|
4
1
|
import debounce from 'lodash.debounce';
|
|
5
|
-
import {
|
|
6
|
-
import { getUrlWithParams
|
|
2
|
+
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
|
|
3
|
+
import { getUrlWithParams } from '../../common/utils';
|
|
7
4
|
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
8
|
-
import MaplibreLayerRenderer from '../renderers/MaplibreLayerRenderer';
|
|
9
5
|
/**
|
|
10
6
|
* An OpenLayers layer able to display data from the [geOps Maps API](https://developer.geops.io/apis/maps).
|
|
11
7
|
*
|
|
@@ -15,7 +11,7 @@ import MaplibreLayerRenderer from '../renderers/MaplibreLayerRenderer';
|
|
|
15
11
|
* const layer = new MaplibreLayer({
|
|
16
12
|
* apiKey: 'yourApiKey',
|
|
17
13
|
* // apiKeyName: 'key',
|
|
18
|
-
* //
|
|
14
|
+
* // mapLibreOptions: {
|
|
19
15
|
* // interactive: false,
|
|
20
16
|
* // trackResize: false,
|
|
21
17
|
* // attributionControl: false,
|
|
@@ -27,35 +23,30 @@ import MaplibreLayerRenderer from '../renderers/MaplibreLayerRenderer';
|
|
|
27
23
|
* // url: 'https://maps.geops.io',
|
|
28
24
|
* });
|
|
29
25
|
*
|
|
30
|
-
* @classproperty {maplibregl.Map}
|
|
31
|
-
* @classproperty {maplibregl.QueryRenderedFeaturesOptions} queryRenderedFeaturesOptions - Options used when we query features using map.getFeaturesAtPixel().
|
|
26
|
+
* @classproperty {maplibregl.Map} mapLibreMap - The Maplibre map object. Readonly.
|
|
32
27
|
* @classproperty {string} style - geOps Maps api style.
|
|
33
28
|
* @extends {ol/layer/Layer~Layer}
|
|
34
29
|
* @public
|
|
35
30
|
*/
|
|
36
|
-
class MaplibreLayer extends MobilityLayerMixin(
|
|
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
|
-
}
|
|
31
|
+
class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
49
32
|
get mbMap() {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
50
34
|
console.warn('Deprecated. Use layer.maplibreMap.');
|
|
51
35
|
return this.maplibreMap;
|
|
52
36
|
}
|
|
53
|
-
get
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
get maplibreMap() {
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
console.warn('Deprecated. Use layer.mapLibreMap.');
|
|
40
|
+
return this.mapLibreMap;
|
|
41
|
+
}
|
|
42
|
+
// get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
|
|
43
|
+
// return this.get('queryRenderedFeaturesOptions');
|
|
44
|
+
// }
|
|
45
|
+
// set queryRenderedFeaturesOptions(
|
|
46
|
+
// newValue: maplibregl.QueryRenderedFeaturesOptions,
|
|
47
|
+
// ) {
|
|
48
|
+
// this.set('queryRenderedFeaturesOptions', newValue);
|
|
49
|
+
// }
|
|
59
50
|
get style() {
|
|
60
51
|
return this.get('style');
|
|
61
52
|
}
|
|
@@ -74,18 +65,12 @@ class MaplibreLayer extends MobilityLayerMixin(Layer) {
|
|
|
74
65
|
* @param {MaplibreLayerOptions} options
|
|
75
66
|
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
76
67
|
* @param {string} [options.apiKeyName="key"] The geOps Maps API key name.
|
|
77
|
-
* @param {maplibregl.MapOptions} [options.
|
|
68
|
+
* @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
|
|
78
69
|
* @param {string} [options.style="travic_v2"] The geOps Maps API style.
|
|
79
70
|
* @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
|
|
80
71
|
*/
|
|
81
72
|
constructor(options) {
|
|
82
|
-
super(Object.assign(Object.assign({
|
|
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) || {})) }));
|
|
73
|
+
super(Object.assign(Object.assign({ apiKeyName: 'key', style: 'travic_v2', url: 'https://maps.geops.io' }, (options || {})), { mapLibreOptions: Object.assign({}, (options.mapLibreOptions || {})) }));
|
|
89
74
|
}
|
|
90
75
|
/**
|
|
91
76
|
* Initialize the layer and listen to feature clicks.
|
|
@@ -93,66 +78,14 @@ class MaplibreLayer extends MobilityLayerMixin(Layer) {
|
|
|
93
78
|
*/
|
|
94
79
|
attachToMap(map) {
|
|
95
80
|
super.attachToMap(map);
|
|
96
|
-
this.
|
|
81
|
+
this.updateMaplibreMap();
|
|
97
82
|
const updateMaplibreMapDebounced = debounce(this.updateMaplibreMap.bind(this), 150);
|
|
98
|
-
this.
|
|
99
|
-
if (/(
|
|
83
|
+
this.olEventsKeys.push(this.on('propertychange', (evt) => {
|
|
84
|
+
if (/(url|style)/.test(evt.key)) {
|
|
100
85
|
updateMaplibreMapDebounced();
|
|
101
86
|
}
|
|
102
87
|
}));
|
|
103
88
|
}
|
|
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();
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Create the Maplibre map.
|
|
120
|
-
* @private
|
|
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
89
|
getStyle() {
|
|
157
90
|
// If the style is a complete style object, use it directly.
|
|
158
91
|
if (this.style &&
|
|
@@ -167,16 +100,16 @@ class MaplibreLayer extends MobilityLayerMixin(Layer) {
|
|
|
167
100
|
}
|
|
168
101
|
/// Otherwise build the complete style url.
|
|
169
102
|
return getUrlWithParams(`${this.url}/styles/${this.style}/style.json`, {
|
|
170
|
-
[this.apiKeyName]: this.apiKey,
|
|
103
|
+
[this.get('apiKeyName')]: this.get('apiKey'),
|
|
171
104
|
}).toString();
|
|
172
105
|
}
|
|
173
106
|
// eslint-disable-next-line class-methods-use-this
|
|
174
|
-
createMap(options) {
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
createRenderer() {
|
|
178
|
-
|
|
179
|
-
}
|
|
107
|
+
// createMap(options: MapOptions): Map {
|
|
108
|
+
// return new Map(options);
|
|
109
|
+
// }
|
|
110
|
+
// createRenderer(): MaplibreLayerRenderer {
|
|
111
|
+
// return new MaplibreLayerRenderer(this);
|
|
112
|
+
// }
|
|
180
113
|
updateMaplibreMap() {
|
|
181
114
|
var _a;
|
|
182
115
|
(_a = this.maplibreMap) === null || _a === void 0 ? void 0 : _a.setStyle(this.getStyle(), { diff: false });
|
|
@@ -18,13 +18,13 @@ export type MaplibreStyleLayerOptions = MaplibreLayerOptions & {
|
|
|
18
18
|
declare const MaplibreStyleLayer_base: {
|
|
19
19
|
new (...args: any[]): {
|
|
20
20
|
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions | undefined;
|
|
21
|
-
|
|
21
|
+
olEventsKeys: import("ol/events").EventsKey[];
|
|
22
22
|
children: Layer<Source, import("ol/renderer/Layer").default<any>>[];
|
|
23
23
|
get copyrights(): string;
|
|
24
24
|
set copyrights(newCopyrights: string | string[]);
|
|
25
25
|
disabled: boolean;
|
|
26
26
|
readonly group: string;
|
|
27
|
-
readonly hitTolerance:
|
|
27
|
+
readonly hitTolerance: number;
|
|
28
28
|
readonly key: string;
|
|
29
29
|
readonly map: Map;
|
|
30
30
|
readonly name: string;
|
|
@@ -169,7 +169,7 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
169
169
|
* @param {FilterFunction} [options.layersFilter] Filter function to decide which style layer to apply visiblity on. If not provided, the 'layers' property is used.
|
|
170
170
|
* @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
|
|
171
171
|
*/
|
|
172
|
-
constructor(options
|
|
172
|
+
constructor(options?: MaplibreStyleLayerOptions);
|
|
173
173
|
createRenderer(): MaplibreStyleLayerRenderer;
|
|
174
174
|
/**
|
|
175
175
|
* Initialize the layer.
|
|
@@ -105,8 +105,19 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
|
|
|
105
105
|
* @param {FilterFunction} [options.layersFilter] Filter function to decide which style layer to apply visiblity on. If not provided, the 'layers' property is used.
|
|
106
106
|
* @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
|
|
107
107
|
*/
|
|
108
|
-
constructor(options
|
|
109
|
-
|
|
108
|
+
constructor(options = {
|
|
109
|
+
mapLibreOptions: { style: { version: 8, sources: {}, layers: [] } },
|
|
110
|
+
}) {
|
|
111
|
+
/** Manage renamed property for backward compatibility with v2 */
|
|
112
|
+
if (options.mapboxLayer) {
|
|
113
|
+
// eslint-disable-next-line no-console
|
|
114
|
+
console.warn('options.mapboxLayer is deprecated. Use options.maplibreLayer instead.');
|
|
115
|
+
// eslint-disable-next-line no-param-reassign
|
|
116
|
+
options.maplibreLayer = options.mapboxLayer;
|
|
117
|
+
// eslint-disable-next-line no-param-reassign
|
|
118
|
+
delete options.mapboxLayer;
|
|
119
|
+
}
|
|
120
|
+
super(Object.assign({ source: new Source({}) }, options));
|
|
110
121
|
this.highlightedFeatures = [];
|
|
111
122
|
this.selectedFeatures = [];
|
|
112
123
|
/**
|
|
@@ -138,7 +149,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
|
|
|
138
149
|
if (!this.map.getTargetElement()) {
|
|
139
150
|
// If ther e is no target element the maplibreMap is not yet created, we
|
|
140
151
|
// relaunch the initialisation when it's the case.
|
|
141
|
-
this.
|
|
152
|
+
this.olEventsKeys.push(this.map.on('change:target', () => {
|
|
142
153
|
this.attachToMap(map);
|
|
143
154
|
}));
|
|
144
155
|
return;
|
|
@@ -158,7 +169,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
|
|
|
158
169
|
}
|
|
159
170
|
}
|
|
160
171
|
// Apply the visibiltity when layer's visibility change.
|
|
161
|
-
this.
|
|
172
|
+
this.olEventsKeys.push(
|
|
162
173
|
// @ts-expect-error 'load' is a custom event
|
|
163
174
|
this.maplibreLayer.on('load', this.onLoad.bind(this)), this.on('change:visible', (evt) => {
|
|
164
175
|
// Once the map is loaded we can apply visiblity without waiting
|
|
@@ -25,7 +25,7 @@ declare const RealtimeLayer_base: {
|
|
|
25
25
|
tenant: string;
|
|
26
26
|
bboxParameters?: {
|
|
27
27
|
[index: string]: string | number | boolean | string[] | number[] | boolean[];
|
|
28
|
-
} | undefined;
|
|
28
|
+
} | undefined;
|
|
29
29
|
time?: Date | undefined;
|
|
30
30
|
live?: boolean | undefined;
|
|
31
31
|
speed?: number | undefined;
|
|
@@ -46,8 +46,7 @@ declare const RealtimeLayer_base: {
|
|
|
46
46
|
motsByZoom: import("../../types").RealtimeMot[][];
|
|
47
47
|
generalizationLevel?: import("../../types").RealtimeGeneralizationLevel | undefined;
|
|
48
48
|
generalizationLevelByZoom: import("../../types").RealtimeGeneralizationLevel[];
|
|
49
|
-
renderTimeIntervalByZoom: number[];
|
|
50
|
-
/**
|
|
49
|
+
renderTimeIntervalByZoom: number[]; /**
|
|
51
50
|
* Destroy the container of the tracker.
|
|
52
51
|
* @private
|
|
53
52
|
*/
|
|
@@ -95,13 +94,13 @@ declare const RealtimeLayer_base: {
|
|
|
95
94
|
} & {
|
|
96
95
|
new (...args: any[]): {
|
|
97
96
|
options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions | undefined;
|
|
98
|
-
|
|
97
|
+
olEventsKeys: import("ol/events").EventsKey[];
|
|
99
98
|
children: Layer<Source, import("ol/renderer/Layer").default<any>>[];
|
|
100
99
|
get copyrights(): string;
|
|
101
100
|
set copyrights(newCopyrights: string | string[]);
|
|
102
101
|
disabled: boolean;
|
|
103
102
|
readonly group: string;
|
|
104
|
-
readonly hitTolerance:
|
|
103
|
+
readonly hitTolerance: number;
|
|
105
104
|
readonly key: string;
|
|
106
105
|
readonly map: Map;
|
|
107
106
|
readonly name: string;
|
|
@@ -89,7 +89,7 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
89
89
|
// @ts-expect-error - bad ts check RealtimeLayer is a BaseLayer
|
|
90
90
|
const index = this.map.getLayers().getArray().indexOf(this);
|
|
91
91
|
this.map.getLayers().insertAt(index, this.vectorLayer);
|
|
92
|
-
this.
|
|
92
|
+
this.olEventsKeys.push(...this.map.on(['moveend', 'change:target'],
|
|
93
93
|
// @ts-expect-error - bad ol definitions
|
|
94
94
|
(evt) => {
|
|
95
95
|
const view = (evt.map || evt.target).getView();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Coordinate } from 'ol/coordinate';
|
|
2
|
+
import { LayerGetFeatureInfoResponse } from '../../types';
|
|
3
|
+
import Layer from './Layer';
|
|
4
|
+
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated
|
|
7
|
+
*/
|
|
8
|
+
declare class VectorLayer extends Layer {
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
12
|
+
getFeatureInfoAtCoordinate(coordinate: Coordinate): Promise<LayerGetFeatureInfoResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
16
|
+
clone(newOptions: MobilityLayerOptions): VectorLayer;
|
|
17
|
+
}
|
|
18
|
+
export default VectorLayer;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Layer from './Layer';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated
|
|
4
|
+
*/
|
|
5
|
+
class VectorLayer extends Layer {
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
*/
|
|
9
|
+
getFeatureInfoAtCoordinate(coordinate) {
|
|
10
|
+
let features = [];
|
|
11
|
+
if (this.map) {
|
|
12
|
+
const pixel = this.map.getPixelFromCoordinate(coordinate);
|
|
13
|
+
features = this.map.getFeaturesAtPixel(pixel, {
|
|
14
|
+
layerFilter: (l) => l === this.olLayer,
|
|
15
|
+
hitTolerance: this.hitTolerance || 5,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return Promise.resolve({
|
|
19
|
+
features,
|
|
20
|
+
layer: this,
|
|
21
|
+
coordinate,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated
|
|
26
|
+
*/
|
|
27
|
+
clone(newOptions) {
|
|
28
|
+
return new VectorLayer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export default VectorLayer;
|
package/ol/layers/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { default as MaplibreLayer } from "./MaplibreLayer";
|
|
|
2
2
|
export { default as MaplibreStyleLayer } from "./MaplibreStyleLayer";
|
|
3
3
|
export { default as RealtimeLayer } from "./RealtimeLayer";
|
|
4
4
|
export { default as Layer } from "./Layer";
|
|
5
|
+
export { default as VectorLayer } from "./VectorLayer";
|
package/ol/layers/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default as MaplibreLayer } from './MaplibreLayer';
|
|
2
2
|
export { default as MaplibreStyleLayer } from './MaplibreStyleLayer';
|
|
3
3
|
export { default as RealtimeLayer } from './RealtimeLayer';
|
|
4
|
+
// Deprecated export
|
|
4
5
|
export { default as Layer } from './Layer';
|
|
6
|
+
export { default as VectorLayer } from './VectorLayer';
|
|
@@ -8,13 +8,13 @@ export type Layerable = GConstructor<Omit<Layer, keyof string>>;
|
|
|
8
8
|
declare function MobilityLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
9
9
|
new (...args: any[]): {
|
|
10
10
|
options?: PropertiesLayerMixinOptions | undefined;
|
|
11
|
-
|
|
11
|
+
olEventsKeys: import("ol/events").EventsKey[];
|
|
12
12
|
children: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
13
13
|
get copyrights(): string;
|
|
14
14
|
set copyrights(newCopyrights: string | string[]);
|
|
15
15
|
disabled: boolean;
|
|
16
16
|
readonly group: string;
|
|
17
|
-
readonly hitTolerance:
|
|
17
|
+
readonly hitTolerance: number;
|
|
18
18
|
readonly key: string;
|
|
19
19
|
readonly map: import("ol").Map;
|
|
20
20
|
readonly name: string;
|
|
@@ -25,18 +25,28 @@ export type PropertiesLayerMixinOptions = Options & {
|
|
|
25
25
|
declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
26
26
|
new (...args: any[]): {
|
|
27
27
|
options?: PropertiesLayerMixinOptions | undefined;
|
|
28
|
-
|
|
28
|
+
olEventsKeys: EventsKey[];
|
|
29
|
+
/** @deprecated */
|
|
29
30
|
children: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
31
|
+
/** @deprecated */
|
|
30
32
|
get copyrights(): string;
|
|
33
|
+
/** @deprecated */
|
|
31
34
|
set copyrights(newCopyrights: string | string[]);
|
|
35
|
+
/** @deprecated */
|
|
32
36
|
disabled: boolean;
|
|
37
|
+
/** @deprecated */
|
|
33
38
|
readonly group: string;
|
|
34
|
-
|
|
39
|
+
/** @deprecated */
|
|
40
|
+
readonly hitTolerance: number;
|
|
35
41
|
readonly key: string;
|
|
36
42
|
readonly map: Map;
|
|
43
|
+
/** @deprecated */
|
|
37
44
|
readonly name: string;
|
|
45
|
+
/** @deprecated */
|
|
38
46
|
olLayer: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
47
|
+
/** @deprecated */
|
|
39
48
|
parent: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
49
|
+
/** @deprecated */
|
|
40
50
|
visible: boolean;
|
|
41
51
|
setMapInternal(map: Map): void;
|
|
42
52
|
/** @private */
|
|
@@ -53,6 +63,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
53
63
|
detachFromMap(): void;
|
|
54
64
|
/**
|
|
55
65
|
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
66
|
+
* @deprecated
|
|
56
67
|
*/
|
|
57
68
|
flat(): any[];
|
|
58
69
|
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|