@vcmap/core 6.3.3 → 6.3.5
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/dist/src/cesium/wallpaperMaterial.js +2 -2
- package/dist/src/cesium/wallpaperMaterial.js.map +1 -1
- package/dist/src/featureProvider/mapboxFeatureProvider.d.ts +3 -2
- package/dist/src/featureProvider/mapboxFeatureProvider.js +19 -1
- package/dist/src/featureProvider/mapboxFeatureProvider.js.map +1 -1
- package/dist/src/layer/cesium/mapboxStyleCesiumImpl.d.ts +2 -1
- package/dist/src/layer/cesium/mapboxStyleCesiumImpl.js +8 -5
- package/dist/src/layer/cesium/mapboxStyleCesiumImpl.js.map +1 -1
- package/dist/src/layer/layerImplementation.d.ts +1 -0
- package/dist/src/layer/layerImplementation.js +23 -6
- package/dist/src/layer/layerImplementation.js.map +1 -1
- package/dist/src/layer/mapboxStyleLayer.d.ts +2 -1
- package/dist/src/layer/mapboxStyleLayer.js +42 -29
- package/dist/src/layer/mapboxStyleLayer.js.map +1 -1
- package/dist/src/layer/mapboxStyleLayerHelpers.d.ts +10 -0
- package/dist/src/layer/mapboxStyleLayerHelpers.js +30 -0
- package/dist/src/layer/mapboxStyleLayerHelpers.js.map +1 -0
- package/dist/src/layer/openlayers/mapboxStyleOpenlayersImpl.d.ts +2 -0
- package/dist/src/layer/openlayers/mapboxStyleOpenlayersImpl.js +16 -1
- package/dist/src/layer/openlayers/mapboxStyleOpenlayersImpl.js.map +1 -1
- package/package.json +7 -4
- package/src/cesium/wallpaperMaterial.js +2 -2
- package/src/featureProvider/mapboxFeatureProvider.ts +21 -4
- package/src/layer/cesium/mapboxStyleCesiumImpl.ts +13 -9
- package/src/layer/layerImplementation.ts +26 -6
- package/src/layer/mapboxStyleLayer.ts +58 -38
- package/src/layer/mapboxStyleLayerHelpers.ts +52 -0
- package/src/layer/openlayers/mapboxStyleOpenlayersImpl.ts +20 -2
|
@@ -12,8 +12,8 @@ Material._materialCache.addMaterial('Wallpaper', {
|
|
|
12
12
|
anchor: new Cartesian2(0, 0),
|
|
13
13
|
},
|
|
14
14
|
components: {
|
|
15
|
-
diffuse: '
|
|
16
|
-
alpha: '
|
|
15
|
+
diffuse: 'texture(image, fract((gl_FragCoord.xy - anchor.xy) / vec2(imageDimensions.xy))).rgb',
|
|
16
|
+
alpha: 'texture(image, fract((gl_FragCoord.xy - anchor.xy) / vec2(imageDimensions.xy))).a',
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
translucent: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallpaperMaterial.js","sourceRoot":"","sources":["../../../src/cesium/wallpaperMaterial.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AAEH,wCAAwC;AACxC,gDAAgD;AAChD,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,WAAW,EAAE;IAC/C,MAAM,EAAE;QACN,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE;YACR,KAAK,EAAE,QAAQ,CAAC,cAAc;YAC9B,MAAM,EAAE,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;SAC7B;QACD,UAAU,EAAE;YACV,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"wallpaperMaterial.js","sourceRoot":"","sources":["../../../src/cesium/wallpaperMaterial.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AAEH,wCAAwC;AACxC,gDAAgD;AAChD,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,WAAW,EAAE;IAC/C,MAAM,EAAE;QACN,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE;YACR,KAAK,EAAE,QAAQ,CAAC,cAAc;YAC9B,MAAM,EAAE,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;SAC7B;QACD,UAAU,EAAE;YACV,OAAO,EACL,qFAAqF;YACvF,KAAK,EACH,mFAAmF;SACtF;KACF;IACD,WAAW,EAAE,KAAK;CACnB,CAAC,CAAC;AAEH,4EAA4E;AAC5E,sBAAsB;AACtB,yEAAyE;AACzE,sFAAsF;AACtF,mEAAmE;AACnE,yBAAyB;AACzB,yBAAyB;AACzB,2BAA2B;AAC3B,iDAAiD;AACjD,4BAA4B;AAC5B,KAAK;AACL,EAAE;AACF,iEAAiE;AACjE,wBAAwB;AACxB,KAAK;AACL,EAAE;AACF,0EAA0E;AAC1E,mCAAmC;AACnC,iBAAiB;AACjB,2BAA2B;AAC3B,2BAA2B;AAC3B,SAAS;AACT,MAAM;AACN,EAAE;AACF,gCAAgC;AAChC,sHAAsH;AACtH,uCAAuC;AACvC,qDAAqD;AACrD,qDAAqD;AACrD,aAAa;AACb,mDAAmD;AACnD,MAAM;AACN,mBAAmB;AACnB,KAAK;AACL,EAAE;AACF,iEAAiE;AACjE,gCAAgC;AAChC,yDAAyD;AACzD,uCAAuC;AACvC,KAAK"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import type LayerGroup from 'ol/layer/Group.js';
|
|
1
2
|
import type Feature from 'ol/Feature.js';
|
|
2
3
|
import type { Coordinate } from 'ol/coordinate.js';
|
|
3
|
-
import type LayerGroup from 'ol/layer/Group.js';
|
|
4
4
|
import type Layer from '../layer/layer.js';
|
|
5
5
|
import AbstractFeatureProvider, { type AbstractFeatureProviderOptions } from './abstractFeatureProvider.js';
|
|
6
6
|
export type MapboxFeatureProviderOptions = AbstractFeatureProviderOptions & {
|
|
7
|
-
|
|
7
|
+
createStyledLayerGroup: () => Promise<LayerGroup>;
|
|
8
8
|
excludeLayerFromPicking?: string[];
|
|
9
9
|
};
|
|
10
10
|
export default class MapboxFeatureProvider extends AbstractFeatureProvider {
|
|
11
11
|
static get className(): string;
|
|
12
12
|
protected _inRenderingOrder: boolean;
|
|
13
13
|
private _renderMap;
|
|
14
|
+
private _styledLayerGroup?;
|
|
14
15
|
private _excludeLayerFromPicking?;
|
|
15
16
|
constructor(options: MapboxFeatureProviderOptions);
|
|
16
17
|
getFeaturesByCoordinate(coordinate: Coordinate, resolution: number, layer: Layer): Promise<Feature[]>;
|
|
@@ -10,11 +10,24 @@ export default class MapboxFeatureProvider extends AbstractFeatureProvider {
|
|
|
10
10
|
}
|
|
11
11
|
_inRenderingOrder = true;
|
|
12
12
|
_renderMap = new OLMap({ target: document.createElement('div') });
|
|
13
|
+
_styledLayerGroup;
|
|
13
14
|
_excludeLayerFromPicking;
|
|
14
15
|
constructor(options) {
|
|
15
16
|
super(options);
|
|
16
17
|
this._renderMap.setSize([256, 256]);
|
|
17
|
-
|
|
18
|
+
options
|
|
19
|
+
.createStyledLayerGroup()
|
|
20
|
+
.then((layerGroup) => {
|
|
21
|
+
if (this.isDestroyed) {
|
|
22
|
+
layerGroup.dispose();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this._styledLayerGroup = layerGroup;
|
|
26
|
+
this._renderMap.addLayer(layerGroup);
|
|
27
|
+
})
|
|
28
|
+
.catch((error) => {
|
|
29
|
+
this.getLogger().error('Error creating styled layer group', error);
|
|
30
|
+
});
|
|
18
31
|
this._excludeLayerFromPicking = options.excludeLayerFromPicking;
|
|
19
32
|
}
|
|
20
33
|
getFeaturesByCoordinate(coordinate, resolution, layer) {
|
|
@@ -41,6 +54,11 @@ export default class MapboxFeatureProvider extends AbstractFeatureProvider {
|
|
|
41
54
|
return Promise.resolve(features);
|
|
42
55
|
}
|
|
43
56
|
destroy() {
|
|
57
|
+
if (this._styledLayerGroup) {
|
|
58
|
+
this._renderMap.removeLayer(this._styledLayerGroup);
|
|
59
|
+
this._styledLayerGroup.dispose();
|
|
60
|
+
this._styledLayerGroup = undefined;
|
|
61
|
+
}
|
|
44
62
|
this._renderMap.setTarget(undefined);
|
|
45
63
|
this._renderMap.dispose();
|
|
46
64
|
super.destroy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapboxFeatureProvider.js","sourceRoot":"","sources":["../../../src/featureProvider/mapboxFeatureProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,MAAM,WAAW,CAAC;AAK9B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,uBAEN,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAOhE,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,uBAAuB;IACxE,MAAM,KAAK,SAAS;QAClB,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAES,iBAAiB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"mapboxFeatureProvider.js","sourceRoot":"","sources":["../../../src/featureProvider/mapboxFeatureProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,MAAM,WAAW,CAAC;AAK9B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,uBAEN,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAOhE,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,uBAAuB;IACxE,MAAM,KAAK,SAAS;QAClB,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAES,iBAAiB,GAAG,IAAI,CAAC;IAC3B,UAAU,GAAG,IAAI,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClE,iBAAiB,CAAc;IAC/B,wBAAwB,CAAY;I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CAAC,CAAC;QAC/D,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5B,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACrB,CAAC,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC;YAC7B,CAAC,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;YAC5B,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;gBACf,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YAClB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YACpD,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;YACjC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC1B,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -6,7 +6,7 @@ import type { LayerImplementationOptions } from '../layer.js';
|
|
|
6
6
|
import MapboxStyleImageryProvider from './imageryProvider/mapboxStyleImageryProvider.js';
|
|
7
7
|
import RasterLayerCesiumImpl from './rasterLayerCesiumImpl.js';
|
|
8
8
|
export type MapboxStyleLayerImplementationOptions = LayerImplementationOptions & {
|
|
9
|
-
|
|
9
|
+
createStyledLayerGroup: () => Promise<LayerGroup>;
|
|
10
10
|
splitDirection: SplitDirection;
|
|
11
11
|
minRenderingLevel?: number;
|
|
12
12
|
maxRenderingLevel?: number;
|
|
@@ -14,6 +14,7 @@ export type MapboxStyleLayerImplementationOptions = LayerImplementationOptions &
|
|
|
14
14
|
declare class MapboxStyleCesiumImpl extends RasterLayerCesiumImpl {
|
|
15
15
|
static get className(): string;
|
|
16
16
|
private _styledMapboxLayerGroup;
|
|
17
|
+
private _createStyledLayerGroup;
|
|
17
18
|
minRenderingLevel: number | undefined;
|
|
18
19
|
maxRenderingLevel: number | undefined;
|
|
19
20
|
imageryProvider: MapboxStyleImageryProvider | undefined;
|
|
@@ -9,6 +9,7 @@ class MapboxStyleCesiumImpl extends RasterLayerCesiumImpl {
|
|
|
9
9
|
return 'MapboxStyleCesiumImpl';
|
|
10
10
|
}
|
|
11
11
|
_styledMapboxLayerGroup;
|
|
12
|
+
_createStyledLayerGroup;
|
|
12
13
|
minRenderingLevel;
|
|
13
14
|
maxRenderingLevel;
|
|
14
15
|
imageryProvider = undefined;
|
|
@@ -20,17 +21,18 @@ class MapboxStyleCesiumImpl extends RasterLayerCesiumImpl {
|
|
|
20
21
|
tilingSchema: TilingScheme.MERCATOR,
|
|
21
22
|
opacity: 1,
|
|
22
23
|
});
|
|
23
|
-
this.
|
|
24
|
+
this._createStyledLayerGroup = options.createStyledLayerGroup;
|
|
24
25
|
this.minRenderingLevel = options.minRenderingLevel;
|
|
25
26
|
this.maxRenderingLevel = options.maxRenderingLevel;
|
|
26
27
|
}
|
|
27
28
|
async activate() {
|
|
28
29
|
await super.activate();
|
|
29
|
-
if (this.active) {
|
|
30
|
+
if (this.active && this._styledMapboxLayerGroup) {
|
|
30
31
|
this._styledMapboxLayerGroup.setVisible(true);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
getCesiumLayer() {
|
|
34
|
+
async getCesiumLayer() {
|
|
35
|
+
this._styledMapboxLayerGroup = await this._createStyledLayerGroup();
|
|
34
36
|
const options = {
|
|
35
37
|
headers: this.headers,
|
|
36
38
|
styledMapboxLayerGroup: this._styledMapboxLayerGroup,
|
|
@@ -45,12 +47,13 @@ class MapboxStyleCesiumImpl extends RasterLayerCesiumImpl {
|
|
|
45
47
|
const extent = this.extent.getCoordinatesInProjection(wgs84Projection);
|
|
46
48
|
layerOptions.rectangle = Rectangle.fromDegrees(extent[0], extent[1], extent[2], extent[3]);
|
|
47
49
|
}
|
|
48
|
-
return Promise.resolve(
|
|
49
50
|
// @ts-expect-error mistyped
|
|
50
|
-
new CesiumImageryLayer(this.imageryProvider, layerOptions)
|
|
51
|
+
return new CesiumImageryLayer(this.imageryProvider, layerOptions);
|
|
51
52
|
}
|
|
52
53
|
destroy() {
|
|
53
54
|
this.imageryProvider?.destroy();
|
|
55
|
+
this._styledMapboxLayerGroup?.dispose();
|
|
56
|
+
this._styledMapboxLayerGroup = undefined;
|
|
54
57
|
super.destroy();
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapboxStyleCesiumImpl.js","sourceRoot":"","sources":["../../../../src/layer/cesium/mapboxStyleCesiumImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,IAAI,kBAAkB,EAClC,SAAS,GACV,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAC3D,OAAO,0BAEN,MAAM,iDAAiD,CAAC;AACzD,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAU/D,MAAM,qBAAsB,SAAQ,qBAAqB;IACvD,MAAM,KAAK,SAAS;QAClB,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAEO,uBAAuB,
|
|
1
|
+
{"version":3,"file":"mapboxStyleCesiumImpl.js","sourceRoot":"","sources":["../../../../src/layer/cesium/mapboxStyleCesiumImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,IAAI,kBAAkB,EAClC,SAAS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AI,CAAC,OAAO;YACrB,sBAAsB,EAAE,IAAI,CAAC,uBAAuB;YACpD,mBAAmB,EAAE,IAAI,CAAC,iBAAiB;YAC3C,mBAAmB,EAAE,IAAI,CAAC,iBAAiB;YAC3C,YAAY,EAAE,IAAI,YAAY,CAAC,EAAE,CAAC;YAClC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;SACrB,CAAC;QAEF,IAAI,CAAC,eAAe,GAAG,IAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC;QAE/D,MAAM,YAAY,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAClD,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,eAAe,CAAC,CAAC;YACvE,YAAY,CAAC,SAAS,GAAG,SAAS,CAAC,WAAW,CAC5C,MAAM,CAAC,CAAC,CAAC,EACT,MAAM,CAAC,CAAC,CAAC,EACT,MAAM,CAAC,CAAC,CAAC,EACT,MAAM,CAAC,CAAC,CAAC,CACV,CAAC;QACJ,CAAC;QACD,4BAA4B;QAC5B,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;IACpE,CAAC;IAED,OAAO;QACL,IAAI,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,uBAAuB,EAAE,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QACzC,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -11,6 +11,7 @@ declare class LayerImplementation<M extends VcsMap> extends VcsObject {
|
|
|
11
11
|
url: string | undefined;
|
|
12
12
|
protected _state: LayerState;
|
|
13
13
|
private _initialized;
|
|
14
|
+
private _loadingPromise;
|
|
14
15
|
headers?: Record<string, string>;
|
|
15
16
|
constructor(map: M, options: LayerImplementationOptions);
|
|
16
17
|
get map(): M;
|
|
@@ -11,6 +11,7 @@ class LayerImplementation extends VcsObject {
|
|
|
11
11
|
url;
|
|
12
12
|
_state = LayerState.INACTIVE;
|
|
13
13
|
_initialized = false;
|
|
14
|
+
_loadingPromise = null;
|
|
14
15
|
headers;
|
|
15
16
|
constructor(map, options) {
|
|
16
17
|
super(options);
|
|
@@ -49,12 +50,28 @@ class LayerImplementation extends VcsObject {
|
|
|
49
50
|
* Once the promise resolves, the layer can still be inactive, if deactivate was called while initializing the layer.
|
|
50
51
|
*/
|
|
51
52
|
async activate() {
|
|
52
|
-
if (this.
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
if (this._loadingPromise) {
|
|
54
|
+
await this._loadingPromise;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (this.map.active && this._state === LayerState.INACTIVE) {
|
|
58
|
+
this._loadingPromise = (async () => {
|
|
59
|
+
this._state = LayerState.LOADING;
|
|
60
|
+
await this.initialize();
|
|
61
|
+
if (this.loading) {
|
|
62
|
+
this._state = LayerState.ACTIVE;
|
|
63
|
+
}
|
|
64
|
+
})()
|
|
65
|
+
.catch((err) => {
|
|
66
|
+
if (this.loading) {
|
|
67
|
+
this._state = LayerState.INACTIVE;
|
|
68
|
+
}
|
|
69
|
+
return Promise.reject(err);
|
|
70
|
+
})
|
|
71
|
+
.finally(() => {
|
|
72
|
+
this._loadingPromise = null;
|
|
73
|
+
});
|
|
74
|
+
await this._loadingPromise;
|
|
58
75
|
}
|
|
59
76
|
}
|
|
60
77
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layerImplementation.js","sourceRoot":"","sources":["../../../src/layer/layerImplementation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,UAAU,MAAM,iBAAiB,CA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EG;IACH,OAAO;QACL,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -28,10 +28,10 @@ declare class MapboxStyleLayer extends Layer<MaboxStyleImplementation> implement
|
|
|
28
28
|
static get className(): string;
|
|
29
29
|
static getDefaultOptions(): MapboxStyleOptions;
|
|
30
30
|
protected _supportedMaps: string[];
|
|
31
|
-
private _mapboxLayerGroup;
|
|
32
31
|
private _sources?;
|
|
33
32
|
private _excludeLayerFromPicking?;
|
|
34
33
|
private _splitDirection;
|
|
34
|
+
private _boundCreateStyledLayerGroup;
|
|
35
35
|
splitDirectionChanged: VcsEvent<SplitDirection>;
|
|
36
36
|
/**
|
|
37
37
|
* defines the visible level in the rendered map, maps to Openlayers `minZoom` and Cesium `minimiumTerrainLevel`.
|
|
@@ -44,6 +44,7 @@ declare class MapboxStyleLayer extends Layer<MaboxStyleImplementation> implement
|
|
|
44
44
|
*/
|
|
45
45
|
maxRenderingLevel: number | undefined;
|
|
46
46
|
constructor(options: MapboxStyleOptions);
|
|
47
|
+
private _createStyledLayerGroup;
|
|
47
48
|
initialize(): Promise<void>;
|
|
48
49
|
get splitDirection(): SplitDirection;
|
|
49
50
|
set splitDirection(direction: SplitDirection);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { SplitDirection } from '@vcmap-cesium/engine';
|
|
2
2
|
import { parseInteger } from '@vcsuite/parsers';
|
|
3
3
|
import { is } from '@vcsuite/check';
|
|
4
|
-
import Collection from 'ol/Collection.js';
|
|
5
|
-
import LayerGroup from 'ol/layer/Group.js';
|
|
6
|
-
import { apply } from 'ol-mapbox-style';
|
|
7
4
|
import { layerClassRegistry } from '../classRegistry.js';
|
|
8
5
|
import AbstractAttributeProvider from '../featureProvider/abstractAttributeProvider.js';
|
|
9
6
|
import CompositeFeatureProvider from '../featureProvider/compositeFeatureProvider.js';
|
|
@@ -16,8 +13,8 @@ import PanoramaMap from '../map/panoramaMap.js';
|
|
|
16
13
|
import VcsEvent from '../vcsEvent.js';
|
|
17
14
|
import MapboxVectorRasterTileCesiumImpl from './cesium/mapboxStyleCesiumImpl.js';
|
|
18
15
|
import Layer from './layer.js';
|
|
16
|
+
import { createStyledMapboxLayerGroup } from './mapboxStyleLayerHelpers.js';
|
|
19
17
|
import MapboxVectorTileOpenlayersImpl from './openlayers/mapboxStyleOpenlayersImpl.js';
|
|
20
|
-
import { allowPicking, vcsLayerName } from './layerSymbols.js';
|
|
21
18
|
/**
|
|
22
19
|
* Layer class for Mapbox Style layers.
|
|
23
20
|
* @group Layer
|
|
@@ -39,10 +36,10 @@ class MapboxStyleLayer extends Layer {
|
|
|
39
36
|
OpenlayersMap.className,
|
|
40
37
|
PanoramaMap.className,
|
|
41
38
|
];
|
|
42
|
-
_mapboxLayerGroup;
|
|
43
39
|
_sources;
|
|
44
40
|
_excludeLayerFromPicking;
|
|
45
41
|
_splitDirection = SplitDirection.NONE;
|
|
42
|
+
_boundCreateStyledLayerGroup;
|
|
46
43
|
splitDirectionChanged = new VcsEvent();
|
|
47
44
|
/**
|
|
48
45
|
* defines the visible level in the rendered map, maps to Openlayers `minZoom` and Cesium `minimiumTerrainLevel`.
|
|
@@ -67,32 +64,22 @@ class MapboxStyleLayer extends Layer {
|
|
|
67
64
|
}
|
|
68
65
|
this.minRenderingLevel = parseInteger(options.minRenderingLevel, defaultOptions.minRenderingLevel);
|
|
69
66
|
this.maxRenderingLevel = parseInteger(options.maxRenderingLevel, defaultOptions.maxRenderingLevel);
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
this._boundCreateStyledLayerGroup = this._createStyledLayerGroup.bind(this);
|
|
68
|
+
}
|
|
69
|
+
_createStyledLayerGroup() {
|
|
70
|
+
return createStyledMapboxLayerGroup({
|
|
71
|
+
url: this.url,
|
|
72
|
+
name: this.name,
|
|
73
|
+
allowPicking: this.allowPicking,
|
|
74
|
+
sources: this._sources,
|
|
75
|
+
minRenderingLevel: this.minRenderingLevel,
|
|
76
|
+
maxRenderingLevel: this.maxRenderingLevel,
|
|
73
77
|
});
|
|
74
78
|
}
|
|
75
79
|
async initialize() {
|
|
76
|
-
if (!this.initialized) {
|
|
77
|
-
await apply(this._mapboxLayerGroup, this.url);
|
|
78
|
-
const layers = this._mapboxLayerGroup.getLayersArray();
|
|
79
|
-
layers.forEach((layer) => {
|
|
80
|
-
layer[vcsLayerName] = this.name;
|
|
81
|
-
layer[allowPicking] = super.allowPicking;
|
|
82
|
-
});
|
|
83
|
-
if (this._sources && this._sources.length > 0) {
|
|
84
|
-
const filteredCollection = new Collection();
|
|
85
|
-
layers
|
|
86
|
-
.filter((layer) => this._sources.includes(layer.get('mapbox-source')))
|
|
87
|
-
.forEach((layer) => {
|
|
88
|
-
filteredCollection.push(layer);
|
|
89
|
-
});
|
|
90
|
-
this._mapboxLayerGroup.setLayers(filteredCollection);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
80
|
if (!this.featureProvider) {
|
|
94
81
|
this.featureProvider = new MapboxFeatureProvider({
|
|
95
|
-
|
|
82
|
+
createStyledLayerGroup: this._boundCreateStyledLayerGroup,
|
|
96
83
|
excludeLayerFromPicking: this._excludeLayerFromPicking,
|
|
97
84
|
});
|
|
98
85
|
}
|
|
@@ -101,7 +88,7 @@ class MapboxStyleLayer extends Layer {
|
|
|
101
88
|
attributeProviders: [this.featureProvider],
|
|
102
89
|
featureProviders: [
|
|
103
90
|
new MapboxFeatureProvider({
|
|
104
|
-
|
|
91
|
+
createStyledLayerGroup: this._boundCreateStyledLayerGroup,
|
|
105
92
|
excludeLayerFromPicking: this._excludeLayerFromPicking,
|
|
106
93
|
}),
|
|
107
94
|
],
|
|
@@ -124,7 +111,7 @@ class MapboxStyleLayer extends Layer {
|
|
|
124
111
|
getImplementationOptions() {
|
|
125
112
|
return {
|
|
126
113
|
...super.getImplementationOptions(),
|
|
127
|
-
|
|
114
|
+
createStyledLayerGroup: this._boundCreateStyledLayerGroup,
|
|
128
115
|
splitDirection: this._splitDirection,
|
|
129
116
|
minRenderingLevel: this.minRenderingLevel,
|
|
130
117
|
maxRenderingLevel: this.maxRenderingLevel,
|
|
@@ -145,6 +132,33 @@ class MapboxStyleLayer extends Layer {
|
|
|
145
132
|
}
|
|
146
133
|
toJSON(defaultOptions = MapboxStyleLayer.getDefaultOptions()) {
|
|
147
134
|
const config = { ...super.toJSON() };
|
|
135
|
+
if (config.featureProvider?.type ===
|
|
136
|
+
MapboxFeatureProvider.className) {
|
|
137
|
+
delete config.featureProvider;
|
|
138
|
+
}
|
|
139
|
+
else if (config.featureProvider?.type ===
|
|
140
|
+
CompositeFeatureProvider.className) {
|
|
141
|
+
const compositeConfig = config.featureProvider;
|
|
142
|
+
const featureProviders = (compositeConfig.featureProviders || []).filter((providerConfig) => providerConfig.type !==
|
|
143
|
+
MapboxFeatureProvider.className);
|
|
144
|
+
const attributeProviders = compositeConfig.attributeProviders || [];
|
|
145
|
+
if (featureProviders.length === 0 && attributeProviders.length === 0) {
|
|
146
|
+
delete config.featureProvider;
|
|
147
|
+
}
|
|
148
|
+
else if (featureProviders.length === 0 &&
|
|
149
|
+
attributeProviders.length === 1) {
|
|
150
|
+
config.featureProvider =
|
|
151
|
+
attributeProviders[0];
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
const filteredComposite = {
|
|
155
|
+
...compositeConfig,
|
|
156
|
+
featureProviders,
|
|
157
|
+
attributeProviders,
|
|
158
|
+
};
|
|
159
|
+
config.featureProvider = filteredComposite;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
148
162
|
if (this._sources && this._sources.length > 0) {
|
|
149
163
|
config.sources = this._sources.slice();
|
|
150
164
|
}
|
|
@@ -166,7 +180,6 @@ class MapboxStyleLayer extends Layer {
|
|
|
166
180
|
}
|
|
167
181
|
destroy() {
|
|
168
182
|
this.splitDirectionChanged.destroy();
|
|
169
|
-
this._mapboxLayerGroup.dispose();
|
|
170
183
|
this.featureProvider?.destroy();
|
|
171
184
|
super.destroy();
|
|
172
185
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapboxStyleLayer.js","sourceRoot":"","sources":["../../../src/layer/mapboxStyleLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"mapboxStyleLayer.js","sourceRoot":"","sources":["../../../src/layer/mapboxStyleLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,yBAAyB,MAAM,iDAAiD,CAAC;AACxF,OAAO,wBAEN,MAAM,gDAAgD,CAAC;AACxD,OAAO,qBAEN,MAAM,6CAA6C,CAAC;AAErD,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,gCAEN,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,MAAM,YAAY,CAAC;AAG/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,O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AAC;QAED,IAAI,IAAI,CAAC,eAAe,KAAK,cAAc,CAAC,IAAI,EAAE,CAAC;YACjD,MAAM,CAAC,cAAc;gBACnB,IAAI,CAAC,eAAe,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QACpE,CAAC;QAED,IAAI,IAAI,CAAC,iBAAiB,KAAK,cAAc,CAAC,iBAAiB,EAAE,CAAC;YAChE,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACpD,CAAC;QAED,IAAI,IAAI,CAAC,iBAAiB,KAAK,cAAc,CAAC,iBAAiB,EAAE,CAAC;YAChE,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACpD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC;QAChC,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAED,kBAAkB,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAC/E,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import LayerGroup from 'ol/layer/Group.js';
|
|
2
|
+
export type StyledMapboxLayerGroupOptions = {
|
|
3
|
+
url: string;
|
|
4
|
+
name: string;
|
|
5
|
+
allowPicking: boolean;
|
|
6
|
+
sources?: string[];
|
|
7
|
+
minRenderingLevel?: number;
|
|
8
|
+
maxRenderingLevel?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function createStyledMapboxLayerGroup(options: StyledMapboxLayerGroupOptions): Promise<LayerGroup>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Collection from 'ol/Collection.js';
|
|
2
|
+
import LayerGroup from 'ol/layer/Group.js';
|
|
3
|
+
import { apply } from 'ol-mapbox-style';
|
|
4
|
+
import { allowPicking, vcsLayerName } from './layerSymbols.js';
|
|
5
|
+
async function applyStyleAndConfigureGroup(mapboxLayerGroup, options) {
|
|
6
|
+
await apply(mapboxLayerGroup, options.url);
|
|
7
|
+
const layers = mapboxLayerGroup.getLayersArray();
|
|
8
|
+
layers.forEach((layer) => {
|
|
9
|
+
layer[vcsLayerName] = options.name;
|
|
10
|
+
layer[allowPicking] = options.allowPicking;
|
|
11
|
+
});
|
|
12
|
+
if (options.sources && options.sources.length > 0) {
|
|
13
|
+
const filteredCollection = new Collection();
|
|
14
|
+
layers
|
|
15
|
+
.filter((layer) => options.sources.includes(layer.get('mapbox-source')))
|
|
16
|
+
.forEach((layer) => {
|
|
17
|
+
filteredCollection.push(layer);
|
|
18
|
+
});
|
|
19
|
+
mapboxLayerGroup.setLayers(filteredCollection);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export async function createStyledMapboxLayerGroup(options) {
|
|
23
|
+
const mapboxLayerGroup = new LayerGroup({
|
|
24
|
+
minZoom: options.minRenderingLevel,
|
|
25
|
+
maxZoom: options.maxRenderingLevel,
|
|
26
|
+
});
|
|
27
|
+
await applyStyleAndConfigureGroup(mapboxLayerGroup, options);
|
|
28
|
+
return mapboxLayerGroup;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=mapboxStyleLayerHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapboxStyleLayerHelpers.js","sourceRoot":"","sources":["../../../src/layer/mapboxStyleLayerHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAW/D,KAAK,UAAU,2BAA2B,CACxC,gBAA4B,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|
|
7
7
|
static get className(): string;
|
|
8
8
|
private _styledMapboxLayerGroup;
|
|
9
|
+
private _createStyledLayerGroup;
|
|
9
10
|
private _removeChildLayerListeners;
|
|
10
11
|
constructor(map: OpenlayersMap, options: MapboxStyleLayerImplementationOptions);
|
|
12
|
+
initialize(): Promise<void>;
|
|
11
13
|
getOLLayer(): OLLayerLike;
|
|
12
14
|
updateSplitDirection(splitDirection: SplitDirection): void;
|
|
13
15
|
destroy(): void;
|
|
@@ -6,12 +6,22 @@ class MapboxVectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
6
6
|
return 'MapboxVectorTileOpenlayersImpl';
|
|
7
7
|
}
|
|
8
8
|
_styledMapboxLayerGroup;
|
|
9
|
+
_createStyledLayerGroup;
|
|
9
10
|
_removeChildLayerListeners = null;
|
|
10
11
|
constructor(map, options) {
|
|
11
12
|
super(map, options);
|
|
12
|
-
this.
|
|
13
|
+
this._createStyledLayerGroup = options.createStyledLayerGroup;
|
|
14
|
+
}
|
|
15
|
+
async initialize() {
|
|
16
|
+
if (!this.initialized) {
|
|
17
|
+
this._styledMapboxLayerGroup = await this._createStyledLayerGroup();
|
|
18
|
+
}
|
|
19
|
+
await super.initialize();
|
|
13
20
|
}
|
|
14
21
|
getOLLayer() {
|
|
22
|
+
if (!this._styledMapboxLayerGroup) {
|
|
23
|
+
throw new Error('Mapbox layer group must be initialized before use');
|
|
24
|
+
}
|
|
15
25
|
return this._styledMapboxLayerGroup;
|
|
16
26
|
}
|
|
17
27
|
updateSplitDirection(splitDirection) {
|
|
@@ -19,6 +29,9 @@ class MapboxVectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
19
29
|
if (this.initialized) {
|
|
20
30
|
this._removeChildLayerListeners?.();
|
|
21
31
|
this._removeChildLayerListeners = null;
|
|
32
|
+
if (!this._styledMapboxLayerGroup) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
22
35
|
if (splitDirection !== SplitDirection.NONE) {
|
|
23
36
|
const childLayers = this._styledMapboxLayerGroup.getLayersArray();
|
|
24
37
|
const listenerKeys = [];
|
|
@@ -42,6 +55,8 @@ class MapboxVectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
42
55
|
destroy() {
|
|
43
56
|
this._removeChildLayerListeners?.();
|
|
44
57
|
this._removeChildLayerListeners = null;
|
|
58
|
+
this._styledMapboxLayerGroup?.dispose();
|
|
59
|
+
this._styledMapboxLayerGroup = undefined;
|
|
45
60
|
super.destroy();
|
|
46
61
|
}
|
|
47
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapboxStyleOpenlayersImpl.js","sourceRoot":"","sources":["../../../../src/layer/openlayers/mapboxStyleOpenlayersImpl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK3C,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D,MAAM,8BAA+B,SAAQ,mBAAmB;IAC9D,MAAM,KAAK,SAAS;QAClB,OAAO,gCAAgC,CAAC;IAC1C,CAAC;IAEO,uBAAuB,
|
|
1
|
+
{"version":3,"file":"mapboxStyleOpenlayersImpl.js","sourceRoot":"","sources":["../../../../src/layer/openlayers/mapboxStyleOpenlayersImpl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK3C,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D,MAAM,8BAA+B,SAAQ,mBAAmB;IAC9D,MAAM,KAAK,SAAS;QAClB,OAAO,gCAAgC,CAAC;IAC1C,CAAC;IAEO,uBAAuB,CAAyB;IAEhD,uBAAuB,CAA4B;IAEnD,0BAA0B,GAAwB,IAAI,CAAC;IAE/D,YACE,GAAkB,EAClB,OAA8C;QAE9C,KAAK,CAAC,GAAG,EAA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F,KAAK,CAAC,OAAO,EAAE,CAAC;gBAClB,CAAC,CAAC,CAAC;gBACH,IAAI,CAAC,0BAA0B,GAAG,GAAS,EAAE;oBAC3C,OAAO,CAAC,YAAY,CAAC,CAAC;gBACxB,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAAC,cAAc,EAAE,CAAC;gBAClE,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC5B,KAAK,CAAC,OAAO,EAAE,CAAC;gBAClB,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,0BAA0B,EAAE,EAAE,CAAC;QACpC,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC;QACvC,IAAI,CAAC,uBAAuB,EAAE,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QACzC,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF;AAED,eAAe,8BAA8B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcmap/core",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"@types/sinon-chai": "^3.2.12",
|
|
54
54
|
"@vcsuite/eslint-config": "^4.0.0",
|
|
55
55
|
"c8": "^10.1.2",
|
|
56
|
-
"canvas": "^2.
|
|
56
|
+
"canvas": "^3.2.3",
|
|
57
57
|
"chai": "^4.4.1",
|
|
58
58
|
"chai-as-promised": "^8.0.1",
|
|
59
|
-
"jsdom": "^
|
|
59
|
+
"jsdom": "^26.1.0",
|
|
60
60
|
"jsdom-global": "^3.0.2",
|
|
61
61
|
"madge": "^8.0.0",
|
|
62
62
|
"mocha": "^10.0.0",
|
|
@@ -86,7 +86,10 @@
|
|
|
86
86
|
"proj4": "^2.15.0",
|
|
87
87
|
"rbush": ">=4.0.0",
|
|
88
88
|
"rbush-knn": "^4.0.0",
|
|
89
|
-
"uuid": "^
|
|
89
|
+
"uuid": "^14.0.0"
|
|
90
|
+
},
|
|
91
|
+
"overrides": {
|
|
92
|
+
"serialize-javascript": "^7.0.5"
|
|
90
93
|
},
|
|
91
94
|
"engines": {
|
|
92
95
|
"node": "^20.0.0"
|
|
@@ -15,9 +15,9 @@ Material._materialCache.addMaterial('Wallpaper', {
|
|
|
15
15
|
},
|
|
16
16
|
components: {
|
|
17
17
|
diffuse:
|
|
18
|
-
'
|
|
18
|
+
'texture(image, fract((gl_FragCoord.xy - anchor.xy) / vec2(imageDimensions.xy))).rgb',
|
|
19
19
|
alpha:
|
|
20
|
-
'
|
|
20
|
+
'texture(image, fract((gl_FragCoord.xy - anchor.xy) / vec2(imageDimensions.xy))).a',
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
translucent: false,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { v4 as uuid } from 'uuid';
|
|
2
2
|
import OLMap from 'ol/Map.js';
|
|
3
|
+
import type LayerGroup from 'ol/layer/Group.js';
|
|
3
4
|
import type Feature from 'ol/Feature.js';
|
|
4
5
|
import type { Coordinate } from 'ol/coordinate.js';
|
|
5
|
-
import type LayerGroup from 'ol/layer/Group.js';
|
|
6
6
|
import type RenderFeature from 'ol/render/Feature.js';
|
|
7
7
|
import { toFeature } from 'ol/render/Feature.js';
|
|
8
8
|
import type Layer from '../layer/layer.js';
|
|
@@ -13,7 +13,7 @@ import AbstractFeatureProvider, {
|
|
|
13
13
|
import { isProvidedFeature } from './featureProviderSymbols.js';
|
|
14
14
|
|
|
15
15
|
export type MapboxFeatureProviderOptions = AbstractFeatureProviderOptions & {
|
|
16
|
-
|
|
16
|
+
createStyledLayerGroup: () => Promise<LayerGroup>;
|
|
17
17
|
excludeLayerFromPicking?: string[];
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -23,15 +23,27 @@ export default class MapboxFeatureProvider extends AbstractFeatureProvider {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
protected _inRenderingOrder = true;
|
|
26
|
-
|
|
27
26
|
private _renderMap = new OLMap({ target: document.createElement('div') });
|
|
27
|
+
private _styledLayerGroup?: LayerGroup;
|
|
28
28
|
private _excludeLayerFromPicking?: string[];
|
|
29
29
|
|
|
30
30
|
constructor(options: MapboxFeatureProviderOptions) {
|
|
31
31
|
super(options);
|
|
32
32
|
|
|
33
33
|
this._renderMap.setSize([256, 256]);
|
|
34
|
-
|
|
34
|
+
options
|
|
35
|
+
.createStyledLayerGroup()
|
|
36
|
+
.then((layerGroup) => {
|
|
37
|
+
if (this.isDestroyed) {
|
|
38
|
+
layerGroup.dispose();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this._styledLayerGroup = layerGroup;
|
|
42
|
+
this._renderMap.addLayer(layerGroup);
|
|
43
|
+
})
|
|
44
|
+
.catch((error: unknown) => {
|
|
45
|
+
this.getLogger().error('Error creating styled layer group', error);
|
|
46
|
+
});
|
|
35
47
|
this._excludeLayerFromPicking = options.excludeLayerFromPicking;
|
|
36
48
|
}
|
|
37
49
|
|
|
@@ -67,6 +79,11 @@ export default class MapboxFeatureProvider extends AbstractFeatureProvider {
|
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
destroy(): void {
|
|
82
|
+
if (this._styledLayerGroup) {
|
|
83
|
+
this._renderMap.removeLayer(this._styledLayerGroup);
|
|
84
|
+
this._styledLayerGroup.dispose();
|
|
85
|
+
this._styledLayerGroup = undefined;
|
|
86
|
+
}
|
|
70
87
|
this._renderMap.setTarget(undefined);
|
|
71
88
|
this._renderMap.dispose();
|
|
72
89
|
super.destroy();
|
|
@@ -16,7 +16,7 @@ import RasterLayerCesiumImpl from './rasterLayerCesiumImpl.js';
|
|
|
16
16
|
|
|
17
17
|
export type MapboxStyleLayerImplementationOptions =
|
|
18
18
|
LayerImplementationOptions & {
|
|
19
|
-
|
|
19
|
+
createStyledLayerGroup: () => Promise<LayerGroup>;
|
|
20
20
|
splitDirection: SplitDirection;
|
|
21
21
|
minRenderingLevel?: number;
|
|
22
22
|
maxRenderingLevel?: number;
|
|
@@ -27,7 +27,9 @@ class MapboxStyleCesiumImpl extends RasterLayerCesiumImpl {
|
|
|
27
27
|
return 'MapboxStyleCesiumImpl';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
private _styledMapboxLayerGroup: LayerGroup;
|
|
30
|
+
private _styledMapboxLayerGroup: LayerGroup | undefined;
|
|
31
|
+
|
|
32
|
+
private _createStyledLayerGroup: () => Promise<LayerGroup>;
|
|
31
33
|
|
|
32
34
|
minRenderingLevel: number | undefined;
|
|
33
35
|
|
|
@@ -46,19 +48,21 @@ class MapboxStyleCesiumImpl extends RasterLayerCesiumImpl {
|
|
|
46
48
|
tilingSchema: TilingScheme.MERCATOR,
|
|
47
49
|
opacity: 1,
|
|
48
50
|
});
|
|
49
|
-
this.
|
|
51
|
+
this._createStyledLayerGroup = options.createStyledLayerGroup;
|
|
50
52
|
this.minRenderingLevel = options.minRenderingLevel;
|
|
51
53
|
this.maxRenderingLevel = options.maxRenderingLevel;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
async activate(): Promise<void> {
|
|
55
57
|
await super.activate();
|
|
56
|
-
if (this.active) {
|
|
58
|
+
if (this.active && this._styledMapboxLayerGroup) {
|
|
57
59
|
this._styledMapboxLayerGroup.setVisible(true);
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
getCesiumLayer(): Promise<CesiumImageryLayer> {
|
|
63
|
+
async getCesiumLayer(): Promise<CesiumImageryLayer> {
|
|
64
|
+
this._styledMapboxLayerGroup = await this._createStyledLayerGroup();
|
|
65
|
+
|
|
62
66
|
const options: MapboxStyleImageryProviderOptions = {
|
|
63
67
|
headers: this.headers,
|
|
64
68
|
styledMapboxLayerGroup: this._styledMapboxLayerGroup,
|
|
@@ -80,14 +84,14 @@ class MapboxStyleCesiumImpl extends RasterLayerCesiumImpl {
|
|
|
80
84
|
extent[3],
|
|
81
85
|
);
|
|
82
86
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
new CesiumImageryLayer(this.imageryProvider, layerOptions),
|
|
86
|
-
);
|
|
87
|
+
// @ts-expect-error mistyped
|
|
88
|
+
return new CesiumImageryLayer(this.imageryProvider, layerOptions);
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
destroy(): void {
|
|
90
92
|
this.imageryProvider?.destroy();
|
|
93
|
+
this._styledMapboxLayerGroup?.dispose();
|
|
94
|
+
this._styledMapboxLayerGroup = undefined;
|
|
91
95
|
super.destroy();
|
|
92
96
|
}
|
|
93
97
|
}
|
|
@@ -19,6 +19,8 @@ class LayerImplementation<M extends VcsMap> extends VcsObject {
|
|
|
19
19
|
|
|
20
20
|
private _initialized = false;
|
|
21
21
|
|
|
22
|
+
private _loadingPromise: Promise<void> | null = null;
|
|
23
|
+
|
|
22
24
|
headers?: Record<string, string>;
|
|
23
25
|
|
|
24
26
|
constructor(map: M, options: LayerImplementationOptions) {
|
|
@@ -64,12 +66,30 @@ class LayerImplementation<M extends VcsMap> extends VcsObject {
|
|
|
64
66
|
* Once the promise resolves, the layer can still be inactive, if deactivate was called while initializing the layer.
|
|
65
67
|
*/
|
|
66
68
|
async activate(): Promise<void> {
|
|
67
|
-
if (this.
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
if (this._loadingPromise) {
|
|
70
|
+
await this._loadingPromise;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (this.map.active && this._state === LayerState.INACTIVE) {
|
|
75
|
+
this._loadingPromise = (async (): Promise<void> => {
|
|
76
|
+
this._state = LayerState.LOADING;
|
|
77
|
+
await this.initialize();
|
|
78
|
+
if (this.loading) {
|
|
79
|
+
this._state = LayerState.ACTIVE;
|
|
80
|
+
}
|
|
81
|
+
})()
|
|
82
|
+
.catch((err: unknown) => {
|
|
83
|
+
if (this.loading) {
|
|
84
|
+
this._state = LayerState.INACTIVE;
|
|
85
|
+
}
|
|
86
|
+
return Promise.reject(err as Error);
|
|
87
|
+
})
|
|
88
|
+
.finally(() => {
|
|
89
|
+
this._loadingPromise = null;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
await this._loadingPromise;
|
|
73
93
|
}
|
|
74
94
|
}
|
|
75
95
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { SplitDirection } from '@vcmap-cesium/engine';
|
|
2
2
|
import { parseInteger } from '@vcsuite/parsers';
|
|
3
3
|
import { is } from '@vcsuite/check';
|
|
4
|
-
import
|
|
5
|
-
import LayerGroup from 'ol/layer/Group.js';
|
|
6
|
-
import type BaseLayer from 'ol/layer/Base.js';
|
|
7
|
-
import { apply } from 'ol-mapbox-style';
|
|
4
|
+
import type LayerGroup from 'ol/layer/Group.js';
|
|
8
5
|
import { layerClassRegistry } from '../classRegistry.js';
|
|
9
6
|
import AbstractAttributeProvider from '../featureProvider/abstractAttributeProvider.js';
|
|
10
|
-
import CompositeFeatureProvider
|
|
11
|
-
|
|
7
|
+
import CompositeFeatureProvider, {
|
|
8
|
+
type CompositeFeatureProviderOptions,
|
|
9
|
+
} from '../featureProvider/compositeFeatureProvider.js';
|
|
10
|
+
import MapboxFeatureProvider, {
|
|
11
|
+
type MapboxFeatureProviderOptions,
|
|
12
|
+
} from '../featureProvider/mapboxFeatureProvider.js';
|
|
12
13
|
import type VcsMap from '../map/vcsMap.js';
|
|
13
14
|
import BaseCesiumMap from '../map/baseCesiumMap.js';
|
|
14
15
|
import CesiumMap from '../map/cesiumMap.js';
|
|
@@ -22,8 +23,8 @@ import MapboxVectorRasterTileCesiumImpl, {
|
|
|
22
23
|
import Layer from './layer.js';
|
|
23
24
|
import type { LayerOptions, SplitLayer } from './layer.js';
|
|
24
25
|
import type LayerImplementation from './layerImplementation.js';
|
|
26
|
+
import { createStyledMapboxLayerGroup } from './mapboxStyleLayerHelpers.js';
|
|
25
27
|
import MapboxVectorTileOpenlayersImpl from './openlayers/mapboxStyleOpenlayersImpl.js';
|
|
26
|
-
import { allowPicking, vcsLayerName } from './layerSymbols.js';
|
|
27
28
|
|
|
28
29
|
export type MapboxStyleOptions = LayerOptions & {
|
|
29
30
|
/** The sources from the Mapbox Style to use. If not provided, all sources from the style will be used. */
|
|
@@ -68,10 +69,10 @@ class MapboxStyleLayer
|
|
|
68
69
|
OpenlayersMap.className,
|
|
69
70
|
PanoramaMap.className,
|
|
70
71
|
];
|
|
71
|
-
private _mapboxLayerGroup: LayerGroup;
|
|
72
72
|
private _sources?: string[];
|
|
73
73
|
private _excludeLayerFromPicking?: string[];
|
|
74
74
|
private _splitDirection: SplitDirection = SplitDirection.NONE;
|
|
75
|
+
private _boundCreateStyledLayerGroup: () => Promise<LayerGroup>;
|
|
75
76
|
splitDirectionChanged = new VcsEvent<SplitDirection>();
|
|
76
77
|
/**
|
|
77
78
|
* defines the visible level in the rendered map, maps to Openlayers `minZoom` and Cesium `minimiumTerrainLevel`.
|
|
@@ -104,40 +105,24 @@ class MapboxStyleLayer
|
|
|
104
105
|
options.maxRenderingLevel,
|
|
105
106
|
defaultOptions.maxRenderingLevel,
|
|
106
107
|
);
|
|
108
|
+
this._boundCreateStyledLayerGroup = this._createStyledLayerGroup.bind(this);
|
|
109
|
+
}
|
|
107
110
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
private _createStyledLayerGroup(): Promise<LayerGroup> {
|
|
112
|
+
return createStyledMapboxLayerGroup({
|
|
113
|
+
url: this.url,
|
|
114
|
+
name: this.name,
|
|
115
|
+
allowPicking: this.allowPicking,
|
|
116
|
+
sources: this._sources,
|
|
117
|
+
minRenderingLevel: this.minRenderingLevel,
|
|
118
|
+
maxRenderingLevel: this.maxRenderingLevel,
|
|
111
119
|
});
|
|
112
120
|
}
|
|
113
121
|
|
|
114
122
|
async initialize(): Promise<void> {
|
|
115
|
-
if (!this.initialized) {
|
|
116
|
-
await apply(this._mapboxLayerGroup, this.url);
|
|
117
|
-
|
|
118
|
-
const layers = this._mapboxLayerGroup.getLayersArray();
|
|
119
|
-
layers.forEach((layer) => {
|
|
120
|
-
layer[vcsLayerName] = this.name;
|
|
121
|
-
layer[allowPicking] = super.allowPicking;
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
if (this._sources && this._sources.length > 0) {
|
|
125
|
-
const filteredCollection = new Collection<BaseLayer>();
|
|
126
|
-
layers
|
|
127
|
-
.filter((layer) =>
|
|
128
|
-
this._sources!.includes(layer.get('mapbox-source') as string),
|
|
129
|
-
)
|
|
130
|
-
.forEach((layer) => {
|
|
131
|
-
filteredCollection.push(layer);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
this._mapboxLayerGroup.setLayers(filteredCollection);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
123
|
if (!this.featureProvider) {
|
|
139
124
|
this.featureProvider = new MapboxFeatureProvider({
|
|
140
|
-
|
|
125
|
+
createStyledLayerGroup: this._boundCreateStyledLayerGroup,
|
|
141
126
|
excludeLayerFromPicking: this._excludeLayerFromPicking,
|
|
142
127
|
});
|
|
143
128
|
} else if (is(this.featureProvider, AbstractAttributeProvider)) {
|
|
@@ -145,7 +130,7 @@ class MapboxStyleLayer
|
|
|
145
130
|
attributeProviders: [this.featureProvider],
|
|
146
131
|
featureProviders: [
|
|
147
132
|
new MapboxFeatureProvider({
|
|
148
|
-
|
|
133
|
+
createStyledLayerGroup: this._boundCreateStyledLayerGroup,
|
|
149
134
|
excludeLayerFromPicking: this._excludeLayerFromPicking,
|
|
150
135
|
}),
|
|
151
136
|
],
|
|
@@ -172,7 +157,7 @@ class MapboxStyleLayer
|
|
|
172
157
|
getImplementationOptions(): MapboxStyleLayerImplementationOptions {
|
|
173
158
|
return {
|
|
174
159
|
...super.getImplementationOptions(),
|
|
175
|
-
|
|
160
|
+
createStyledLayerGroup: this._boundCreateStyledLayerGroup,
|
|
176
161
|
splitDirection: this._splitDirection,
|
|
177
162
|
minRenderingLevel: this.minRenderingLevel,
|
|
178
163
|
maxRenderingLevel: this.maxRenderingLevel,
|
|
@@ -205,6 +190,42 @@ class MapboxStyleLayer
|
|
|
205
190
|
): MapboxStyleOptions {
|
|
206
191
|
const config: MapboxStyleOptions = { ...super.toJSON() };
|
|
207
192
|
|
|
193
|
+
if (
|
|
194
|
+
(config.featureProvider as MapboxFeatureProviderOptions)?.type ===
|
|
195
|
+
MapboxFeatureProvider.className
|
|
196
|
+
) {
|
|
197
|
+
delete config.featureProvider;
|
|
198
|
+
} else if (
|
|
199
|
+
(config.featureProvider as CompositeFeatureProviderOptions)?.type ===
|
|
200
|
+
CompositeFeatureProvider.className
|
|
201
|
+
) {
|
|
202
|
+
const compositeConfig =
|
|
203
|
+
config.featureProvider as CompositeFeatureProviderOptions;
|
|
204
|
+
const featureProviders = (compositeConfig.featureProviders || []).filter(
|
|
205
|
+
(providerConfig) =>
|
|
206
|
+
(providerConfig as MapboxFeatureProviderOptions).type !==
|
|
207
|
+
MapboxFeatureProvider.className,
|
|
208
|
+
);
|
|
209
|
+
const attributeProviders = compositeConfig.attributeProviders || [];
|
|
210
|
+
|
|
211
|
+
if (featureProviders.length === 0 && attributeProviders.length === 0) {
|
|
212
|
+
delete config.featureProvider;
|
|
213
|
+
} else if (
|
|
214
|
+
featureProviders.length === 0 &&
|
|
215
|
+
attributeProviders.length === 1
|
|
216
|
+
) {
|
|
217
|
+
config.featureProvider =
|
|
218
|
+
attributeProviders[0] as AbstractAttributeProvider;
|
|
219
|
+
} else {
|
|
220
|
+
const filteredComposite: CompositeFeatureProviderOptions = {
|
|
221
|
+
...compositeConfig,
|
|
222
|
+
featureProviders,
|
|
223
|
+
attributeProviders,
|
|
224
|
+
};
|
|
225
|
+
config.featureProvider = filteredComposite;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
208
229
|
if (this._sources && this._sources.length > 0) {
|
|
209
230
|
config.sources = this._sources.slice();
|
|
210
231
|
}
|
|
@@ -234,7 +255,6 @@ class MapboxStyleLayer
|
|
|
234
255
|
|
|
235
256
|
destroy(): void {
|
|
236
257
|
this.splitDirectionChanged.destroy();
|
|
237
|
-
this._mapboxLayerGroup.dispose();
|
|
238
258
|
this.featureProvider?.destroy();
|
|
239
259
|
super.destroy();
|
|
240
260
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Collection from 'ol/Collection.js';
|
|
2
|
+
import type BaseLayer from 'ol/layer/Base.js';
|
|
3
|
+
import LayerGroup from 'ol/layer/Group.js';
|
|
4
|
+
import { apply } from 'ol-mapbox-style';
|
|
5
|
+
import { allowPicking, vcsLayerName } from './layerSymbols.js';
|
|
6
|
+
|
|
7
|
+
export type StyledMapboxLayerGroupOptions = {
|
|
8
|
+
url: string;
|
|
9
|
+
name: string;
|
|
10
|
+
allowPicking: boolean;
|
|
11
|
+
sources?: string[];
|
|
12
|
+
minRenderingLevel?: number;
|
|
13
|
+
maxRenderingLevel?: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
async function applyStyleAndConfigureGroup(
|
|
17
|
+
mapboxLayerGroup: LayerGroup,
|
|
18
|
+
options: StyledMapboxLayerGroupOptions,
|
|
19
|
+
): Promise<void> {
|
|
20
|
+
await apply(mapboxLayerGroup, options.url);
|
|
21
|
+
|
|
22
|
+
const layers = mapboxLayerGroup.getLayersArray();
|
|
23
|
+
layers.forEach((layer) => {
|
|
24
|
+
layer[vcsLayerName] = options.name;
|
|
25
|
+
layer[allowPicking] = options.allowPicking;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (options.sources && options.sources.length > 0) {
|
|
29
|
+
const filteredCollection = new Collection<BaseLayer>();
|
|
30
|
+
layers
|
|
31
|
+
.filter((layer) =>
|
|
32
|
+
options.sources!.includes(layer.get('mapbox-source') as string),
|
|
33
|
+
)
|
|
34
|
+
.forEach((layer) => {
|
|
35
|
+
filteredCollection.push(layer);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
mapboxLayerGroup.setLayers(filteredCollection);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function createStyledMapboxLayerGroup(
|
|
43
|
+
options: StyledMapboxLayerGroupOptions,
|
|
44
|
+
): Promise<LayerGroup> {
|
|
45
|
+
const mapboxLayerGroup = new LayerGroup({
|
|
46
|
+
minZoom: options.minRenderingLevel,
|
|
47
|
+
maxZoom: options.maxRenderingLevel,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await applyStyleAndConfigureGroup(mapboxLayerGroup, options);
|
|
51
|
+
return mapboxLayerGroup;
|
|
52
|
+
}
|
|
@@ -12,7 +12,9 @@ class MapboxVectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
12
12
|
return 'MapboxVectorTileOpenlayersImpl';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
private _styledMapboxLayerGroup: LayerGroup;
|
|
15
|
+
private _styledMapboxLayerGroup: LayerGroup | undefined;
|
|
16
|
+
|
|
17
|
+
private _createStyledLayerGroup: () => Promise<LayerGroup>;
|
|
16
18
|
|
|
17
19
|
private _removeChildLayerListeners: (() => void) | null = null;
|
|
18
20
|
|
|
@@ -21,10 +23,20 @@ class MapboxVectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
21
23
|
options: MapboxStyleLayerImplementationOptions,
|
|
22
24
|
) {
|
|
23
25
|
super(map, options);
|
|
24
|
-
this.
|
|
26
|
+
this._createStyledLayerGroup = options.createStyledLayerGroup;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async initialize(): Promise<void> {
|
|
30
|
+
if (!this.initialized) {
|
|
31
|
+
this._styledMapboxLayerGroup = await this._createStyledLayerGroup();
|
|
32
|
+
}
|
|
33
|
+
await super.initialize();
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
getOLLayer(): OLLayerLike {
|
|
37
|
+
if (!this._styledMapboxLayerGroup) {
|
|
38
|
+
throw new Error('Mapbox layer group must be initialized before use');
|
|
39
|
+
}
|
|
28
40
|
return this._styledMapboxLayerGroup as OLLayerLike;
|
|
29
41
|
}
|
|
30
42
|
|
|
@@ -34,6 +46,10 @@ class MapboxVectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
34
46
|
this._removeChildLayerListeners?.();
|
|
35
47
|
this._removeChildLayerListeners = null;
|
|
36
48
|
|
|
49
|
+
if (!this._styledMapboxLayerGroup) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
37
53
|
if (splitDirection !== SplitDirection.NONE) {
|
|
38
54
|
const childLayers = this._styledMapboxLayerGroup.getLayersArray();
|
|
39
55
|
const listenerKeys: EventsKey[] = [];
|
|
@@ -61,6 +77,8 @@ class MapboxVectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
61
77
|
destroy(): void {
|
|
62
78
|
this._removeChildLayerListeners?.();
|
|
63
79
|
this._removeChildLayerListeners = null;
|
|
80
|
+
this._styledMapboxLayerGroup?.dispose();
|
|
81
|
+
this._styledMapboxLayerGroup = undefined;
|
|
64
82
|
super.destroy();
|
|
65
83
|
}
|
|
66
84
|
}
|