@deck.gl/mapbox 9.3.0-alpha.5 → 9.3.0-beta.1
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/deck-utils.d.ts +1 -2
- package/dist/deck-utils.d.ts.map +1 -1
- package/dist/deck-utils.js +16 -30
- package/dist/deck-utils.js.map +1 -1
- package/dist/dist.dev.js +124 -229
- package/dist/index.cjs +122 -226
- package/dist/index.cjs.map +4 -4
- package/dist/mapbox-overlay.d.ts +1 -6
- package/dist/mapbox-overlay.d.ts.map +1 -1
- package/dist/mapbox-overlay.js +23 -14
- package/dist/mapbox-overlay.js.map +1 -1
- package/dist/resolve-layer-groups.d.ts +3 -2
- package/dist/resolve-layer-groups.d.ts.map +1 -1
- package/dist/resolve-layer-groups.js +1 -1
- package/dist/resolve-layer-groups.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +3 -3
- package/src/deck-utils.ts +18 -42
- package/src/mapbox-overlay.ts +25 -20
- package/src/resolve-layer-groups.ts +1 -1
- package/dist/mapbox-layer.d.ts +0 -25
- package/dist/mapbox-layer.d.ts.map +0 -1
- package/dist/mapbox-layer.js +0 -35
- package/dist/mapbox-layer.js.map +0 -1
- package/dist/resolve-layers.d.ts +0 -5
- package/dist/resolve-layers.d.ts.map +0 -1
- package/dist/resolve-layers.js +0 -84
- package/dist/resolve-layers.js.map +0 -1
- package/src/mapbox-layer.ts +0 -61
- package/src/resolve-layers.ts +0 -104
package/dist/deck-utils.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Deck, MapView, _GlobeView as GlobeView } from '@deck.gl/core';
|
|
2
2
|
import type { MapViewState } from '@deck.gl/core';
|
|
3
3
|
import type { Parameters } from '@luma.gl/core';
|
|
4
|
-
import type MapboxLayer from "./mapbox-layer.js";
|
|
5
4
|
import type MapboxLayerGroup from "./mapbox-layer-group.js";
|
|
6
5
|
import type { Map } from "./types.js";
|
|
6
|
+
export declare const MAPBOX_VIEW_ID = "mapbox";
|
|
7
7
|
export declare function getDeckInstance({ map, deck }: {
|
|
8
8
|
map: Map & {
|
|
9
9
|
__deck?: Deck<any> | null;
|
|
@@ -14,7 +14,6 @@ export declare function removeDeckInstance(map: Map & {
|
|
|
14
14
|
__deck?: Deck | null;
|
|
15
15
|
}): void;
|
|
16
16
|
export declare function getDefaultParameters(map: Map, interleaved: boolean): Parameters;
|
|
17
|
-
export declare function drawLayer(deck: Deck, map: Map, layer: MapboxLayer<any>, renderParameters: any): void;
|
|
18
17
|
export declare function drawLayerGroup(deck: Deck, map: Map, group: MapboxLayerGroup, renderParameters: any): void;
|
|
19
18
|
export declare function getProjection(map: Map): 'mercator' | 'globe';
|
|
20
19
|
export declare function getDefaultView(map: Map): GlobeView | MapView;
|
package/dist/deck-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deck-utils.d.ts","sourceRoot":"","sources":["../src/deck-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,UAAU,IAAI,SAAS,EAAsB,MAAM,eAAe,CAAC;AAC1F,OAAO,KAAK,EAAW,YAAY,EAAQ,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"deck-utils.d.ts","sourceRoot":"","sources":["../src/deck-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,UAAU,IAAI,SAAS,EAAsB,MAAM,eAAe,CAAC;AAC1F,OAAO,KAAK,EAAW,YAAY,EAAQ,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,gBAAgB,gCAA6B;AACzD,OAAO,KAAK,EAAoB,GAAG,EAAC,mBAAgB;AAKpD,eAAO,MAAM,cAAc,WAAW,CAAC;AAWvC,wBAAgB,eAAe,CAAC,EAC9B,GAAG,EACH,IAAI,EACL,EAAE;IACD,GAAG,EAAE,GAAG,GAAG;QAAC,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;KAAC,CAAC;IACvC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;CACjB,GAAG,IAAI,CAAC,GAAG,CAAC,CAgDZ;AAeD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG;IAAC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAC,QAGnE;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,GAAG,UAAU,CAmB/E;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,gBAAgB,EACvB,gBAAgB,EAAE,GAAG,GACpB,IAAI,CAmCN;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,GAAG,OAAO,CAc5D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,GAAG,OAAO,CAK5D;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,YAAY,GAAG;IACrD,MAAM,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,CA6BA"}
|
package/dist/deck-utils.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { MapView, _GlobeView as GlobeView, _flatten as flatten } from '@deck.gl/core';
|
|
5
|
+
import { getLayerGroupId } from "./resolve-layer-groups.js";
|
|
5
6
|
import { lngLatToWorld, unitsPerMeter } from '@math.gl/web-mercator';
|
|
6
|
-
const MAPBOX_VIEW_ID = 'mapbox';
|
|
7
|
+
export const MAPBOX_VIEW_ID = 'mapbox';
|
|
7
8
|
// Mercator constants
|
|
8
9
|
const TILE_SIZE = 512;
|
|
9
10
|
const DEGREES_TO_RADIANS = Math.PI / 180;
|
|
@@ -23,7 +24,7 @@ export function getDeckInstance({ map, deck }) {
|
|
|
23
24
|
// customRender may be subscribed by DeckGL React component to update child props
|
|
24
25
|
// make sure it is still called
|
|
25
26
|
// Hack - do not pass a redraw reason here to prevent the React component from clearing the context
|
|
26
|
-
// Rerender will be triggered by
|
|
27
|
+
// Rerender will be triggered by MapboxLayerGroup's render()
|
|
27
28
|
customRender?.('');
|
|
28
29
|
}
|
|
29
30
|
};
|
|
@@ -90,30 +91,6 @@ export function getDefaultParameters(map, interleaved) {
|
|
|
90
91
|
}
|
|
91
92
|
return result;
|
|
92
93
|
}
|
|
93
|
-
export function drawLayer(deck, map, layer, renderParameters) {
|
|
94
|
-
if (!deck.isInitialized) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
let { currentViewport } = deck.userData;
|
|
98
|
-
let clearStack = false;
|
|
99
|
-
if (!currentViewport) {
|
|
100
|
-
// This is the first layer drawn in this render cycle.
|
|
101
|
-
// Generate viewport from the current map state.
|
|
102
|
-
currentViewport = getViewport(deck, map, renderParameters);
|
|
103
|
-
deck.userData.currentViewport = currentViewport;
|
|
104
|
-
clearStack = true;
|
|
105
|
-
}
|
|
106
|
-
if (!currentViewport) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
deck._drawLayers('mapbox-repaint', {
|
|
110
|
-
viewports: [currentViewport],
|
|
111
|
-
layerFilter: params => (!deck.props.layerFilter || deck.props.layerFilter(params)) &&
|
|
112
|
-
(layer.id === params.layer.id || params.layer.props.operation.includes('terrain')),
|
|
113
|
-
clearStack,
|
|
114
|
-
clearCanvas: false
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
94
|
export function drawLayerGroup(deck, map, group, renderParameters) {
|
|
118
95
|
if (!deck.isInitialized) {
|
|
119
96
|
return;
|
|
@@ -228,7 +205,7 @@ function getViewport(deck, map, renderParameters) {
|
|
|
228
205
|
// View is always MapView or GlobeView in this context
|
|
229
206
|
const view = (deck.getView(MAPBOX_VIEW_ID) || getDefaultView(map));
|
|
230
207
|
if (renderParameters) {
|
|
231
|
-
// Called from
|
|
208
|
+
// Called from MapboxLayerGroup.render
|
|
232
209
|
// Magic number, matches mapbox-gl@>=1.3.0's projection matrix
|
|
233
210
|
view.props.nearZMultiplier = 0.2;
|
|
234
211
|
}
|
|
@@ -249,9 +226,9 @@ function getViewport(deck, map, renderParameters) {
|
|
|
249
226
|
});
|
|
250
227
|
}
|
|
251
228
|
function afterRender(deck, map) {
|
|
252
|
-
// Draw non-Mapbox layers (layers that don't have a corresponding
|
|
229
|
+
// Draw non-Mapbox layers (layers that don't have a corresponding MapboxLayerGroup on the map)
|
|
253
230
|
const deckLayers = flatten(deck.props.layers, Boolean);
|
|
254
|
-
const hasNonMapboxLayers = deckLayers.some(layer => layer && !map.getLayer(layer
|
|
231
|
+
const hasNonMapboxLayers = deckLayers.some(layer => layer && !map.getLayer(getLayerGroupId(layer)));
|
|
255
232
|
let viewports = deck.getViewports();
|
|
256
233
|
const mapboxViewportIdx = viewports.findIndex(vp => vp.id === MAPBOX_VIEW_ID);
|
|
257
234
|
const hasNonMapboxViews = viewports.length > 1 || mapboxViewportIdx < 0;
|
|
@@ -269,10 +246,19 @@ function afterRender(deck, map) {
|
|
|
269
246
|
deck._drawLayers('mapbox-repaint', {
|
|
270
247
|
viewports,
|
|
271
248
|
layerFilter: params => (!deck.props.layerFilter || deck.props.layerFilter(params)) &&
|
|
272
|
-
(params.viewport.id !== MAPBOX_VIEW_ID ||
|
|
249
|
+
(params.viewport.id !== MAPBOX_VIEW_ID ||
|
|
250
|
+
!map.getLayer(getLayerGroupId(params.layer))),
|
|
273
251
|
clearCanvas: false
|
|
274
252
|
});
|
|
275
253
|
}
|
|
254
|
+
else {
|
|
255
|
+
// Even when there are no non-Mapbox layers to draw, fire lifecycle callbacks
|
|
256
|
+
// so that consumers can still track view state changes via onAfterRender
|
|
257
|
+
const device = deck.device;
|
|
258
|
+
const gl = device?.gl;
|
|
259
|
+
deck.props.onBeforeRender?.({ device, gl });
|
|
260
|
+
deck.props.onAfterRender?.({ device, gl });
|
|
261
|
+
}
|
|
276
262
|
// End of render cycle, clear generated viewport
|
|
277
263
|
deck.userData.currentViewport = null;
|
|
278
264
|
}
|
package/dist/deck-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deck-utils.js","sourceRoot":"","sources":["../src/deck-utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAO,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,QAAQ,IAAI,OAAO,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"deck-utils.js","sourceRoot":"","sources":["../src/deck-utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAO,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,QAAQ,IAAI,OAAO,EAAC,MAAM,eAAe,CAAC;AAK1F,OAAO,EAAC,eAAe,EAAC,kCAA+B;AAEvD,OAAO,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAMvC,qBAAqB;AACrB,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAEzC,uCAAuC;AACvC,MAAM,UAAU,eAAe,CAAC,EAC9B,GAAG,EACH,IAAI,EAIL;IACC,4CAA4C;IAC5C,IAAI,GAAG,CAAC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__ = (() => {
|
|
|
63
63
|
__reExport(bundle_exports, peer_dependency_exports);
|
|
64
64
|
|
|
65
65
|
// src/mapbox-overlay.ts
|
|
66
|
-
var
|
|
66
|
+
var import_core5 = __toESM(require_core(), 1);
|
|
67
67
|
|
|
68
68
|
// src/deck-utils.ts
|
|
69
|
+
var import_core4 = __toESM(require_core(), 1);
|
|
70
|
+
|
|
71
|
+
// src/resolve-layer-groups.ts
|
|
72
|
+
var import_core3 = __toESM(require_core(), 1);
|
|
73
|
+
|
|
74
|
+
// src/mapbox-layer-group.ts
|
|
69
75
|
var import_core2 = __toESM(require_core(), 1);
|
|
76
|
+
var MapboxLayerGroup = class {
|
|
77
|
+
/* eslint-disable no-this-before-super */
|
|
78
|
+
constructor(props) {
|
|
79
|
+
(0, import_core2.assert)(props.id, "id is required");
|
|
80
|
+
this.id = props.id;
|
|
81
|
+
this.type = "custom";
|
|
82
|
+
this.renderingMode = props.renderingMode || "3d";
|
|
83
|
+
this.slot = props.slot;
|
|
84
|
+
this.beforeId = props.beforeId;
|
|
85
|
+
this.map = null;
|
|
86
|
+
}
|
|
87
|
+
/* Mapbox custom layer methods */
|
|
88
|
+
onAdd(map, gl) {
|
|
89
|
+
this.map = map;
|
|
90
|
+
}
|
|
91
|
+
render(gl, renderParameters) {
|
|
92
|
+
if (!this.map)
|
|
93
|
+
return;
|
|
94
|
+
drawLayerGroup(this.map.__deck, this.map, this, renderParameters);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// src/resolve-layer-groups.ts
|
|
99
|
+
var UNDEFINED_BEFORE_ID = "__UNDEFINED__";
|
|
100
|
+
function getLayerGroupId(layer) {
|
|
101
|
+
if (layer.props.beforeId) {
|
|
102
|
+
return `deck-layer-group-before:${layer.props.beforeId}`;
|
|
103
|
+
} else if (layer.props.slot) {
|
|
104
|
+
return `deck-layer-group-slot:${layer.props.slot}`;
|
|
105
|
+
}
|
|
106
|
+
return "deck-layer-group-last";
|
|
107
|
+
}
|
|
108
|
+
function resolveLayerGroups(map, oldLayers, newLayers) {
|
|
109
|
+
if (!map || !map.style || !map.style._loaded) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const layers = (0, import_core3._flatten)(newLayers, Boolean);
|
|
113
|
+
if (oldLayers !== newLayers) {
|
|
114
|
+
const prevLayers = (0, import_core3._flatten)(oldLayers, Boolean);
|
|
115
|
+
const prevLayerGroupIds = new Set(prevLayers.map((l) => getLayerGroupId(l)));
|
|
116
|
+
const newLayerGroupIds = new Set(layers.map((l) => getLayerGroupId(l)));
|
|
117
|
+
for (const groupId of prevLayerGroupIds) {
|
|
118
|
+
if (!newLayerGroupIds.has(groupId)) {
|
|
119
|
+
if (map.getLayer(groupId)) {
|
|
120
|
+
map.removeLayer(groupId);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const layerGroups = {};
|
|
126
|
+
for (const layer of layers) {
|
|
127
|
+
const groupId = getLayerGroupId(layer);
|
|
128
|
+
const mapboxGroup = map.getLayer(groupId);
|
|
129
|
+
if (mapboxGroup) {
|
|
130
|
+
const groupInstance = mapboxGroup.implementation || mapboxGroup;
|
|
131
|
+
layerGroups[groupId] = groupInstance;
|
|
132
|
+
} else {
|
|
133
|
+
const newGroup = new MapboxLayerGroup({
|
|
134
|
+
id: groupId,
|
|
135
|
+
slot: layer.props.slot,
|
|
136
|
+
beforeId: layer.props.beforeId
|
|
137
|
+
});
|
|
138
|
+
layerGroups[groupId] = newGroup;
|
|
139
|
+
map.addLayer(newGroup, layer.props.beforeId);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const mapLayers = map.style._order;
|
|
143
|
+
for (const [groupId, group] of Object.entries(layerGroups)) {
|
|
144
|
+
const beforeId = group.beforeId || UNDEFINED_BEFORE_ID;
|
|
145
|
+
const expectedGroupIndex = beforeId === UNDEFINED_BEFORE_ID ? mapLayers.length : mapLayers.indexOf(beforeId);
|
|
146
|
+
const currentGropupIndex = mapLayers.indexOf(groupId);
|
|
147
|
+
if (currentGropupIndex !== expectedGroupIndex - 1) {
|
|
148
|
+
const moveBeforeId = beforeId === UNDEFINED_BEFORE_ID ? void 0 : beforeId;
|
|
149
|
+
map.moveLayer(groupId, moveBeforeId);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
70
153
|
|
|
71
154
|
// ../../node_modules/@math.gl/web-mercator/dist/assert.js
|
|
72
|
-
function
|
|
155
|
+
function assert2(condition, message) {
|
|
73
156
|
if (!condition) {
|
|
74
157
|
throw new Error(message || "@math.gl/web-mercator: assertion failed.");
|
|
75
158
|
}
|
|
@@ -84,8 +167,8 @@ var __exports__ = (() => {
|
|
|
84
167
|
var EARTH_CIRCUMFERENCE = 4003e4;
|
|
85
168
|
function lngLatToWorld(lngLat) {
|
|
86
169
|
const [lng, lat] = lngLat;
|
|
87
|
-
|
|
88
|
-
|
|
170
|
+
assert2(Number.isFinite(lng));
|
|
171
|
+
assert2(Number.isFinite(lat) && lat >= -90 && lat <= 90, "invalid latitude");
|
|
89
172
|
const lambda2 = lng * DEGREES_TO_RADIANS;
|
|
90
173
|
const phi2 = lat * DEGREES_TO_RADIANS;
|
|
91
174
|
const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
|
|
@@ -175,27 +258,6 @@ var __exports__ = (() => {
|
|
|
175
258
|
}
|
|
176
259
|
return result;
|
|
177
260
|
}
|
|
178
|
-
function drawLayer(deck, map, layer, renderParameters) {
|
|
179
|
-
if (!deck.isInitialized) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
let { currentViewport } = deck.userData;
|
|
183
|
-
let clearStack = false;
|
|
184
|
-
if (!currentViewport) {
|
|
185
|
-
currentViewport = getViewport(deck, map, renderParameters);
|
|
186
|
-
deck.userData.currentViewport = currentViewport;
|
|
187
|
-
clearStack = true;
|
|
188
|
-
}
|
|
189
|
-
if (!currentViewport) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
deck._drawLayers("mapbox-repaint", {
|
|
193
|
-
viewports: [currentViewport],
|
|
194
|
-
layerFilter: (params) => (!deck.props.layerFilter || deck.props.layerFilter(params)) && (layer.id === params.layer.id || params.layer.props.operation.includes("terrain")),
|
|
195
|
-
clearStack,
|
|
196
|
-
clearCanvas: false
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
261
|
function drawLayerGroup(deck, map, group, renderParameters) {
|
|
200
262
|
if (!deck.isInitialized) {
|
|
201
263
|
return;
|
|
@@ -243,9 +305,9 @@ var __exports__ = (() => {
|
|
|
243
305
|
}
|
|
244
306
|
function getDefaultView(map) {
|
|
245
307
|
if (getProjection(map) === "globe") {
|
|
246
|
-
return new
|
|
308
|
+
return new import_core4._GlobeView({ id: MAPBOX_VIEW_ID });
|
|
247
309
|
}
|
|
248
|
-
return new
|
|
310
|
+
return new import_core4.MapView({ id: MAPBOX_VIEW_ID });
|
|
249
311
|
}
|
|
250
312
|
function getViewState(map) {
|
|
251
313
|
const { lng, lat } = map.getCenter();
|
|
@@ -313,8 +375,10 @@ var __exports__ = (() => {
|
|
|
313
375
|
});
|
|
314
376
|
}
|
|
315
377
|
function afterRender(deck, map) {
|
|
316
|
-
const deckLayers = (0,
|
|
317
|
-
const hasNonMapboxLayers = deckLayers.some(
|
|
378
|
+
const deckLayers = (0, import_core4._flatten)(deck.props.layers, Boolean);
|
|
379
|
+
const hasNonMapboxLayers = deckLayers.some(
|
|
380
|
+
(layer) => layer && !map.getLayer(getLayerGroupId(layer))
|
|
381
|
+
);
|
|
318
382
|
let viewports = deck.getViewports();
|
|
319
383
|
const mapboxViewportIdx = viewports.findIndex((vp) => vp.id === MAPBOX_VIEW_ID);
|
|
320
384
|
const hasNonMapboxViews = viewports.length > 1 || mapboxViewportIdx < 0;
|
|
@@ -330,9 +394,14 @@ var __exports__ = (() => {
|
|
|
330
394
|
}
|
|
331
395
|
deck._drawLayers("mapbox-repaint", {
|
|
332
396
|
viewports,
|
|
333
|
-
layerFilter: (params) => (!deck.props.layerFilter || deck.props.layerFilter(params)) && (params.viewport.id !== MAPBOX_VIEW_ID || !map.getLayer(params.layer
|
|
397
|
+
layerFilter: (params) => (!deck.props.layerFilter || deck.props.layerFilter(params)) && (params.viewport.id !== MAPBOX_VIEW_ID || !map.getLayer(getLayerGroupId(params.layer))),
|
|
334
398
|
clearCanvas: false
|
|
335
399
|
});
|
|
400
|
+
} else {
|
|
401
|
+
const device = deck.device;
|
|
402
|
+
const gl = device?.gl;
|
|
403
|
+
deck.props.onBeforeRender?.({ device, gl });
|
|
404
|
+
deck.props.onAfterRender?.({ device, gl });
|
|
336
405
|
}
|
|
337
406
|
deck.userData.currentViewport = null;
|
|
338
407
|
}
|
|
@@ -343,188 +412,6 @@ var __exports__ = (() => {
|
|
|
343
412
|
deck.needsRedraw({ clearRedrawFlags: true });
|
|
344
413
|
}
|
|
345
414
|
|
|
346
|
-
// src/resolve-layers.ts
|
|
347
|
-
var import_core3 = __toESM(require_core(), 1);
|
|
348
|
-
|
|
349
|
-
// src/mapbox-layer.ts
|
|
350
|
-
var MapboxLayer = class {
|
|
351
|
-
/* eslint-disable no-this-before-super */
|
|
352
|
-
constructor(props) {
|
|
353
|
-
if (!props.id) {
|
|
354
|
-
throw new Error("Layer must have an unique id");
|
|
355
|
-
}
|
|
356
|
-
this.id = props.id;
|
|
357
|
-
this.type = "custom";
|
|
358
|
-
this.renderingMode = props.renderingMode || "3d";
|
|
359
|
-
this.slot = props.slot;
|
|
360
|
-
this.map = null;
|
|
361
|
-
this.props = props;
|
|
362
|
-
}
|
|
363
|
-
/* Mapbox custom layer methods */
|
|
364
|
-
onAdd(map, gl) {
|
|
365
|
-
this.map = map;
|
|
366
|
-
}
|
|
367
|
-
onRemove() {
|
|
368
|
-
this.map = null;
|
|
369
|
-
}
|
|
370
|
-
setProps(props) {
|
|
371
|
-
Object.assign(this.props, props, { id: this.id });
|
|
372
|
-
}
|
|
373
|
-
render(gl, renderParameters) {
|
|
374
|
-
if (!this.map)
|
|
375
|
-
return;
|
|
376
|
-
drawLayer(this.map.__deck, this.map, this, renderParameters);
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
// src/resolve-layers.ts
|
|
381
|
-
var UNDEFINED_BEFORE_ID = "__UNDEFINED__";
|
|
382
|
-
function resolveLayers(map, deck, oldLayers, newLayers) {
|
|
383
|
-
if (!map || !deck || !map.style || !map.style._loaded) {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
const layers = (0, import_core3._flatten)(newLayers, Boolean);
|
|
387
|
-
if (oldLayers !== newLayers) {
|
|
388
|
-
const prevLayers = (0, import_core3._flatten)(oldLayers, Boolean);
|
|
389
|
-
const prevLayerIds = new Set(prevLayers.map((l) => l.id));
|
|
390
|
-
for (const layer of layers) {
|
|
391
|
-
prevLayerIds.delete(layer.id);
|
|
392
|
-
}
|
|
393
|
-
for (const id of prevLayerIds) {
|
|
394
|
-
if (map.getLayer(id)) {
|
|
395
|
-
map.removeLayer(id);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
for (const layer of layers) {
|
|
400
|
-
const mapboxLayer = map.getLayer(layer.id);
|
|
401
|
-
if (mapboxLayer) {
|
|
402
|
-
const layerInstance = mapboxLayer.implementation || mapboxLayer;
|
|
403
|
-
layerInstance.setProps(layer.props);
|
|
404
|
-
} else {
|
|
405
|
-
map.addLayer(
|
|
406
|
-
new MapboxLayer({
|
|
407
|
-
id: layer.id,
|
|
408
|
-
// @ts-expect-error slot is not defined in LayerProps
|
|
409
|
-
slot: layer.props.slot
|
|
410
|
-
}),
|
|
411
|
-
// @ts-expect-error beforeId is not defined in LayerProps
|
|
412
|
-
layer.props.beforeId
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
const mapLayers = map.style._order;
|
|
417
|
-
const layerGroups = {};
|
|
418
|
-
for (const layer of layers) {
|
|
419
|
-
let { beforeId } = layer.props;
|
|
420
|
-
if (!beforeId || !mapLayers.includes(beforeId)) {
|
|
421
|
-
beforeId = UNDEFINED_BEFORE_ID;
|
|
422
|
-
}
|
|
423
|
-
layerGroups[beforeId] = layerGroups[beforeId] || [];
|
|
424
|
-
layerGroups[beforeId].push(layer.id);
|
|
425
|
-
}
|
|
426
|
-
for (const beforeId in layerGroups) {
|
|
427
|
-
const layerGroup = layerGroups[beforeId];
|
|
428
|
-
let lastLayerIndex = beforeId === UNDEFINED_BEFORE_ID ? mapLayers.length : mapLayers.indexOf(beforeId);
|
|
429
|
-
let lastLayerId = beforeId === UNDEFINED_BEFORE_ID ? void 0 : beforeId;
|
|
430
|
-
for (let i = layerGroup.length - 1; i >= 0; i--) {
|
|
431
|
-
const layerId = layerGroup[i];
|
|
432
|
-
const layerIndex = mapLayers.indexOf(layerId);
|
|
433
|
-
if (layerIndex !== lastLayerIndex - 1) {
|
|
434
|
-
map.moveLayer(layerId, lastLayerId);
|
|
435
|
-
if (layerIndex > lastLayerIndex) {
|
|
436
|
-
lastLayerIndex++;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
lastLayerIndex--;
|
|
440
|
-
lastLayerId = layerId;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
// src/resolve-layer-groups.ts
|
|
446
|
-
var import_core5 = __toESM(require_core(), 1);
|
|
447
|
-
|
|
448
|
-
// src/mapbox-layer-group.ts
|
|
449
|
-
var import_core4 = __toESM(require_core(), 1);
|
|
450
|
-
var MapboxLayerGroup = class {
|
|
451
|
-
/* eslint-disable no-this-before-super */
|
|
452
|
-
constructor(props) {
|
|
453
|
-
(0, import_core4.assert)(props.id, "id is required");
|
|
454
|
-
this.id = props.id;
|
|
455
|
-
this.type = "custom";
|
|
456
|
-
this.renderingMode = props.renderingMode || "3d";
|
|
457
|
-
this.slot = props.slot;
|
|
458
|
-
this.beforeId = props.beforeId;
|
|
459
|
-
this.map = null;
|
|
460
|
-
}
|
|
461
|
-
/* Mapbox custom layer methods */
|
|
462
|
-
onAdd(map, gl) {
|
|
463
|
-
this.map = map;
|
|
464
|
-
}
|
|
465
|
-
render(gl, renderParameters) {
|
|
466
|
-
if (!this.map)
|
|
467
|
-
return;
|
|
468
|
-
drawLayerGroup(this.map.__deck, this.map, this, renderParameters);
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
// src/resolve-layer-groups.ts
|
|
473
|
-
var UNDEFINED_BEFORE_ID2 = "__UNDEFINED__";
|
|
474
|
-
function getLayerGroupId(layer) {
|
|
475
|
-
if (layer.props.beforeId) {
|
|
476
|
-
return `deck-layer-group-before:${layer.props.beforeId}`;
|
|
477
|
-
} else if (layer.props.slot) {
|
|
478
|
-
return `deck-layer-group-slot:${layer.props.slot}`;
|
|
479
|
-
}
|
|
480
|
-
return "deck-layer-group-last";
|
|
481
|
-
}
|
|
482
|
-
function resolveLayerGroups(map, oldLayers, newLayers) {
|
|
483
|
-
if (!map || !map.style || !map.style._loaded) {
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
const layers = (0, import_core5._flatten)(newLayers, Boolean);
|
|
487
|
-
if (oldLayers !== newLayers) {
|
|
488
|
-
const prevLayers = (0, import_core5._flatten)(oldLayers, Boolean);
|
|
489
|
-
const prevLayerGroupIds = new Set(prevLayers.map((l) => getLayerGroupId(l)));
|
|
490
|
-
const newLayerGroupIds = new Set(layers.map((l) => getLayerGroupId(l)));
|
|
491
|
-
for (const groupId of prevLayerGroupIds) {
|
|
492
|
-
if (!newLayerGroupIds.has(groupId)) {
|
|
493
|
-
if (map.getLayer(groupId)) {
|
|
494
|
-
map.removeLayer(groupId);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
const layerGroups = {};
|
|
500
|
-
for (const layer of layers) {
|
|
501
|
-
const groupId = getLayerGroupId(layer);
|
|
502
|
-
const mapboxGroup = map.getLayer(groupId);
|
|
503
|
-
if (mapboxGroup) {
|
|
504
|
-
const groupInstance = mapboxGroup.implementation || mapboxGroup;
|
|
505
|
-
layerGroups[groupId] = groupInstance;
|
|
506
|
-
} else {
|
|
507
|
-
const newGroup = new MapboxLayerGroup({
|
|
508
|
-
id: groupId,
|
|
509
|
-
slot: layer.props.slot,
|
|
510
|
-
beforeId: layer.props.beforeId
|
|
511
|
-
});
|
|
512
|
-
layerGroups[groupId] = newGroup;
|
|
513
|
-
map.addLayer(newGroup, layer.props.beforeId);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
const mapLayers = map.style._order;
|
|
517
|
-
for (const [groupId, group] of Object.entries(layerGroups)) {
|
|
518
|
-
const beforeId = group.beforeId || UNDEFINED_BEFORE_ID2;
|
|
519
|
-
const expectedGroupIndex = beforeId === UNDEFINED_BEFORE_ID2 ? mapLayers.length : mapLayers.indexOf(beforeId);
|
|
520
|
-
const currentGropupIndex = mapLayers.indexOf(groupId);
|
|
521
|
-
if (currentGropupIndex !== expectedGroupIndex - 1) {
|
|
522
|
-
const moveBeforeId = beforeId === UNDEFINED_BEFORE_ID2 ? void 0 : beforeId;
|
|
523
|
-
map.moveLayer(groupId, moveBeforeId);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
415
|
// src/mapbox-overlay.ts
|
|
529
416
|
var MapboxOverlay = class {
|
|
530
417
|
constructor(props) {
|
|
@@ -533,8 +420,8 @@ var __exports__ = (() => {
|
|
|
533
420
|
if (!this._map)
|
|
534
421
|
return;
|
|
535
422
|
const projection = getProjection(this._map);
|
|
536
|
-
if (projection
|
|
537
|
-
this._deck?.setProps({ views:
|
|
423
|
+
if (projection) {
|
|
424
|
+
this._deck?.setProps({ views: this._getViews(this._map) });
|
|
538
425
|
}
|
|
539
426
|
};
|
|
540
427
|
this._updateContainerSize = () => {
|
|
@@ -551,7 +438,7 @@ var __exports__ = (() => {
|
|
|
551
438
|
const map = this._map;
|
|
552
439
|
if (deck && map) {
|
|
553
440
|
deck.setProps({
|
|
554
|
-
views: this.
|
|
441
|
+
views: this._getViews(map),
|
|
555
442
|
viewState: getViewState(map)
|
|
556
443
|
});
|
|
557
444
|
if (deck.isInitialized) {
|
|
@@ -623,7 +510,6 @@ var __exports__ = (() => {
|
|
|
623
510
|
};
|
|
624
511
|
const { interleaved = false } = props;
|
|
625
512
|
this._interleaved = interleaved;
|
|
626
|
-
this._renderLayersInGroups = props._renderLayersInGroups || false;
|
|
627
513
|
this._props = this.filterProps(props);
|
|
628
514
|
}
|
|
629
515
|
/** Filter out props to pass to Deck **/
|
|
@@ -643,6 +529,7 @@ var __exports__ = (() => {
|
|
|
643
529
|
if (this._deck && this._map) {
|
|
644
530
|
this._deck.setProps({
|
|
645
531
|
...this._props,
|
|
532
|
+
views: this._getViews(this._map),
|
|
646
533
|
parameters: {
|
|
647
534
|
...getDefaultParameters(this._map, this._interleaved),
|
|
648
535
|
...this._props.parameters
|
|
@@ -667,11 +554,11 @@ var __exports__ = (() => {
|
|
|
667
554
|
pointerEvents: "none"
|
|
668
555
|
});
|
|
669
556
|
this._container = container;
|
|
670
|
-
this._deck = new
|
|
557
|
+
this._deck = new import_core5.Deck({
|
|
671
558
|
...this._props,
|
|
672
559
|
parent: container,
|
|
673
560
|
parameters: { ...getDefaultParameters(map, false), ...this._props.parameters },
|
|
674
|
-
views: this.
|
|
561
|
+
views: this._getViews(map),
|
|
675
562
|
viewState: getViewState(map)
|
|
676
563
|
});
|
|
677
564
|
map.on("resize", this._updateContainerSize);
|
|
@@ -690,14 +577,15 @@ var __exports__ = (() => {
|
|
|
690
577
|
_onAddInterleaved(map) {
|
|
691
578
|
const gl = map.painter.context.gl;
|
|
692
579
|
if (gl instanceof WebGLRenderingContext) {
|
|
693
|
-
|
|
580
|
+
import_core5.log.warn(
|
|
694
581
|
"Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility"
|
|
695
582
|
)();
|
|
696
583
|
}
|
|
697
584
|
this._deck = getDeckInstance({
|
|
698
585
|
map,
|
|
699
|
-
deck: new
|
|
586
|
+
deck: new import_core5.Deck({
|
|
700
587
|
...this._props,
|
|
588
|
+
views: this._getViews(map),
|
|
701
589
|
gl,
|
|
702
590
|
parameters: { ...getDefaultParameters(map, true), ...this._props.parameters }
|
|
703
591
|
})
|
|
@@ -706,12 +594,8 @@ var __exports__ = (() => {
|
|
|
706
594
|
this._resolveLayers(map, this._deck, [], this._props.layers);
|
|
707
595
|
return document.createElement("div");
|
|
708
596
|
}
|
|
709
|
-
_resolveLayers(map,
|
|
710
|
-
|
|
711
|
-
resolveLayerGroups(map, prevLayers, newLayers);
|
|
712
|
-
} else {
|
|
713
|
-
resolveLayers(map, deck, prevLayers, newLayers);
|
|
714
|
-
}
|
|
597
|
+
_resolveLayers(map, _deck, prevLayers, newLayers) {
|
|
598
|
+
resolveLayerGroups(map, prevLayers, newLayers);
|
|
715
599
|
}
|
|
716
600
|
/** Called when the control is removed from a map */
|
|
717
601
|
onRemove() {
|
|
@@ -750,17 +634,17 @@ var __exports__ = (() => {
|
|
|
750
634
|
}
|
|
751
635
|
/** Forwards the Deck.pickObject method */
|
|
752
636
|
pickObject(params) {
|
|
753
|
-
(0,
|
|
637
|
+
(0, import_core5.assert)(this._deck);
|
|
754
638
|
return this._deck.pickObject(params);
|
|
755
639
|
}
|
|
756
640
|
/** Forwards the Deck.pickMultipleObjects method */
|
|
757
641
|
pickMultipleObjects(params) {
|
|
758
|
-
(0,
|
|
642
|
+
(0, import_core5.assert)(this._deck);
|
|
759
643
|
return this._deck.pickMultipleObjects(params);
|
|
760
644
|
}
|
|
761
645
|
/** Forwards the Deck.pickObjects method */
|
|
762
646
|
pickObjects(params) {
|
|
763
|
-
(0,
|
|
647
|
+
(0, import_core5.assert)(this._deck);
|
|
764
648
|
return this._deck.pickObjects(params);
|
|
765
649
|
}
|
|
766
650
|
/** Remove from map and releases all resources */
|
|
@@ -776,6 +660,17 @@ var __exports__ = (() => {
|
|
|
776
660
|
}
|
|
777
661
|
return this._interleaved ? this._map.getCanvas() : this._deck.getCanvas();
|
|
778
662
|
}
|
|
663
|
+
_getViews(map) {
|
|
664
|
+
if (!this._props.views) {
|
|
665
|
+
return getDefaultView(map);
|
|
666
|
+
}
|
|
667
|
+
const views = Array.isArray(this._props.views) ? this._props.views : [this._props.views];
|
|
668
|
+
const hasMapboxView = views.some((v) => v.id === MAPBOX_VIEW_ID);
|
|
669
|
+
if (hasMapboxView) {
|
|
670
|
+
return this._props.views;
|
|
671
|
+
}
|
|
672
|
+
return [getDefaultView(map), ...views];
|
|
673
|
+
}
|
|
779
674
|
};
|
|
780
675
|
return __toCommonJS(bundle_exports);
|
|
781
676
|
})();
|