@deck.gl/mapbox 8.9.0-alpha.2 → 8.9.0-alpha.4
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 +45 -45
- package/package.json +2 -2
- package/typed/deck-utils.js +0 -185
- package/typed/index.js +0 -2
- package/typed/mapbox-layer.js +0 -37
- package/typed/mapbox-overlay.js +0 -139
package/dist/dist.dev.js
CHANGED
|
@@ -97,9 +97,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
97
97
|
/******/ ({
|
|
98
98
|
|
|
99
99
|
/***/ "../../node_modules/@math.gl/web-mercator/dist/esm/assert.js":
|
|
100
|
-
|
|
101
|
-
!*** /Users/
|
|
102
|
-
|
|
100
|
+
/*!****************************************************************************************!*\
|
|
101
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/dist/esm/assert.js ***!
|
|
102
|
+
\****************************************************************************************/
|
|
103
103
|
/*! exports provided: default */
|
|
104
104
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
105
105
|
|
|
@@ -116,9 +116,9 @@ function assert(condition, message) {
|
|
|
116
116
|
/***/ }),
|
|
117
117
|
|
|
118
118
|
/***/ "../../node_modules/@math.gl/web-mercator/dist/esm/fit-bounds.js":
|
|
119
|
-
|
|
120
|
-
!*** /Users/
|
|
121
|
-
|
|
119
|
+
/*!********************************************************************************************!*\
|
|
120
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/dist/esm/fit-bounds.js ***!
|
|
121
|
+
\********************************************************************************************/
|
|
122
122
|
/*! exports provided: default */
|
|
123
123
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
124
124
|
|
|
@@ -180,9 +180,9 @@ function getPaddingObject(padding = 0) {
|
|
|
180
180
|
/***/ }),
|
|
181
181
|
|
|
182
182
|
/***/ "../../node_modules/@math.gl/web-mercator/dist/esm/fly-to-viewport.js":
|
|
183
|
-
|
|
184
|
-
!*** /Users/
|
|
185
|
-
|
|
183
|
+
/*!*************************************************************************************************!*\
|
|
184
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/dist/esm/fly-to-viewport.js ***!
|
|
185
|
+
\*************************************************************************************************/
|
|
186
186
|
/*! exports provided: default, getFlyToDuration */
|
|
187
187
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
188
188
|
|
|
@@ -308,9 +308,9 @@ function getFlyToTransitionParams(startProps, endProps, opts) {
|
|
|
308
308
|
/***/ }),
|
|
309
309
|
|
|
310
310
|
/***/ "../../node_modules/@math.gl/web-mercator/dist/esm/get-bounds.js":
|
|
311
|
-
|
|
312
|
-
!*** /Users/
|
|
313
|
-
|
|
311
|
+
/*!********************************************************************************************!*\
|
|
312
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/dist/esm/get-bounds.js ***!
|
|
313
|
+
\********************************************************************************************/
|
|
314
314
|
/*! exports provided: default */
|
|
315
315
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
316
316
|
|
|
@@ -369,9 +369,9 @@ function unprojectOnFarPlane(viewport, x, targetZ) {
|
|
|
369
369
|
/***/ }),
|
|
370
370
|
|
|
371
371
|
/***/ "../../node_modules/@math.gl/web-mercator/dist/esm/index.js":
|
|
372
|
-
|
|
373
|
-
!*** /Users/
|
|
374
|
-
|
|
372
|
+
/*!***************************************************************************************!*\
|
|
373
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/dist/esm/index.js ***!
|
|
374
|
+
\***************************************************************************************/
|
|
375
375
|
/*! exports provided: default, WebMercatorViewport, getBounds, fitBounds, normalizeViewportProps, flyToViewport, getFlyToDuration, MAX_LATITUDE, lngLatToWorld, worldToLngLat, worldToPixels, pixelsToWorld, zoomToScale, scaleToZoom, altitudeToFovy, fovyToAltitude, getMeterZoom, unitsPerMeter, getDistanceScales, addMetersToLngLat, getViewMatrix, getProjectionMatrix, getProjectionParameters */
|
|
376
376
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
377
377
|
|
|
@@ -441,9 +441,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
441
441
|
/***/ }),
|
|
442
442
|
|
|
443
443
|
/***/ "../../node_modules/@math.gl/web-mercator/dist/esm/math-utils.js":
|
|
444
|
-
|
|
445
|
-
!*** /Users/
|
|
446
|
-
|
|
444
|
+
/*!********************************************************************************************!*\
|
|
445
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/dist/esm/math-utils.js ***!
|
|
446
|
+
\********************************************************************************************/
|
|
447
447
|
/*! exports provided: createMat4, transformVector, mod, lerp, clamp, log2 */
|
|
448
448
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
449
449
|
|
|
@@ -486,9 +486,9 @@ const log2 = Math.log2 || ieLog2;
|
|
|
486
486
|
/***/ }),
|
|
487
487
|
|
|
488
488
|
/***/ "../../node_modules/@math.gl/web-mercator/dist/esm/normalize-viewport-props.js":
|
|
489
|
-
|
|
490
|
-
!*** /Users/
|
|
491
|
-
|
|
489
|
+
/*!**********************************************************************************************************!*\
|
|
490
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/dist/esm/normalize-viewport-props.js ***!
|
|
491
|
+
\**********************************************************************************************************/
|
|
492
492
|
/*! exports provided: default */
|
|
493
493
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
494
494
|
|
|
@@ -556,9 +556,9 @@ function normalizeViewportProps(props) {
|
|
|
556
556
|
/***/ }),
|
|
557
557
|
|
|
558
558
|
/***/ "../../node_modules/@math.gl/web-mercator/dist/esm/web-mercator-utils.js":
|
|
559
|
-
|
|
560
|
-
!*** /Users/
|
|
561
|
-
|
|
559
|
+
/*!****************************************************************************************************!*\
|
|
560
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/dist/esm/web-mercator-utils.js ***!
|
|
561
|
+
\****************************************************************************************************/
|
|
562
562
|
/*! exports provided: MAX_LATITUDE, DEFAULT_ALTITUDE, zoomToScale, scaleToZoom, lngLatToWorld, worldToLngLat, getMeterZoom, unitsPerMeter, getDistanceScales, addMetersToLngLat, getViewMatrix, getProjectionParameters, getProjectionMatrix, altitudeToFovy, fovyToAltitude, worldToPixels, pixelsToWorld */
|
|
563
563
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
564
564
|
|
|
@@ -787,9 +787,9 @@ function pixelsToWorld(xyz, pixelUnprojectionMatrix, targetZ = 0) {
|
|
|
787
787
|
/***/ }),
|
|
788
788
|
|
|
789
789
|
/***/ "../../node_modules/@math.gl/web-mercator/dist/esm/web-mercator-viewport.js":
|
|
790
|
-
|
|
791
|
-
!*** /Users/
|
|
792
|
-
|
|
790
|
+
/*!*******************************************************************************************************!*\
|
|
791
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/dist/esm/web-mercator-viewport.js ***!
|
|
792
|
+
\*******************************************************************************************************/
|
|
793
793
|
/*! exports provided: default */
|
|
794
794
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
795
795
|
|
|
@@ -1076,9 +1076,9 @@ class WebMercatorViewport {
|
|
|
1076
1076
|
/***/ }),
|
|
1077
1077
|
|
|
1078
1078
|
/***/ "../../node_modules/@math.gl/web-mercator/node_modules/@babel/runtime/helpers/esm/defineProperty.js":
|
|
1079
|
-
|
|
1080
|
-
!*** /Users/
|
|
1081
|
-
|
|
1079
|
+
/*!*******************************************************************************************************************************!*\
|
|
1080
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/@math.gl/web-mercator/node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
|
|
1081
|
+
\*******************************************************************************************************************************/
|
|
1082
1082
|
/*! exports provided: default */
|
|
1083
1083
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1084
1084
|
|
|
@@ -1103,9 +1103,9 @@ function _defineProperty(obj, key, value) {
|
|
|
1103
1103
|
/***/ }),
|
|
1104
1104
|
|
|
1105
1105
|
/***/ "../../node_modules/gl-matrix/esm/common.js":
|
|
1106
|
-
|
|
1107
|
-
!*** /Users/
|
|
1108
|
-
|
|
1106
|
+
/*!***********************************************************************!*\
|
|
1107
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/gl-matrix/esm/common.js ***!
|
|
1108
|
+
\***********************************************************************/
|
|
1109
1109
|
/*! exports provided: EPSILON, ARRAY_TYPE, RANDOM, setMatrixArrayType, toRadian, equals */
|
|
1110
1110
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1111
1111
|
|
|
@@ -1171,9 +1171,9 @@ if (!Math.hypot) Math.hypot = function () {
|
|
|
1171
1171
|
/***/ }),
|
|
1172
1172
|
|
|
1173
1173
|
/***/ "../../node_modules/gl-matrix/esm/mat4.js":
|
|
1174
|
-
|
|
1175
|
-
!*** /Users/
|
|
1176
|
-
|
|
1174
|
+
/*!*********************************************************************!*\
|
|
1175
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/gl-matrix/esm/mat4.js ***!
|
|
1176
|
+
\*********************************************************************/
|
|
1177
1177
|
/*! exports provided: create, clone, copy, fromValues, set, identity, transpose, invert, adjoint, determinant, multiply, translate, scale, rotate, rotateX, rotateY, rotateZ, fromTranslation, fromScaling, fromRotation, fromXRotation, fromYRotation, fromZRotation, fromRotationTranslation, fromQuat2, getTranslation, getScaling, getRotation, fromRotationTranslationScale, fromRotationTranslationScaleOrigin, fromQuat, frustum, perspectiveNO, perspective, perspectiveZO, perspectiveFromFieldOfView, orthoNO, ortho, orthoZO, lookAt, targetTo, str, frob, add, subtract, multiplyScalar, multiplyScalarAndAdd, exactEquals, equals, mul, sub */
|
|
1178
1178
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1179
1179
|
|
|
@@ -3145,9 +3145,9 @@ var sub = subtract;
|
|
|
3145
3145
|
/***/ }),
|
|
3146
3146
|
|
|
3147
3147
|
/***/ "../../node_modules/gl-matrix/esm/vec2.js":
|
|
3148
|
-
|
|
3149
|
-
!*** /Users/
|
|
3150
|
-
|
|
3148
|
+
/*!*********************************************************************!*\
|
|
3149
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/gl-matrix/esm/vec2.js ***!
|
|
3150
|
+
\*********************************************************************/
|
|
3151
3151
|
/*! exports provided: create, clone, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, length, squaredLength, negate, inverse, normalize, dot, cross, lerp, random, transformMat2, transformMat2d, transformMat3, transformMat4, rotate, angle, zero, str, exactEquals, equals, len, sub, mul, div, dist, sqrDist, sqrLen, forEach */
|
|
3152
3152
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3153
3153
|
|
|
@@ -3827,9 +3827,9 @@ var forEach = function () {
|
|
|
3827
3827
|
/***/ }),
|
|
3828
3828
|
|
|
3829
3829
|
/***/ "../../node_modules/gl-matrix/esm/vec3.js":
|
|
3830
|
-
|
|
3831
|
-
!*** /Users/
|
|
3832
|
-
|
|
3830
|
+
/*!*********************************************************************!*\
|
|
3831
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/gl-matrix/esm/vec3.js ***!
|
|
3832
|
+
\*********************************************************************/
|
|
3833
3833
|
/*! exports provided: create, clone, length, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, squaredLength, negate, inverse, normalize, dot, cross, lerp, hermite, bezier, random, transformMat4, transformMat3, transformQuat, rotateX, rotateY, rotateZ, angle, zero, str, exactEquals, equals, sub, mul, div, dist, sqrDist, len, sqrLen, forEach */
|
|
3834
3834
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
3835
3835
|
|
|
@@ -4675,9 +4675,9 @@ var forEach = function () {
|
|
|
4675
4675
|
/***/ }),
|
|
4676
4676
|
|
|
4677
4677
|
/***/ "../../node_modules/gl-matrix/esm/vec4.js":
|
|
4678
|
-
|
|
4679
|
-
!*** /Users/
|
|
4680
|
-
|
|
4678
|
+
/*!*********************************************************************!*\
|
|
4679
|
+
!*** /Users/alasarr/dev/deck.gl/node_modules/gl-matrix/esm/vec4.js ***!
|
|
4680
|
+
\*********************************************************************/
|
|
4681
4681
|
/*! exports provided: create, clone, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, length, squaredLength, negate, inverse, normalize, dot, cross, lerp, random, transformMat4, transformQuat, zero, str, exactEquals, equals, sub, mul, div, dist, sqrDist, len, sqrLen, forEach */
|
|
4682
4682
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
4683
4683
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl/mapbox",
|
|
3
3
|
"description": "Use deck.gl layers as custom mapbox-gl-js layers",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "8.9.0-alpha.
|
|
5
|
+
"version": "8.9.0-alpha.4",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@deck.gl/core": "^8.0.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "f34f77e2b050306ade160a5628ea2844a4ceabc2"
|
|
39
39
|
}
|
package/typed/deck-utils.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { Deck, WebMercatorViewport, MapView, _flatten as flatten } from '@deck.gl/core';
|
|
2
|
-
export function getDeckInstance({ map, gl, deck }) {
|
|
3
|
-
// Only create one deck instance per context
|
|
4
|
-
if (map.__deck) {
|
|
5
|
-
return map.__deck;
|
|
6
|
-
}
|
|
7
|
-
const customRender = deck?.props._customRender;
|
|
8
|
-
const deckProps = {
|
|
9
|
-
useDevicePixels: true,
|
|
10
|
-
_customRender: (reason) => {
|
|
11
|
-
map.triggerRepaint();
|
|
12
|
-
// customRender may be subscribed by DeckGL React component to update child props
|
|
13
|
-
// make sure it is still called
|
|
14
|
-
customRender?.(reason);
|
|
15
|
-
},
|
|
16
|
-
// TODO: import these defaults from a single source of truth
|
|
17
|
-
parameters: {
|
|
18
|
-
depthMask: true,
|
|
19
|
-
depthTest: true,
|
|
20
|
-
blend: true,
|
|
21
|
-
blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA],
|
|
22
|
-
polygonOffsetFill: true,
|
|
23
|
-
depthFunc: gl.LEQUAL,
|
|
24
|
-
blendEquation: gl.FUNC_ADD
|
|
25
|
-
},
|
|
26
|
-
views: (deck && deck.props.views) || [new MapView({ id: 'mapbox' })]
|
|
27
|
-
};
|
|
28
|
-
if (!deck || deck.props.gl === gl) {
|
|
29
|
-
// deck is using the WebGLContext created by mapbox
|
|
30
|
-
// block deck from setting the canvas size
|
|
31
|
-
Object.assign(deckProps, {
|
|
32
|
-
gl,
|
|
33
|
-
width: null,
|
|
34
|
-
height: null,
|
|
35
|
-
touchAction: 'unset',
|
|
36
|
-
viewState: getViewState(map)
|
|
37
|
-
});
|
|
38
|
-
// If using the WebGLContext created by deck (React use case), we use deck's viewState to drive the map.
|
|
39
|
-
// Otherwise (pure JS use case), we use the map's viewState to drive deck.
|
|
40
|
-
map.on('move', () => onMapMove(deck, map));
|
|
41
|
-
}
|
|
42
|
-
if (deck) {
|
|
43
|
-
deck.setProps(deckProps);
|
|
44
|
-
deck.userData.isExternal = true;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
deck = new Deck(deckProps);
|
|
48
|
-
map.on('remove', () => {
|
|
49
|
-
deck.finalize();
|
|
50
|
-
map.__deck = null;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
deck.userData.mapboxLayers = new Set();
|
|
54
|
-
deck.userData.mapboxVersion = getMapboxVersion(map);
|
|
55
|
-
map.__deck = deck;
|
|
56
|
-
map.on('render', () => {
|
|
57
|
-
// @ts-expect-error (2445) protected property
|
|
58
|
-
if (deck.layerManager)
|
|
59
|
-
afterRender(deck, map);
|
|
60
|
-
});
|
|
61
|
-
return deck;
|
|
62
|
-
}
|
|
63
|
-
export function addLayer(deck, layer) {
|
|
64
|
-
deck.userData.mapboxLayers.add(layer);
|
|
65
|
-
updateLayers(deck);
|
|
66
|
-
}
|
|
67
|
-
export function removeLayer(deck, layer) {
|
|
68
|
-
deck.userData.mapboxLayers.delete(layer);
|
|
69
|
-
updateLayers(deck);
|
|
70
|
-
}
|
|
71
|
-
export function updateLayer(deck, layer) {
|
|
72
|
-
updateLayers(deck);
|
|
73
|
-
}
|
|
74
|
-
export function drawLayer(deck, map, layer) {
|
|
75
|
-
let { currentViewport } = deck.userData;
|
|
76
|
-
if (!currentViewport) {
|
|
77
|
-
// This is the first layer drawn in this render cycle.
|
|
78
|
-
// Generate viewport from the current map state.
|
|
79
|
-
currentViewport = getViewport(deck, map, true);
|
|
80
|
-
deck.userData.currentViewport = currentViewport;
|
|
81
|
-
}
|
|
82
|
-
// @ts-expect-error (2445) protected property
|
|
83
|
-
if (!deck.layerManager) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
deck._drawLayers('mapbox-repaint', {
|
|
87
|
-
viewports: [currentViewport],
|
|
88
|
-
layerFilter: ({ layer: deckLayer }) => layer.id === deckLayer.id,
|
|
89
|
-
clearCanvas: false
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
export function getViewState(map) {
|
|
93
|
-
const { lng, lat } = map.getCenter();
|
|
94
|
-
return {
|
|
95
|
-
// Longitude returned by getCenter can be outside of [-180, 180] when zooming near the anti meridian
|
|
96
|
-
// https://github.com/visgl/deck.gl/issues/6894
|
|
97
|
-
longitude: ((lng + 540) % 360) - 180,
|
|
98
|
-
latitude: lat,
|
|
99
|
-
zoom: map.getZoom(),
|
|
100
|
-
bearing: map.getBearing(),
|
|
101
|
-
pitch: map.getPitch(),
|
|
102
|
-
repeat: map.getRenderWorldCopies()
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function getMapboxVersion(map) {
|
|
106
|
-
// parse mapbox version string
|
|
107
|
-
let major = 0;
|
|
108
|
-
let minor = 0;
|
|
109
|
-
// @ts-ignore (2339) undefined property
|
|
110
|
-
const version = map.version;
|
|
111
|
-
if (version) {
|
|
112
|
-
[major, minor] = version.split('.').slice(0, 2).map(Number);
|
|
113
|
-
}
|
|
114
|
-
return { major, minor };
|
|
115
|
-
}
|
|
116
|
-
function getViewport(deck, map, useMapboxProjection = true) {
|
|
117
|
-
const { mapboxVersion } = deck.userData;
|
|
118
|
-
return new WebMercatorViewport(Object.assign({
|
|
119
|
-
id: 'mapbox',
|
|
120
|
-
x: 0,
|
|
121
|
-
y: 0,
|
|
122
|
-
width: deck.width,
|
|
123
|
-
height: deck.height
|
|
124
|
-
}, getViewState(map), useMapboxProjection
|
|
125
|
-
? {
|
|
126
|
-
// match mapbox's projection matrix
|
|
127
|
-
// A change of near plane was made in 1.3.0
|
|
128
|
-
// https://github.com/mapbox/mapbox-gl-js/pull/8502
|
|
129
|
-
nearZMultiplier: (mapboxVersion.major === 1 && mapboxVersion.minor >= 3) || mapboxVersion.major >= 2
|
|
130
|
-
? 0.02
|
|
131
|
-
: 1 / (deck.height || 1)
|
|
132
|
-
}
|
|
133
|
-
: {
|
|
134
|
-
// use deck.gl's own default
|
|
135
|
-
nearZMultiplier: 0.1
|
|
136
|
-
}));
|
|
137
|
-
}
|
|
138
|
-
function afterRender(deck, map) {
|
|
139
|
-
const { mapboxLayers, isExternal } = deck.userData;
|
|
140
|
-
if (isExternal) {
|
|
141
|
-
// Draw non-Mapbox layers
|
|
142
|
-
const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);
|
|
143
|
-
const deckLayers = flatten(deck.props.layers, Boolean);
|
|
144
|
-
const hasNonMapboxLayers = deckLayers.some(layer => layer && !mapboxLayerIds.includes(layer.id));
|
|
145
|
-
let viewports = deck.getViewports();
|
|
146
|
-
const mapboxViewportIdx = viewports.findIndex(vp => vp.id === 'mapbox');
|
|
147
|
-
const hasNonMapboxViews = viewports.length > 1 || mapboxViewportIdx < 0;
|
|
148
|
-
if (hasNonMapboxLayers || hasNonMapboxViews) {
|
|
149
|
-
if (mapboxViewportIdx >= 0) {
|
|
150
|
-
viewports = viewports.slice();
|
|
151
|
-
viewports[mapboxViewportIdx] = getViewport(deck, map, false);
|
|
152
|
-
}
|
|
153
|
-
deck._drawLayers('mapbox-repaint', {
|
|
154
|
-
viewports,
|
|
155
|
-
layerFilter: params => (!deck.props.layerFilter || deck.props.layerFilter(params)) &&
|
|
156
|
-
(params.viewport.id !== 'mapbox' || !mapboxLayerIds.includes(params.layer.id)),
|
|
157
|
-
clearCanvas: false
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// End of render cycle, clear generated viewport
|
|
162
|
-
deck.userData.currentViewport = null;
|
|
163
|
-
}
|
|
164
|
-
function onMapMove(deck, map) {
|
|
165
|
-
deck.setProps({
|
|
166
|
-
viewState: getViewState(map)
|
|
167
|
-
});
|
|
168
|
-
// Camera changed, will trigger a map repaint right after this
|
|
169
|
-
// Clear any change flag triggered by setting viewState so that deck does not request
|
|
170
|
-
// a second repaint
|
|
171
|
-
deck.needsRedraw({ clearRedrawFlags: true });
|
|
172
|
-
}
|
|
173
|
-
function updateLayers(deck) {
|
|
174
|
-
if (deck.userData.isExternal) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
const layers = [];
|
|
178
|
-
let layerIndex = 0;
|
|
179
|
-
deck.userData.mapboxLayers.forEach(deckLayer => {
|
|
180
|
-
const LayerType = deckLayer.props.type;
|
|
181
|
-
const layer = new LayerType(deckLayer.props, { _offset: layerIndex++ });
|
|
182
|
-
layers.push(layer);
|
|
183
|
-
});
|
|
184
|
-
deck.setProps({ layers });
|
|
185
|
-
}
|
package/typed/index.js
DELETED
package/typed/mapbox-layer.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { getDeckInstance, addLayer, removeLayer, updateLayer, drawLayer } from './deck-utils';
|
|
2
|
-
export default class MapboxLayer {
|
|
3
|
-
/* eslint-disable no-this-before-super */
|
|
4
|
-
constructor(props) {
|
|
5
|
-
if (!props.id) {
|
|
6
|
-
throw new Error('Layer must have an unique id');
|
|
7
|
-
}
|
|
8
|
-
this.id = props.id;
|
|
9
|
-
this.type = 'custom';
|
|
10
|
-
this.renderingMode = props.renderingMode || '3d';
|
|
11
|
-
this.map = null;
|
|
12
|
-
this.deck = null;
|
|
13
|
-
this.props = props;
|
|
14
|
-
}
|
|
15
|
-
/* Mapbox custom layer methods */
|
|
16
|
-
onAdd(map, gl) {
|
|
17
|
-
this.map = map;
|
|
18
|
-
this.deck = getDeckInstance({ map, gl, deck: this.props.deck });
|
|
19
|
-
addLayer(this.deck, this);
|
|
20
|
-
}
|
|
21
|
-
onRemove() {
|
|
22
|
-
if (this.deck) {
|
|
23
|
-
removeLayer(this.deck, this);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
setProps(props) {
|
|
27
|
-
// id cannot be changed
|
|
28
|
-
Object.assign(this.props, props, { id: this.id });
|
|
29
|
-
// safe guard in case setProps is called before onAdd
|
|
30
|
-
if (this.deck) {
|
|
31
|
-
updateLayer(this.deck, this);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
render() {
|
|
35
|
-
drawLayer(this.deck, this.map, this);
|
|
36
|
-
}
|
|
37
|
-
}
|
package/typed/mapbox-overlay.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { Deck, assert } from '@deck.gl/core';
|
|
2
|
-
import { getViewState } from './deck-utils';
|
|
3
|
-
/**
|
|
4
|
-
* Implements Mapbox [IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) interface
|
|
5
|
-
* Renders deck.gl layers over the base map and automatically synchronizes with the map's camera
|
|
6
|
-
*/
|
|
7
|
-
export default class MapboxOverlay {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
this._updateContainerSize = () => {
|
|
10
|
-
if (this._map && this._container) {
|
|
11
|
-
const { clientWidth, clientHeight } = this._map.getContainer();
|
|
12
|
-
Object.assign(this._container.style, {
|
|
13
|
-
width: `${clientWidth}px`,
|
|
14
|
-
height: `${clientHeight}px`
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
this._updateViewState = () => {
|
|
19
|
-
const deck = this._deck;
|
|
20
|
-
if (deck) {
|
|
21
|
-
// @ts-ignore (2345) map is always defined if deck is
|
|
22
|
-
deck.setProps({ viewState: getViewState(this._map) });
|
|
23
|
-
// Redraw immediately if view state has changed
|
|
24
|
-
deck.redraw();
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
this._handleMouseEvent = (event) => {
|
|
28
|
-
const deck = this._deck;
|
|
29
|
-
if (!deck) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const mockEvent = {
|
|
33
|
-
type: event.type,
|
|
34
|
-
offsetCenter: event.point,
|
|
35
|
-
srcEvent: event
|
|
36
|
-
};
|
|
37
|
-
switch (event.type) {
|
|
38
|
-
case 'click':
|
|
39
|
-
mockEvent.tapCount = 1;
|
|
40
|
-
// Hack: because we do not listen to pointer down, perform picking now
|
|
41
|
-
deck._onPointerDown(mockEvent);
|
|
42
|
-
deck._onEvent(mockEvent);
|
|
43
|
-
break;
|
|
44
|
-
case 'dblclick':
|
|
45
|
-
mockEvent.type = 'click';
|
|
46
|
-
mockEvent.tapCount = 2;
|
|
47
|
-
deck._onEvent(mockEvent);
|
|
48
|
-
break;
|
|
49
|
-
case 'mousemove':
|
|
50
|
-
mockEvent.type = 'pointermove';
|
|
51
|
-
deck._onPointerMove(mockEvent);
|
|
52
|
-
break;
|
|
53
|
-
case 'mouseout':
|
|
54
|
-
mockEvent.type = 'pointerleave';
|
|
55
|
-
deck._onPointerMove(mockEvent);
|
|
56
|
-
break;
|
|
57
|
-
default:
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
this._props = { ...props };
|
|
62
|
-
}
|
|
63
|
-
/** Update (partial) props of the underlying Deck instance. */
|
|
64
|
-
setProps(props) {
|
|
65
|
-
Object.assign(this._props, props);
|
|
66
|
-
if ('viewState' in this._props) {
|
|
67
|
-
delete this._props.viewState;
|
|
68
|
-
}
|
|
69
|
-
if (this._deck) {
|
|
70
|
-
this._deck.setProps(this._props);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/** Called when the control is added to a map */
|
|
74
|
-
onAdd(map) {
|
|
75
|
-
this._map = map;
|
|
76
|
-
/* global document */
|
|
77
|
-
const container = document.createElement('div');
|
|
78
|
-
Object.assign(container.style, {
|
|
79
|
-
position: 'absolute',
|
|
80
|
-
left: 0,
|
|
81
|
-
top: 0,
|
|
82
|
-
pointerEvents: 'none'
|
|
83
|
-
});
|
|
84
|
-
this._container = container;
|
|
85
|
-
this._deck = new Deck({
|
|
86
|
-
...this._props,
|
|
87
|
-
parent: container,
|
|
88
|
-
viewState: getViewState(map)
|
|
89
|
-
});
|
|
90
|
-
map.on('resize', this._updateContainerSize);
|
|
91
|
-
map.on('render', this._updateViewState);
|
|
92
|
-
map.on('mousemove', this._handleMouseEvent);
|
|
93
|
-
map.on('mouseout', this._handleMouseEvent);
|
|
94
|
-
map.on('click', this._handleMouseEvent);
|
|
95
|
-
map.on('dblclick', this._handleMouseEvent);
|
|
96
|
-
this._updateContainerSize();
|
|
97
|
-
return container;
|
|
98
|
-
}
|
|
99
|
-
/** Called when the control is removed from a map */
|
|
100
|
-
onRemove() {
|
|
101
|
-
const map = this._map;
|
|
102
|
-
if (map) {
|
|
103
|
-
map.off('resize', this._updateContainerSize);
|
|
104
|
-
map.off('render', this._updateViewState);
|
|
105
|
-
map.off('mousemove', this._handleMouseEvent);
|
|
106
|
-
map.off('mouseout', this._handleMouseEvent);
|
|
107
|
-
map.off('click', this._handleMouseEvent);
|
|
108
|
-
map.off('dblclick', this._handleMouseEvent);
|
|
109
|
-
}
|
|
110
|
-
this._deck?.finalize();
|
|
111
|
-
this._deck = undefined;
|
|
112
|
-
this._map = undefined;
|
|
113
|
-
this._container = undefined;
|
|
114
|
-
}
|
|
115
|
-
getDefaultPosition() {
|
|
116
|
-
return 'top-left';
|
|
117
|
-
}
|
|
118
|
-
/** Forwards the Deck.pickObject method */
|
|
119
|
-
pickObject(params) {
|
|
120
|
-
assert(this._deck);
|
|
121
|
-
return this._deck.pickObject(params);
|
|
122
|
-
}
|
|
123
|
-
/** Forwards the Deck.pickMultipleObjects method */
|
|
124
|
-
pickMultipleObjects(params) {
|
|
125
|
-
assert(this._deck);
|
|
126
|
-
return this._deck.pickMultipleObjects(params);
|
|
127
|
-
}
|
|
128
|
-
/** Forwards the Deck.pickObjects method */
|
|
129
|
-
pickObjects(params) {
|
|
130
|
-
assert(this._deck);
|
|
131
|
-
return this._deck.pickObjects(params);
|
|
132
|
-
}
|
|
133
|
-
/** Remove from map and releases all resources */
|
|
134
|
-
finalize() {
|
|
135
|
-
if (this._map) {
|
|
136
|
-
this._map.removeControl(this);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|