@deck.gl/mapbox 8.8.0-alpha.6 → 8.8.0-beta.3
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/dist.dev.js +155 -13
- package/dist/es5/deck-utils.js +1 -0
- package/dist/es5/deck-utils.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/mapbox-layer.js.map +1 -1
- package/dist/es5/mapbox-overlay.js +55 -11
- package/dist/es5/mapbox-overlay.js.map +1 -1
- package/dist/es5/resolve-layers.js +134 -0
- package/dist/es5/resolve-layers.js.map +1 -0
- package/dist/esm/deck-utils.js +1 -0
- package/dist/esm/deck-utils.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mapbox-layer.js.map +1 -1
- package/dist/esm/mapbox-overlay.js +49 -12
- package/dist/esm/mapbox-overlay.js.map +1 -1
- package/dist/esm/resolve-layers.js +73 -0
- package/dist/esm/resolve-layers.js.map +1 -0
- package/dist.min.js +1 -1
- package/package.json +2 -2
- package/src/deck-utils.ts +10 -1
- package/src/index.ts +2 -0
- package/src/mapbox-layer.ts +2 -0
- package/src/mapbox-overlay.ts +69 -14
- package/src/resolve-layers.ts +89 -0
- package/typed/deck-utils.d.ts +6 -0
- package/typed/deck-utils.d.ts.map +1 -1
- package/typed/index.d.ts +1 -0
- package/typed/index.d.ts.map +1 -1
- package/typed/mapbox-layer.d.ts +2 -0
- package/typed/mapbox-layer.d.ts.map +1 -1
- package/typed/mapbox-overlay.d.ts +11 -2
- package/typed/mapbox-overlay.d.ts.map +1 -1
- package/typed/resolve-layers.d.ts +5 -0
- package/typed/resolve-layers.d.ts.map +1 -0
package/src/mapbox-layer.ts
CHANGED
|
@@ -4,6 +4,8 @@ import type {Deck, Layer} from '@deck.gl/core';
|
|
|
4
4
|
|
|
5
5
|
export type MapboxLayerProps<LayerT extends Layer> = Partial<LayerT['props']> & {
|
|
6
6
|
id: string;
|
|
7
|
+
renderingMode?: '2d' | '3d';
|
|
8
|
+
deck?: Deck;
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export default class MapboxLayer<LayerT extends Layer> implements CustomLayerInterface {
|
package/src/mapbox-overlay.ts
CHANGED
|
@@ -5,28 +5,50 @@ import type {Map, IControl, MapMouseEvent} from 'mapbox-gl';
|
|
|
5
5
|
import type {MjolnirGestureEvent, MjolnirPointerEvent} from 'mjolnir.js';
|
|
6
6
|
import type {DeckProps} from '@deck.gl/core';
|
|
7
7
|
|
|
8
|
+
import {resolveLayers} from './resolve-layers';
|
|
9
|
+
|
|
10
|
+
export type MapboxOverlayProps = Omit<
|
|
11
|
+
DeckProps,
|
|
12
|
+
| 'width'
|
|
13
|
+
| 'height'
|
|
14
|
+
| 'gl'
|
|
15
|
+
| 'parent'
|
|
16
|
+
| 'canvas'
|
|
17
|
+
| '_customRender'
|
|
18
|
+
| 'viewState'
|
|
19
|
+
| 'initialViewState'
|
|
20
|
+
| 'controller'
|
|
21
|
+
>;
|
|
22
|
+
|
|
8
23
|
/**
|
|
9
24
|
* Implements Mapbox [IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) interface
|
|
10
25
|
* Renders deck.gl layers over the base map and automatically synchronizes with the map's camera
|
|
11
26
|
*/
|
|
12
27
|
export default class MapboxOverlay implements IControl {
|
|
13
|
-
private _props:
|
|
28
|
+
private _props: MapboxOverlayProps;
|
|
14
29
|
private _deck?: Deck;
|
|
15
30
|
private _map?: Map;
|
|
16
31
|
private _container?: HTMLDivElement;
|
|
32
|
+
private _interleaved: boolean;
|
|
17
33
|
|
|
18
|
-
constructor(
|
|
19
|
-
|
|
34
|
+
constructor(
|
|
35
|
+
props: MapboxOverlayProps & {
|
|
36
|
+
interleaved?: boolean;
|
|
37
|
+
}
|
|
38
|
+
) {
|
|
39
|
+
const {interleaved = false, ...otherProps} = props;
|
|
40
|
+
this._interleaved = interleaved;
|
|
41
|
+
this._props = otherProps;
|
|
20
42
|
}
|
|
21
43
|
|
|
22
44
|
/** Update (partial) props of the underlying Deck instance. */
|
|
23
|
-
setProps(props:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if ('viewState' in this._props) {
|
|
27
|
-
delete this._props.viewState;
|
|
45
|
+
setProps(props: MapboxOverlayProps): void {
|
|
46
|
+
if (this._interleaved && props.layers) {
|
|
47
|
+
resolveLayers(this._map, this._deck, this._props.layers, props.layers);
|
|
28
48
|
}
|
|
29
49
|
|
|
50
|
+
Object.assign(this._props, props);
|
|
51
|
+
|
|
30
52
|
if (this._deck) {
|
|
31
53
|
this._deck.setProps(this._props);
|
|
32
54
|
}
|
|
@@ -35,7 +57,10 @@ export default class MapboxOverlay implements IControl {
|
|
|
35
57
|
/** Called when the control is added to a map */
|
|
36
58
|
onAdd(map: Map): HTMLDivElement {
|
|
37
59
|
this._map = map;
|
|
60
|
+
return this._interleaved ? this._onAddInterleaved(map) : this._onAddOverlaid(map);
|
|
61
|
+
}
|
|
38
62
|
|
|
63
|
+
private _onAddOverlaid(map: Map): HTMLDivElement {
|
|
39
64
|
/* global document */
|
|
40
65
|
const container = document.createElement('div');
|
|
41
66
|
Object.assign(container.style, {
|
|
@@ -63,17 +88,29 @@ export default class MapboxOverlay implements IControl {
|
|
|
63
88
|
return container;
|
|
64
89
|
}
|
|
65
90
|
|
|
91
|
+
private _onAddInterleaved(map: Map): HTMLDivElement {
|
|
92
|
+
this._deck = new Deck({
|
|
93
|
+
...this._props,
|
|
94
|
+
// @ts-ignore non-public map property
|
|
95
|
+
gl: map.painter.context.gl
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
map.on('styledata', this._handleStyleChange);
|
|
99
|
+
resolveLayers(map, this._deck, [], this._props.layers);
|
|
100
|
+
|
|
101
|
+
return document.createElement('div');
|
|
102
|
+
}
|
|
103
|
+
|
|
66
104
|
/** Called when the control is removed from a map */
|
|
67
105
|
onRemove(): void {
|
|
68
106
|
const map = this._map;
|
|
69
107
|
|
|
70
108
|
if (map) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
map.off('dblclick', this._handleMouseEvent);
|
|
109
|
+
if (this._interleaved) {
|
|
110
|
+
this._onRemoveInterleaved(map);
|
|
111
|
+
} else {
|
|
112
|
+
this._onRemoveOverlaid(map);
|
|
113
|
+
}
|
|
77
114
|
}
|
|
78
115
|
|
|
79
116
|
this._deck?.finalize();
|
|
@@ -82,6 +119,20 @@ export default class MapboxOverlay implements IControl {
|
|
|
82
119
|
this._container = undefined;
|
|
83
120
|
}
|
|
84
121
|
|
|
122
|
+
private _onRemoveOverlaid(map: Map): void {
|
|
123
|
+
map.off('resize', this._updateContainerSize);
|
|
124
|
+
map.off('render', this._updateViewState);
|
|
125
|
+
map.off('mousemove', this._handleMouseEvent);
|
|
126
|
+
map.off('mouseout', this._handleMouseEvent);
|
|
127
|
+
map.off('click', this._handleMouseEvent);
|
|
128
|
+
map.off('dblclick', this._handleMouseEvent);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private _onRemoveInterleaved(map: Map): void {
|
|
132
|
+
map.off('styledata', this._handleStyleChange);
|
|
133
|
+
resolveLayers(map, this._deck, this._props.layers, []);
|
|
134
|
+
}
|
|
135
|
+
|
|
85
136
|
getDefaultPosition() {
|
|
86
137
|
return 'top-left';
|
|
87
138
|
}
|
|
@@ -113,6 +164,10 @@ export default class MapboxOverlay implements IControl {
|
|
|
113
164
|
}
|
|
114
165
|
}
|
|
115
166
|
|
|
167
|
+
private _handleStyleChange = () => {
|
|
168
|
+
resolveLayers(this._map, this._deck, this._props.layers, this._props.layers);
|
|
169
|
+
};
|
|
170
|
+
|
|
116
171
|
private _updateContainerSize = () => {
|
|
117
172
|
if (this._map && this._container) {
|
|
118
173
|
const {clientWidth, clientHeight} = this._map.getContainer();
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {_flatten as flatten} from '@deck.gl/core';
|
|
2
|
+
import MapboxLayer from './mapbox-layer';
|
|
3
|
+
|
|
4
|
+
import type {Deck, LayersList, Layer} from '@deck.gl/core';
|
|
5
|
+
import type {Map} from 'mapbox-gl';
|
|
6
|
+
|
|
7
|
+
const UNDEFINED_BEFORE_ID = '__UNDEFINED__';
|
|
8
|
+
|
|
9
|
+
/** Insert Deck layers into the mapbox Map according to the user-defined order */
|
|
10
|
+
export function resolveLayers(
|
|
11
|
+
map?: Map,
|
|
12
|
+
deck?: Deck,
|
|
13
|
+
oldLayers?: LayersList,
|
|
14
|
+
newLayers?: LayersList
|
|
15
|
+
) {
|
|
16
|
+
// Wait until map style is loaded
|
|
17
|
+
// @ts-ignore non-public map property
|
|
18
|
+
if (!map || !deck || !map.style || !map.style._loaded) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const layers = flatten(newLayers, Boolean) as Layer[];
|
|
23
|
+
|
|
24
|
+
if (oldLayers !== newLayers) {
|
|
25
|
+
// Step 1: remove layers that no longer exist
|
|
26
|
+
const prevLayers = flatten(oldLayers, Boolean) as Layer[];
|
|
27
|
+
const prevLayerIds = new Set<string>(prevLayers.map(l => l.id));
|
|
28
|
+
|
|
29
|
+
for (const layer of layers) {
|
|
30
|
+
prevLayerIds.delete(layer.id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (const id of prevLayerIds) {
|
|
34
|
+
if (map.getLayer(id)) {
|
|
35
|
+
map.removeLayer(id);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Step 2: add missing layers
|
|
41
|
+
for (const layer of layers) {
|
|
42
|
+
if (!map.getLayer(layer.id)) {
|
|
43
|
+
map.addLayer(
|
|
44
|
+
new MapboxLayer({id: layer.id, deck}),
|
|
45
|
+
// @ts-expect-error beforeId is not defined in LayerProps
|
|
46
|
+
layer.props.beforeId
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Step 3: check the order of layers
|
|
52
|
+
// If beforeId is defined, the deck layer should always render before the mapbox layer [beforeId]
|
|
53
|
+
// If beforeId is not defined, the deck layer should appear after all mapbox layers
|
|
54
|
+
// When two deck layers share the same beforeId, they are rendered in the order that is passed into Deck props.layers
|
|
55
|
+
// @ts-ignore non-public map property
|
|
56
|
+
const mapLayers: string[] = map.style._order;
|
|
57
|
+
|
|
58
|
+
// Group deck layers by beforeId
|
|
59
|
+
const layerGroups: Record<string, string[]> = {};
|
|
60
|
+
for (const layer of layers) {
|
|
61
|
+
// @ts-expect-error beforeId is not defined in LayerProps
|
|
62
|
+
let {beforeId} = layer.props;
|
|
63
|
+
if (!beforeId || !mapLayers.includes(beforeId)) {
|
|
64
|
+
beforeId = UNDEFINED_BEFORE_ID;
|
|
65
|
+
}
|
|
66
|
+
layerGroups[beforeId] = layerGroups[beforeId] || [];
|
|
67
|
+
layerGroups[beforeId].push(layer.id);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (const beforeId in layerGroups) {
|
|
71
|
+
const layerGroup = layerGroups[beforeId];
|
|
72
|
+
let lastLayerIndex =
|
|
73
|
+
beforeId === UNDEFINED_BEFORE_ID ? mapLayers.length : mapLayers.indexOf(beforeId);
|
|
74
|
+
let lastLayerId = beforeId === UNDEFINED_BEFORE_ID ? undefined : beforeId;
|
|
75
|
+
for (let i = layerGroup.length - 1; i >= 0; i--) {
|
|
76
|
+
const layerId = layerGroup[i];
|
|
77
|
+
const layerIndex = mapLayers.indexOf(layerId);
|
|
78
|
+
if (layerIndex !== lastLayerIndex - 1) {
|
|
79
|
+
map.moveLayer(layerId, lastLayerId);
|
|
80
|
+
if (layerIndex > lastLayerIndex) {
|
|
81
|
+
// The last layer's index have changed
|
|
82
|
+
lastLayerIndex++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
lastLayerIndex--;
|
|
86
|
+
lastLayerId = layerId;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
package/typed/deck-utils.d.ts
CHANGED
|
@@ -15,5 +15,11 @@ export declare function updateLayer(deck: Deck, layer: MapboxLayer<any>): void;
|
|
|
15
15
|
export declare function drawLayer(deck: Deck, map: Map, layer: MapboxLayer<any>): void;
|
|
16
16
|
export declare function getViewState(map: Map): MapViewState & {
|
|
17
17
|
repeat: boolean;
|
|
18
|
+
padding: {
|
|
19
|
+
left: number;
|
|
20
|
+
right: number;
|
|
21
|
+
top: number;
|
|
22
|
+
bottom: number;
|
|
23
|
+
};
|
|
18
24
|
};
|
|
19
25
|
//# sourceMappingURL=deck-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deck-utils.d.ts","sourceRoot":"","sources":["../src/deck-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAoD,MAAM,eAAe,CAAC;AACtF,OAAO,KAAK,EAAY,YAAY,EAAQ,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,WAAW,CAAC;AASnC,wBAAgB,eAAe,CAAC,EAC9B,GAAG,EACH,EAAE,EACF,IAAI,EACL,EAAE;IACD,GAAG,EAAE,GAAG,GAAG;QAAC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;KAAC,CAAC;IAClC,EAAE,EAAE,qBAAqB,CAAC;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,GAAG,IAAI,CAgEP;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAGlE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAGrE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAErE;AAED,wBAAgB,SAAS,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EAAE,OAAO,CAAC;IAChB,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAaA"}
|
package/typed/index.d.ts
CHANGED
package/typed/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE1D,YAAY,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC"}
|
package/typed/mapbox-layer.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { Map, CustomLayerInterface } from 'mapbox-gl';
|
|
|
2
2
|
import type { Deck, Layer } from '@deck.gl/core/typed';
|
|
3
3
|
export declare type MapboxLayerProps<LayerT extends Layer> = Partial<LayerT['props']> & {
|
|
4
4
|
id: string;
|
|
5
|
+
renderingMode?: '2d' | '3d';
|
|
6
|
+
deck?: Deck;
|
|
5
7
|
};
|
|
6
8
|
export default class MapboxLayer<LayerT extends Layer> implements CustomLayerInterface {
|
|
7
9
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapbox-layer.d.ts","sourceRoot":"","sources":["../src/mapbox-layer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,GAAG,EAAE,oBAAoB,EAAC,MAAM,WAAW,CAAC;AACzD,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} from '@deck.gl/core/typed';
|
|
2
2
|
import type { Map, IControl } from 'mapbox-gl';
|
|
3
3
|
import type { DeckProps } from '@deck.gl/core/typed';
|
|
4
|
+
export declare type MapboxOverlayProps = Omit<DeckProps, 'width' | 'height' | 'gl' | 'parent' | 'canvas' | '_customRender' | 'viewState' | 'initialViewState' | 'controller'>;
|
|
4
5
|
/**
|
|
5
6
|
* Implements Mapbox [IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) interface
|
|
6
7
|
* Renders deck.gl layers over the base map and automatically synchronizes with the map's camera
|
|
@@ -10,13 +11,20 @@ export default class MapboxOverlay implements IControl {
|
|
|
10
11
|
private _deck?;
|
|
11
12
|
private _map?;
|
|
12
13
|
private _container?;
|
|
13
|
-
|
|
14
|
+
private _interleaved;
|
|
15
|
+
constructor(props: MapboxOverlayProps & {
|
|
16
|
+
interleaved?: boolean;
|
|
17
|
+
});
|
|
14
18
|
/** Update (partial) props of the underlying Deck instance. */
|
|
15
|
-
setProps(props:
|
|
19
|
+
setProps(props: MapboxOverlayProps): void;
|
|
16
20
|
/** Called when the control is added to a map */
|
|
17
21
|
onAdd(map: Map): HTMLDivElement;
|
|
22
|
+
private _onAddOverlaid;
|
|
23
|
+
private _onAddInterleaved;
|
|
18
24
|
/** Called when the control is removed from a map */
|
|
19
25
|
onRemove(): void;
|
|
26
|
+
private _onRemoveOverlaid;
|
|
27
|
+
private _onRemoveInterleaved;
|
|
20
28
|
getDefaultPosition(): string;
|
|
21
29
|
/** Forwards the Deck.pickObject method */
|
|
22
30
|
pickObject(params: Parameters<Deck['pickObject']>[0]): ReturnType<Deck['pickObject']>;
|
|
@@ -26,6 +34,7 @@ export default class MapboxOverlay implements IControl {
|
|
|
26
34
|
pickObjects(params: Parameters<Deck['pickObjects']>[0]): ReturnType<Deck['pickObjects']>;
|
|
27
35
|
/** Remove from map and releases all resources */
|
|
28
36
|
finalize(): void;
|
|
37
|
+
private _handleStyleChange;
|
|
29
38
|
private _updateContainerSize;
|
|
30
39
|
private _updateViewState;
|
|
31
40
|
private _handleMouseEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapbox-overlay.d.ts","sourceRoot":"","sources":["../src/mapbox-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAS,MAAM,eAAe,CAAC;AAG3C,OAAO,KAAK,EAAC,GAAG,EAAE,QAAQ,EAAgB,MAAM,WAAW,CAAC;AAE5D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"mapbox-overlay.d.ts","sourceRoot":"","sources":["../src/mapbox-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAS,MAAM,eAAe,CAAC;AAG3C,OAAO,KAAK,EAAC,GAAG,EAAE,QAAQ,EAAgB,MAAM,WAAW,CAAC;AAE5D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAI7C,oBAAY,kBAAkB,GAAG,IAAI,CACnC,SAAS,EACP,OAAO,GACP,QAAQ,GACR,IAAI,GACJ,QAAQ,GACR,QAAQ,GACR,eAAe,GACf,WAAW,GACX,kBAAkB,GAClB,YAAY,CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,QAAQ;IACpD,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,KAAK,CAAC,CAAO;IACrB,OAAO,CAAC,IAAI,CAAC,CAAM;IACnB,OAAO,CAAC,UAAU,CAAC,CAAiB;IACpC,OAAO,CAAC,YAAY,CAAU;gBAG5B,KAAK,EAAE,kBAAkB,GAAG;QAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB;IAOH,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAYzC,gDAAgD;IAChD,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,cAAc;IAK/B,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,iBAAiB;IAazB,oDAAoD;IACpD,QAAQ,IAAI,IAAI;IAiBhB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,oBAAoB;IAK5B,kBAAkB;IAIlB,0CAA0C;IAC1C,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAKrF,mDAAmD;IACnD,mBAAmB,CACjB,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,GACjD,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAK1C,2CAA2C;IAC3C,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAKxF,iDAAiD;IACjD,QAAQ;IAMR,OAAO,CAAC,kBAAkB,CAExB;IAEF,OAAO,CAAC,oBAAoB,CAQ1B;IAEF,OAAO,CAAC,gBAAgB,CAQtB;IAEF,OAAO,CAAC,iBAAiB,CA4CvB;CACH"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Deck, LayersList } from '@deck.gl/core/typed';
|
|
2
|
+
import type { Map } from 'mapbox-gl';
|
|
3
|
+
/** Insert Deck layers into the mapbox Map according to the user-defined order */
|
|
4
|
+
export declare function resolveLayers(map?: Map, deck?: Deck, oldLayers?: LayersList, newLayers?: LayersList): void;
|
|
5
|
+
//# sourceMappingURL=resolve-layers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-layers.d.ts","sourceRoot":"","sources":["../src/resolve-layers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,IAAI,EAAE,UAAU,EAAQ,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,WAAW,CAAC;AAInC,iFAAiF;AACjF,wBAAgB,aAAa,CAC3B,GAAG,CAAC,EAAE,GAAG,EACT,IAAI,CAAC,EAAE,IAAI,EACX,SAAS,CAAC,EAAE,UAAU,EACtB,SAAS,CAAC,EAAE,UAAU,QA2EvB"}
|