@mapcomponents/deck-gl 1.8.9 → 1.8.10
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MlHexagonLayer.d.ts","sourceRoot":"","sources":["../../../src/components/MlHexagonLayer/MlHexagonLayer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAI9E,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC3D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAwBD,QAAA,MAAM,cAAc,GAAI,OAAO,iBAAiB,
|
|
1
|
+
{"version":3,"file":"MlHexagonLayer.d.ts","sourceRoot":"","sources":["../../../src/components/MlHexagonLayer/MlHexagonLayer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAI9E,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC3D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAwBD,QAAA,MAAM,cAAc,GAAI,OAAO,iBAAiB,4CAyC/C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),n=require("react"),i=require("@mapcomponents/react-maplibre"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),n=require("react"),i=require("@mapcomponents/react-maplibre"),L=require("@deck.gl/mapbox"),f=require("@deck.gl/aggregation-layers"),g=require("@deck.gl/geo-layers"),k=require("@deck.gl/mesh-layers"),v="deckgl-layer",y=n.createContext({}),x=({mapId:e,children:o})=>{const r=i.useMap({mapId:e}),t=n.useRef(void 0),[s,a]=n.useState([]),[c,u]=n.useState([]);n.useEffect(()=>{if(r.map)return t.current=new L.MapboxOverlay({id:v,interleaved:!0}),r.map.addControl(t.current),()=>{t.current&&r.map?.removeControl(t.current),t.current=void 0}},[r.map]),n.useEffect(()=>{t.current&&t.current.setProps({layers:[...s],effects:[...c]})},[s,c]);const m={deckGlLayerArray:s,setDeckGlLayerArray:a,deckGlEffectArray:c,setDeckGlEffectArray:u};return l.jsx(y.Provider,{value:m,children:o})};function d(){const e=n.useContext(y);function o(a){e.setDeckGlEffectArray(c=>[...c,a])}function r(a){e.setDeckGlEffectArray(c=>c.filter(u=>u!==a))}function t(a){e.setDeckGlLayerArray(c=>[...c,a])}function s(a){e.setDeckGlLayerArray(c=>c.filter(u=>u!==a))}return{addEffect:o,removeEffect:r,addLayer:t,removeLayer:s}}const p={type:f.HexagonLayer,layerOpacity:.8,elevationRange:[30,75],elevationScale:1,extruded:!0,coverage:.9,autoHighlight:!1,material:{ambient:.6,diffuse:.5,shininess:10},radius:16,transitions:{elevationScale:1500},_filterData:null,colorRange:[[1,152,189,125],[73,227,206,150],[216,254,181,175],[254,237,177,200],[254,173,84,225],[209,55,78,255]]},G=e=>{const o=d(),r=i.useMap({mapId:e.mapId,waitForLayer:e.beforeId}),t=n.useMemo(()=>{const{mapId:s,...a}=e;return a.data?new f.HexagonLayer({...p,...a}):null},[e.beforeId,e.data,e.elevationScale,e.extruded,e.coverage,e.autoHighlight,e.material,e.radius,e.transitions]);return n.useEffect(()=>{if(!(!r.map||!t))return o.addLayer(t),()=>{o.removeLayer(t)}},[r.map,t]),l.jsx(l.Fragment,{})},D=e=>{const{mapId:o,...r}=e,t=i.useMap({mapId:o}),s=d(),a=n.useMemo(()=>r.data?new g.Tile3DLayer({...r}):null,[r.data,r.id,r.pickable,r.onTileLoad,r.onTileUnload,r.loadOptions,r.loaders,r.visible,r.opacity,r.pointSize,r.beforeId]);return n.useEffect(()=>{if(!(!t.map||!a))return s.addLayer(a),()=>{a&&s.removeLayer(a)}},[t.map,a]),l.jsx(l.Fragment,{})},M=e=>{const o=i.useMap({mapId:e.mapId,waitForLayer:e.beforeId}),r=d(),t=n.useMemo(()=>{const{mapId:s,...a}=e;return new k.ScenegraphLayer({...a})},[e]);return n.useEffect(()=>{if(!(!o.map||!t))return r.addLayer(t),()=>{t&&r.removeLayer(t)}},[o.map,t]),l.jsx(l.Fragment,{})};exports.DeckGlContext=y;exports.DeckGlContextProvider=x;exports.Ml3DTileLayer=D;exports.MlHexagonLayer=G;exports.MlSceneGraphLayer=M;exports.useDeckGl=d;
|
package/dist/index.mjs
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useMap as
|
|
1
|
+
import { jsx as d, Fragment as s } from "react/jsx-runtime";
|
|
2
|
+
import p, { useRef as g, useState as y, useEffect as i, useContext as G, useMemo as f } from "react";
|
|
3
|
+
import { useMap as u } from "@mapcomponents/react-maplibre";
|
|
4
4
|
import { MapboxOverlay as x } from "@deck.gl/mapbox";
|
|
5
|
-
import { HexagonLayer as
|
|
6
|
-
import { Tile3DLayer as
|
|
7
|
-
import { ScenegraphLayer as
|
|
8
|
-
const
|
|
9
|
-
const r =
|
|
5
|
+
import { HexagonLayer as L } from "@deck.gl/aggregation-layers";
|
|
6
|
+
import { Tile3DLayer as I } from "@deck.gl/geo-layers";
|
|
7
|
+
import { ScenegraphLayer as D } from "@deck.gl/mesh-layers";
|
|
8
|
+
const H = "deckgl-layer", k = p.createContext({}), w = ({ mapId: e, children: n }) => {
|
|
9
|
+
const r = u({ mapId: e }), t = g(void 0), [c, a] = y([]), [o, l] = y([]);
|
|
10
10
|
i(() => {
|
|
11
11
|
if (r.map)
|
|
12
|
-
return
|
|
13
|
-
id:
|
|
12
|
+
return t.current = new x({
|
|
13
|
+
id: H,
|
|
14
14
|
interleaved: !0
|
|
15
|
-
}), r.map.addControl(
|
|
16
|
-
|
|
15
|
+
}), r.map.addControl(t.current), () => {
|
|
16
|
+
t.current && r.map?.removeControl(t.current), t.current = void 0;
|
|
17
17
|
};
|
|
18
18
|
}, [r.map]), i(() => {
|
|
19
|
-
|
|
20
|
-
layers: [...
|
|
21
|
-
effects: [...
|
|
19
|
+
t.current && t.current.setProps({
|
|
20
|
+
layers: [...c],
|
|
21
|
+
effects: [...o]
|
|
22
22
|
});
|
|
23
|
-
}, [
|
|
24
|
-
const
|
|
25
|
-
deckGlLayerArray:
|
|
26
|
-
setDeckGlLayerArray:
|
|
27
|
-
deckGlEffectArray:
|
|
23
|
+
}, [c, o]);
|
|
24
|
+
const v = {
|
|
25
|
+
deckGlLayerArray: c,
|
|
26
|
+
setDeckGlLayerArray: a,
|
|
27
|
+
deckGlEffectArray: o,
|
|
28
28
|
setDeckGlEffectArray: l
|
|
29
29
|
};
|
|
30
|
-
return /* @__PURE__ */
|
|
30
|
+
return /* @__PURE__ */ d(k.Provider, { value: v, children: n });
|
|
31
31
|
};
|
|
32
32
|
function m() {
|
|
33
|
-
const
|
|
34
|
-
function n(
|
|
35
|
-
|
|
33
|
+
const e = G(k);
|
|
34
|
+
function n(a) {
|
|
35
|
+
e.setDeckGlEffectArray((o) => [...o, a]);
|
|
36
36
|
}
|
|
37
|
-
function r(
|
|
38
|
-
|
|
37
|
+
function r(a) {
|
|
38
|
+
e.setDeckGlEffectArray((o) => o.filter((l) => l !== a));
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
40
|
+
function t(a) {
|
|
41
|
+
e.setDeckGlLayerArray((o) => [...o, a]);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
43
|
+
function c(a) {
|
|
44
|
+
e.setDeckGlLayerArray((o) => o.filter((l) => l !== a));
|
|
45
45
|
}
|
|
46
46
|
return {
|
|
47
47
|
addEffect: n,
|
|
48
48
|
removeEffect: r,
|
|
49
|
-
addLayer:
|
|
50
|
-
removeLayer:
|
|
49
|
+
addLayer: t,
|
|
50
|
+
removeLayer: c
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
const
|
|
54
|
-
type:
|
|
53
|
+
const h = {
|
|
54
|
+
type: L,
|
|
55
55
|
layerOpacity: 0.8,
|
|
56
56
|
elevationRange: [30, 75],
|
|
57
57
|
elevationScale: 1,
|
|
@@ -70,18 +70,17 @@ const I = {
|
|
|
70
70
|
[254, 173, 84, 225],
|
|
71
71
|
[209, 55, 78, 255]
|
|
72
72
|
]
|
|
73
|
-
}, R = (
|
|
74
|
-
const n = m()
|
|
75
|
-
|
|
76
|
-
...I,
|
|
77
|
-
...a
|
|
78
|
-
};
|
|
79
|
-
const { mapId: r, ...e } = a, o = d({
|
|
80
|
-
mapId: r,
|
|
73
|
+
}, R = (e) => {
|
|
74
|
+
const n = m(), r = u({
|
|
75
|
+
mapId: e.mapId,
|
|
81
76
|
waitForLayer: e.beforeId
|
|
82
|
-
}), t = f(() =>
|
|
83
|
-
...e
|
|
84
|
-
|
|
77
|
+
}), t = f(() => {
|
|
78
|
+
const { mapId: c, ...a } = e;
|
|
79
|
+
return a.data ? new L({
|
|
80
|
+
...h,
|
|
81
|
+
...a
|
|
82
|
+
}) : null;
|
|
83
|
+
}, [
|
|
85
84
|
e.beforeId,
|
|
86
85
|
e.data,
|
|
87
86
|
e.elevationScale,
|
|
@@ -93,13 +92,13 @@ const I = {
|
|
|
93
92
|
e.transitions
|
|
94
93
|
]);
|
|
95
94
|
return i(() => {
|
|
96
|
-
if (!(!
|
|
95
|
+
if (!(!r.map || !t))
|
|
97
96
|
return n.addLayer(t), () => {
|
|
98
97
|
n.removeLayer(t);
|
|
99
98
|
};
|
|
100
|
-
}, [
|
|
101
|
-
}, T = (
|
|
102
|
-
const { mapId: n, ...r } =
|
|
99
|
+
}, [r.map, t]), /* @__PURE__ */ d(s, {});
|
|
100
|
+
}, T = (e) => {
|
|
101
|
+
const { mapId: n, ...r } = e, t = u({ mapId: n }), c = m(), a = f(() => r.data ? new I({
|
|
103
102
|
...r
|
|
104
103
|
}) : null, [
|
|
105
104
|
r.data,
|
|
@@ -115,30 +114,30 @@ const I = {
|
|
|
115
114
|
r.beforeId
|
|
116
115
|
]);
|
|
117
116
|
return i(() => {
|
|
118
|
-
if (!(!
|
|
119
|
-
return
|
|
120
|
-
|
|
117
|
+
if (!(!t.map || !a))
|
|
118
|
+
return c.addLayer(a), () => {
|
|
119
|
+
a && c.removeLayer(a);
|
|
121
120
|
};
|
|
122
|
-
}, [
|
|
123
|
-
}, F = (
|
|
124
|
-
const n =
|
|
125
|
-
mapId:
|
|
126
|
-
waitForLayer:
|
|
127
|
-
}), r = m(),
|
|
128
|
-
const { mapId:
|
|
129
|
-
return new
|
|
130
|
-
...
|
|
121
|
+
}, [t.map, a]), /* @__PURE__ */ d(s, {});
|
|
122
|
+
}, F = (e) => {
|
|
123
|
+
const n = u({
|
|
124
|
+
mapId: e.mapId,
|
|
125
|
+
waitForLayer: e.beforeId
|
|
126
|
+
}), r = m(), t = f(() => {
|
|
127
|
+
const { mapId: c, ...a } = e;
|
|
128
|
+
return new D({
|
|
129
|
+
...a
|
|
131
130
|
});
|
|
132
|
-
}, [
|
|
131
|
+
}, [e]);
|
|
133
132
|
return i(() => {
|
|
134
|
-
if (!(!n.map || !
|
|
135
|
-
return r.addLayer(
|
|
136
|
-
|
|
133
|
+
if (!(!n.map || !t))
|
|
134
|
+
return r.addLayer(t), () => {
|
|
135
|
+
t && r.removeLayer(t);
|
|
137
136
|
};
|
|
138
|
-
}, [n.map,
|
|
137
|
+
}, [n.map, t]), /* @__PURE__ */ d(s, {});
|
|
139
138
|
};
|
|
140
139
|
export {
|
|
141
|
-
|
|
140
|
+
k as DeckGlContext,
|
|
142
141
|
w as DeckGlContextProvider,
|
|
143
142
|
T as Ml3DTileLayer,
|
|
144
143
|
R as MlHexagonLayer,
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapcomponents/deck-gl",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@mui/icons-material": "^7.3.2",
|
|
15
15
|
"@mui/system": "^7.3.2",
|
|
16
16
|
"@mui/material": "^7.3.2",
|
|
17
|
-
"@storybook/react": "^9.1.
|
|
17
|
+
"@storybook/react": "^9.1.20",
|
|
18
18
|
"uuid": "^11.1.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapcomponents/deck-gl",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@mui/icons-material": "^7.3.2",
|
|
12
12
|
"@mui/system": "^7.3.2",
|
|
13
13
|
"@mui/material": "^7.3.2",
|
|
14
|
-
"@storybook/react": "^9.1.
|
|
14
|
+
"@storybook/react": "^9.1.20",
|
|
15
15
|
"uuid": "^11.1.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@deck.gl/mapbox": "^9.2.6",
|
|
22
22
|
"@deck.gl/mesh-layers": "^9.2.6",
|
|
23
23
|
"maplibre-gl": "^5.16.0",
|
|
24
|
-
"@mapcomponents/react-maplibre": "1.8.
|
|
24
|
+
"@mapcomponents/react-maplibre": "1.8.10"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/geojson": "^7946.0.16"
|
|
@@ -40,38 +40,31 @@ const defaultProps = {
|
|
|
40
40
|
const MlHexagonLayer = (props: MlHexagonMapProps) => {
|
|
41
41
|
const deckGlHook = useDeckGl();
|
|
42
42
|
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
44
|
-
// @ts-expect-error
|
|
45
|
-
props = {
|
|
46
|
-
...defaultProps,
|
|
47
|
-
...props,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const { mapId, ...HexagonLayerProps } = props;
|
|
51
|
-
|
|
52
43
|
const mapHook = useMap({
|
|
53
|
-
mapId: mapId,
|
|
54
|
-
waitForLayer:
|
|
44
|
+
mapId: props.mapId,
|
|
45
|
+
waitForLayer: props.beforeId,
|
|
55
46
|
});
|
|
56
47
|
|
|
57
48
|
// create deck.gl HexagonLayer once when its props change
|
|
58
49
|
const hexagonLayer = useMemo(() => {
|
|
50
|
+
const { mapId: _mapId, ...HexagonLayerProps } = props;
|
|
59
51
|
if (!HexagonLayerProps.data) return null;
|
|
60
52
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
61
53
|
// @ts-ignore
|
|
62
54
|
return new HexagonLayer({
|
|
55
|
+
...defaultProps,
|
|
63
56
|
...HexagonLayerProps,
|
|
64
57
|
} as unknown as HexagonLayerProps);
|
|
65
58
|
}, [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
props.beforeId,
|
|
60
|
+
props.data,
|
|
61
|
+
props.elevationScale,
|
|
62
|
+
props.extruded,
|
|
63
|
+
props.coverage,
|
|
64
|
+
props.autoHighlight,
|
|
65
|
+
props.material,
|
|
66
|
+
props.radius,
|
|
67
|
+
props.transitions,
|
|
75
68
|
]);
|
|
76
69
|
|
|
77
70
|
// add/remove the memoized layer
|