@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,4CAgD/C,CAAC;AAEF,eAAe,cAAc,CAAC"}
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"),p=require("@deck.gl/mapbox"),f=require("@deck.gl/aggregation-layers"),L=require("@deck.gl/geo-layers"),g=require("@deck.gl/mesh-layers"),k="deckgl-layer",y=n.createContext({}),v=({mapId:a,children:c})=>{const r=i.useMap({mapId:a}),e=n.useRef(void 0),[o,t]=n.useState([]),[s,u]=n.useState([]);n.useEffect(()=>{if(r.map)return e.current=new p.MapboxOverlay({id:k,interleaved:!0}),r.map.addControl(e.current),()=>{e.current&&r.map?.removeControl(e.current),e.current=void 0}},[r.map]),n.useEffect(()=>{e.current&&e.current.setProps({layers:[...o],effects:[...s]})},[o,s]);const m={deckGlLayerArray:o,setDeckGlLayerArray:t,deckGlEffectArray:s,setDeckGlEffectArray:u};return l.jsx(y.Provider,{value:m,children:c})};function d(){const a=n.useContext(y);function c(t){a.setDeckGlEffectArray(s=>[...s,t])}function r(t){a.setDeckGlEffectArray(s=>s.filter(u=>u!==t))}function e(t){a.setDeckGlLayerArray(s=>[...s,t])}function o(t){a.setDeckGlLayerArray(s=>s.filter(u=>u!==t))}return{addEffect:c,removeEffect:r,addLayer:e,removeLayer:o}}const x={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=a=>{const c=d();a={...x,...a};const{mapId:r,...e}=a,o=i.useMap({mapId:r,waitForLayer:e.beforeId}),t=n.useMemo(()=>e.data?new f.HexagonLayer({...e}):null,[e.beforeId,e.data,e.elevationScale,e.extruded,e.coverage,e.autoHighlight,e.material,e.radius,e.transitions]);return n.useEffect(()=>{if(!(!o.map||!t))return c.addLayer(t),()=>{c.removeLayer(t)}},[o.map,t]),l.jsx(l.Fragment,{})},D=a=>{const{mapId:c,...r}=a,e=i.useMap({mapId:c}),o=d(),t=n.useMemo(()=>r.data?new L.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(!(!e.map||!t))return o.addLayer(t),()=>{t&&o.removeLayer(t)}},[e.map,t]),l.jsx(l.Fragment,{})},M=a=>{const c=i.useMap({mapId:a.mapId,waitForLayer:a.beforeId}),r=d(),e=n.useMemo(()=>{const{mapId:o,...t}=a;return new g.ScenegraphLayer({...t})},[a]);return n.useEffect(()=>{if(!(!c.map||!e))return r.addLayer(e),()=>{e&&r.removeLayer(e)}},[c.map,e]),l.jsx(l.Fragment,{})};exports.DeckGlContext=y;exports.DeckGlContextProvider=v;exports.Ml3DTileLayer=D;exports.MlHexagonLayer=G;exports.MlSceneGraphLayer=M;exports.useDeckGl=d;
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 s, Fragment as u } from "react/jsx-runtime";
2
- import v, { useRef as g, useState as y, useEffect as i, useContext as G, useMemo as f } from "react";
3
- import { useMap as d } from "@mapcomponents/react-maplibre";
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 p } from "@deck.gl/aggregation-layers";
6
- import { Tile3DLayer as D } from "@deck.gl/geo-layers";
7
- import { ScenegraphLayer as H } from "@deck.gl/mesh-layers";
8
- const h = "deckgl-layer", L = v.createContext({}), w = ({ mapId: a, children: n }) => {
9
- const r = d({ mapId: a }), e = g(void 0), [o, t] = y([]), [c, l] = y([]);
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 e.current = new x({
13
- id: h,
12
+ return t.current = new x({
13
+ id: H,
14
14
  interleaved: !0
15
- }), r.map.addControl(e.current), () => {
16
- e.current && r.map?.removeControl(e.current), e.current = void 0;
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
- e.current && e.current.setProps({
20
- layers: [...o],
21
- effects: [...c]
19
+ t.current && t.current.setProps({
20
+ layers: [...c],
21
+ effects: [...o]
22
22
  });
23
- }, [o, c]);
24
- const k = {
25
- deckGlLayerArray: o,
26
- setDeckGlLayerArray: t,
27
- deckGlEffectArray: c,
23
+ }, [c, o]);
24
+ const v = {
25
+ deckGlLayerArray: c,
26
+ setDeckGlLayerArray: a,
27
+ deckGlEffectArray: o,
28
28
  setDeckGlEffectArray: l
29
29
  };
30
- return /* @__PURE__ */ s(L.Provider, { value: k, children: n });
30
+ return /* @__PURE__ */ d(k.Provider, { value: v, children: n });
31
31
  };
32
32
  function m() {
33
- const a = G(L);
34
- function n(t) {
35
- a.setDeckGlEffectArray((c) => [...c, t]);
33
+ const e = G(k);
34
+ function n(a) {
35
+ e.setDeckGlEffectArray((o) => [...o, a]);
36
36
  }
37
- function r(t) {
38
- a.setDeckGlEffectArray((c) => c.filter((l) => l !== t));
37
+ function r(a) {
38
+ e.setDeckGlEffectArray((o) => o.filter((l) => l !== a));
39
39
  }
40
- function e(t) {
41
- a.setDeckGlLayerArray((c) => [...c, t]);
40
+ function t(a) {
41
+ e.setDeckGlLayerArray((o) => [...o, a]);
42
42
  }
43
- function o(t) {
44
- a.setDeckGlLayerArray((c) => c.filter((l) => l !== t));
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: e,
50
- removeLayer: o
49
+ addLayer: t,
50
+ removeLayer: c
51
51
  };
52
52
  }
53
- const I = {
54
- type: p,
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 = (a) => {
74
- const n = m();
75
- a = {
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(() => e.data ? new p({
83
- ...e
84
- }) : null, [
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 (!(!o.map || !t))
95
+ if (!(!r.map || !t))
97
96
  return n.addLayer(t), () => {
98
97
  n.removeLayer(t);
99
98
  };
100
- }, [o.map, t]), /* @__PURE__ */ s(u, {});
101
- }, T = (a) => {
102
- const { mapId: n, ...r } = a, e = d({ mapId: n }), o = m(), t = f(() => r.data ? new D({
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 (!(!e.map || !t))
119
- return o.addLayer(t), () => {
120
- t && o.removeLayer(t);
117
+ if (!(!t.map || !a))
118
+ return c.addLayer(a), () => {
119
+ a && c.removeLayer(a);
121
120
  };
122
- }, [e.map, t]), /* @__PURE__ */ s(u, {});
123
- }, F = (a) => {
124
- const n = d({
125
- mapId: a.mapId,
126
- waitForLayer: a.beforeId
127
- }), r = m(), e = f(() => {
128
- const { mapId: o, ...t } = a;
129
- return new H({
130
- ...t
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
- }, [a]);
131
+ }, [e]);
133
132
  return i(() => {
134
- if (!(!n.map || !e))
135
- return r.addLayer(e), () => {
136
- e && r.removeLayer(e);
133
+ if (!(!n.map || !t))
134
+ return r.addLayer(t), () => {
135
+ t && r.removeLayer(t);
137
136
  };
138
- }, [n.map, e]), /* @__PURE__ */ s(u, {});
137
+ }, [n.map, t]), /* @__PURE__ */ d(s, {});
139
138
  };
140
139
  export {
141
- L as DeckGlContext,
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.9",
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.4",
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.9",
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.4",
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.9"
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: HexagonLayerProps.beforeId,
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
- HexagonLayerProps.beforeId,
67
- HexagonLayerProps.data,
68
- HexagonLayerProps.elevationScale,
69
- HexagonLayerProps.extruded,
70
- HexagonLayerProps.coverage,
71
- HexagonLayerProps.autoHighlight,
72
- HexagonLayerProps.material,
73
- HexagonLayerProps.radius,
74
- HexagonLayerProps.transitions,
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