@accelint/map-toolkit 0.3.0 → 0.4.0
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/CHANGELOG.md +20 -0
- package/catalog-info.yaml +5 -5
- package/dist/cursor-coordinates/index.d.ts +14 -3
- package/dist/cursor-coordinates/index.js +16 -3
- package/dist/cursor-coordinates/use-cursor-coordinates.d.ts +20 -6
- package/dist/cursor-coordinates/use-cursor-coordinates.js +247 -128
- package/dist/cursor-coordinates/use-cursor-coordinates.js.map +1 -1
- package/dist/deckgl/base-map/constants.d.ts +14 -12
- package/dist/deckgl/base-map/constants.js +26 -12
- package/dist/deckgl/base-map/constants.js.map +1 -1
- package/dist/deckgl/base-map/events.d.ts +6 -4
- package/dist/deckgl/base-map/events.js +18 -4
- package/dist/deckgl/base-map/events.js.map +1 -1
- package/dist/deckgl/base-map/index.d.ts +45 -18
- package/dist/deckgl/base-map/index.js +216 -148
- package/dist/deckgl/base-map/index.js.map +1 -1
- package/dist/deckgl/base-map/provider.d.ts +48 -32
- package/dist/deckgl/base-map/provider.js +122 -11
- package/dist/deckgl/base-map/provider.js.map +1 -1
- package/dist/deckgl/base-map/types.d.ts +49 -39
- package/dist/deckgl/base-map/types.js +11 -2
- package/dist/deckgl/index.d.ts +18 -13
- package/dist/deckgl/index.js +19 -6
- package/dist/deckgl/symbol-layer/fiber.d.ts +21 -10
- package/dist/deckgl/symbol-layer/fiber.js +18 -3
- package/dist/deckgl/symbol-layer/fiber.js.map +1 -1
- package/dist/deckgl/symbol-layer/index.d.ts +68 -54
- package/dist/deckgl/symbol-layer/index.js +105 -85
- package/dist/deckgl/symbol-layer/index.js.map +1 -1
- package/dist/deckgl/text-layer/character-sets.d.ts +19 -17
- package/dist/deckgl/text-layer/character-sets.js +40 -19
- package/dist/deckgl/text-layer/character-sets.js.map +1 -1
- package/dist/deckgl/text-layer/default-settings.d.ts +16 -2
- package/dist/deckgl/text-layer/default-settings.js +42 -18
- package/dist/deckgl/text-layer/default-settings.js.map +1 -1
- package/dist/deckgl/text-layer/fiber.d.ts +38 -27
- package/dist/deckgl/text-layer/fiber.js +18 -3
- package/dist/deckgl/text-layer/fiber.js.map +1 -1
- package/dist/deckgl/text-layer/index.d.ts +39 -25
- package/dist/deckgl/text-layer/index.js +47 -29
- package/dist/deckgl/text-layer/index.js.map +1 -1
- package/dist/decorators/deckgl.d.ts +16 -2
- package/dist/decorators/deckgl.js +25 -7
- package/dist/decorators/deckgl.js.map +1 -1
- package/dist/map-cursor/events.d.ts +16 -0
- package/dist/map-cursor/events.js +27 -0
- package/dist/map-cursor/events.js.map +1 -0
- package/dist/map-cursor/index.d.ts +17 -0
- package/dist/map-cursor/index.js +18 -0
- package/dist/map-cursor/store.d.ts +93 -0
- package/dist/map-cursor/store.js +351 -0
- package/dist/map-cursor/store.js.map +1 -0
- package/dist/map-cursor/types.d.ts +81 -0
- package/dist/map-cursor/types.js +12 -0
- package/dist/map-cursor/use-map-cursor.d.ts +99 -0
- package/dist/map-cursor/use-map-cursor.js +116 -0
- package/dist/map-cursor/use-map-cursor.js.map +1 -0
- package/dist/map-mode/events.d.ts +11 -9
- package/dist/map-mode/events.js +43 -9
- package/dist/map-mode/events.js.map +1 -1
- package/dist/map-mode/index.d.ts +17 -6
- package/dist/map-mode/index.js +18 -5
- package/dist/map-mode/store.d.ts +26 -3
- package/dist/map-mode/store.js +329 -265
- package/dist/map-mode/store.js.map +1 -1
- package/dist/map-mode/types.d.ts +49 -35
- package/dist/map-mode/types.js +11 -2
- package/dist/map-mode/use-map-mode.d.ts +21 -7
- package/dist/map-mode/use-map-mode.js +66 -23
- package/dist/map-mode/use-map-mode.js.map +1 -1
- package/dist/maplibre/constants.d.ts +10 -8
- package/dist/maplibre/constants.js +22 -8
- package/dist/maplibre/constants.js.map +1 -1
- package/dist/maplibre/hooks/use-maplibre.d.ts +17 -2
- package/dist/maplibre/hooks/use-maplibre.js +77 -31
- package/dist/maplibre/hooks/use-maplibre.js.map +1 -1
- package/dist/maplibre/index.d.ts +15 -3
- package/dist/maplibre/index.js +17 -4
- package/dist/viewport/constants.d.ts +8 -6
- package/dist/viewport/constants.js +20 -6
- package/dist/viewport/constants.js.map +1 -1
- package/dist/viewport/index.d.ts +18 -13
- package/dist/viewport/index.js +19 -6
- package/dist/viewport/types.d.ts +27 -17
- package/dist/viewport/types.js +11 -2
- package/dist/viewport/use-viewport-state.d.ts +29 -14
- package/dist/viewport/use-viewport-state.js +200 -87
- package/dist/viewport/use-viewport-state.js.map +1 -1
- package/dist/viewport/utils.d.ts +25 -10
- package/dist/viewport/utils.js +67 -37
- package/dist/viewport/utils.js.map +1 -1
- package/dist/viewport/viewport-size.d.ts +27 -15
- package/dist/viewport/viewport-size.js +54 -11
- package/dist/viewport/viewport-size.js.map +1 -1
- package/package.json +54 -27
- package/dist/cursor-coordinates/index.js.map +0 -1
- package/dist/deckgl/base-map/types.js.map +0 -1
- package/dist/deckgl/index.js.map +0 -1
- package/dist/map-mode/index.js.map +0 -1
- package/dist/map-mode/types.js.map +0 -1
- package/dist/maplibre/index.js.map +0 -1
- package/dist/metafile-esm.json +0 -1
- package/dist/viewport/index.js.map +0 -1
- package/dist/viewport/types.js.map +0 -1
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
//#region src/deckgl/base-map/constants.d.ts
|
|
1
2
|
declare const BASE_MAP_STYLE = "https://tiles.basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json";
|
|
2
3
|
declare const PARAMETERS: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
depthWriteEnabled: boolean;
|
|
5
|
+
depthCompare: string;
|
|
6
|
+
depthBias: number;
|
|
7
|
+
blend: boolean;
|
|
8
|
+
depthTest: boolean;
|
|
9
|
+
blendColorSrcFactor: string;
|
|
10
|
+
blendColorDstFactor: string;
|
|
11
|
+
blendAlphaSrcFactor: string;
|
|
12
|
+
blendAlphaDstFactor: string;
|
|
13
|
+
blendColorOperation: string;
|
|
14
|
+
blendAlphaOperation: string;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
//#endregion
|
|
16
17
|
export { BASE_MAP_STYLE, PARAMETERS };
|
|
18
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1,18 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
//#region src/deckgl/base-map/constants.ts
|
|
1
15
|
const BASE_MAP_STYLE = "https://tiles.basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json";
|
|
2
16
|
const PARAMETERS = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
depthWriteEnabled: true,
|
|
18
|
+
depthCompare: "always",
|
|
19
|
+
depthBias: 0,
|
|
20
|
+
blend: true,
|
|
21
|
+
depthTest: false,
|
|
22
|
+
blendColorSrcFactor: "src-alpha",
|
|
23
|
+
blendColorDstFactor: "one-minus-src-alpha",
|
|
24
|
+
blendAlphaSrcFactor: "one",
|
|
25
|
+
blendAlphaDstFactor: "one-minus-src-alpha",
|
|
26
|
+
blendColorOperation: "add",
|
|
27
|
+
blendAlphaOperation: "add"
|
|
14
28
|
};
|
|
15
29
|
|
|
30
|
+
//#endregion
|
|
16
31
|
export { BASE_MAP_STYLE, PARAMETERS };
|
|
17
|
-
//# sourceMappingURL=constants.js.map
|
|
18
32
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/deckgl/base-map/constants.ts"],"sourcesContent":["// __private-exports\n/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const BASE_MAP_STYLE =\n 'https://tiles.basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json';\n\nexport const PARAMETERS = {\n depthWriteEnabled: true,\n depthCompare: 'always',\n depthBias: 0,\n blend: true,\n depthTest: false,\n blendColorSrcFactor: 'src-alpha',\n blendColorDstFactor: 'one-minus-src-alpha',\n blendAlphaSrcFactor: 'one',\n blendAlphaDstFactor: 'one-minus-src-alpha',\n blendColorOperation: 'add',\n blendAlphaOperation: 'add',\n};\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,iBACX;AAEF,MAAa,aAAa;CACxB,mBAAmB;CACnB,cAAc;CACd,WAAW;CACX,OAAO;CACP,WAAW;CACX,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CACtB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
//#region src/deckgl/base-map/events.d.ts
|
|
1
2
|
declare const MapEventsNamespace = "map";
|
|
2
3
|
declare const MapEvents: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
readonly click: "map:click";
|
|
5
|
+
readonly hover: "map:hover";
|
|
6
|
+
readonly viewport: "map:viewport";
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
+
//#endregion
|
|
8
9
|
export { MapEvents, MapEventsNamespace };
|
|
10
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
//#region src/deckgl/base-map/events.ts
|
|
1
15
|
const MapEventsNamespace = "map";
|
|
2
16
|
const MapEvents = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
17
|
+
click: `${MapEventsNamespace}:click`,
|
|
18
|
+
hover: `${MapEventsNamespace}:hover`,
|
|
19
|
+
viewport: `${MapEventsNamespace}:viewport`
|
|
6
20
|
};
|
|
7
21
|
|
|
22
|
+
//#endregion
|
|
8
23
|
export { MapEvents, MapEventsNamespace };
|
|
9
|
-
//# sourceMappingURL=events.js.map
|
|
10
24
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"events.js","names":[],"sources":["../../../src/deckgl/base-map/events.ts"],"sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const MapEventsNamespace = 'map';\n\nexport const MapEvents = {\n click: `${MapEventsNamespace}:click`,\n hover: `${MapEventsNamespace}:hover`,\n viewport: `${MapEventsNamespace}:viewport`,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAa,qBAAqB;AAElC,MAAa,YAAY;CACvB,OAAO,GAAG,mBAAmB;CAC7B,OAAO,GAAG,mBAAmB;CAC7B,UAAU,GAAG,mBAAmB;CACjC"}
|
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
4
12
|
|
|
13
|
+
import { UniqueId } from "@accelint/core";
|
|
14
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
15
|
+
import { DeckglProps } from "@deckgl-fiber-renderer/types";
|
|
16
|
+
|
|
17
|
+
//#region src/deckgl/base-map/index.d.ts
|
|
5
18
|
/**
|
|
6
19
|
* Props for the BaseMap component.
|
|
7
20
|
* Extends all Deck.gl props and adds additional map-specific properties.
|
|
8
21
|
*/
|
|
9
22
|
type BaseMapProps = DeckglProps & {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
/** Optional CSS class name to apply to the map container element */
|
|
24
|
+
className?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Unique identifier for this map instance (required).
|
|
27
|
+
*
|
|
28
|
+
* Used to isolate map mode state between multiple map instances (e.g., main map vs minimap).
|
|
29
|
+
* This should be a UUID generated using `uuid()` from `@accelint/core`.
|
|
30
|
+
*
|
|
31
|
+
* The same id should be passed to `useMapMode()` when accessing map mode state
|
|
32
|
+
* from components rendered outside of the BaseMap's children (i.e., as siblings).
|
|
33
|
+
*/
|
|
34
|
+
id: UniqueId;
|
|
22
35
|
};
|
|
23
36
|
/**
|
|
24
37
|
* A React component that provides a Deck.gl-powered base map with MapLibre GL integration.
|
|
@@ -93,6 +106,20 @@ type BaseMapProps = DeckglProps & {
|
|
|
93
106
|
* }
|
|
94
107
|
* ```
|
|
95
108
|
*/
|
|
96
|
-
declare function BaseMap({
|
|
97
|
-
|
|
98
|
-
|
|
109
|
+
declare function BaseMap({
|
|
110
|
+
id,
|
|
111
|
+
className,
|
|
112
|
+
children,
|
|
113
|
+
controller,
|
|
114
|
+
interleaved,
|
|
115
|
+
parameters,
|
|
116
|
+
useDevicePixels,
|
|
117
|
+
widgets: widgetsProp,
|
|
118
|
+
onClick,
|
|
119
|
+
onHover,
|
|
120
|
+
onViewStateChange,
|
|
121
|
+
...rest
|
|
122
|
+
}: BaseMapProps): react_jsx_runtime0.JSX.Element;
|
|
123
|
+
//#endregion
|
|
124
|
+
export { BaseMap, BaseMapProps };
|
|
125
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,153 +1,221 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
13
|
+
|
|
14
|
+
'use client';
|
|
15
|
+
|
|
16
|
+
import { MapEvents } from "./events.js";
|
|
17
|
+
import { getCursor } from "../../map-cursor/store.js";
|
|
18
|
+
import { MapProvider } from "./provider.js";
|
|
19
|
+
import { INITIAL_VIEW_STATE } from "../../maplibre/constants.js";
|
|
20
|
+
import { useMapLibre } from "../../maplibre/hooks/use-maplibre.js";
|
|
21
|
+
import { BASE_MAP_STYLE, PARAMETERS } from "./constants.js";
|
|
22
|
+
import { useCallback, useId, useMemo } from "react";
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
import { useEffectEvent, useEmit } from "@accelint/bus/react";
|
|
25
|
+
import { Deckgl, useDeckgl } from "@deckgl-fiber-renderer/dom";
|
|
26
|
+
|
|
27
|
+
//#region src/deckgl/base-map/index.tsx
|
|
28
|
+
/**
|
|
29
|
+
* Serializes PickingInfo for event bus transmission.
|
|
30
|
+
* Omits viewport, layer, and sourceLayer (contain functions) but preserves layer IDs.
|
|
31
|
+
*/
|
|
32
|
+
function serializePickingInfo(info) {
|
|
33
|
+
const { viewport, layer, sourceLayer, ...infoRest } = info;
|
|
34
|
+
return {
|
|
35
|
+
layerId: layer?.id,
|
|
36
|
+
sourceLayerId: sourceLayer?.id,
|
|
37
|
+
...infoRest
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function serializeMjolnirEvent(event) {
|
|
41
|
+
const { stopImmediatePropagation, stopPropagation, preventDefault, srcEvent, rootElement, target, ...rest } = event;
|
|
42
|
+
if ("changedPointers" in rest) {
|
|
43
|
+
const { changedPointers, pointers, ...gestureRest } = rest;
|
|
44
|
+
return gestureRest;
|
|
45
|
+
}
|
|
46
|
+
return rest;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A React component that provides a Deck.gl-powered base map with MapLibre GL integration.
|
|
50
|
+
*
|
|
51
|
+
* This component serves as the foundation for building interactive map applications with
|
|
52
|
+
* support for click and hover events through a centralized event bus. It integrates
|
|
53
|
+
* Deck.gl for 3D visualizations with MapLibre GL for the base map tiles.
|
|
54
|
+
*
|
|
55
|
+
* **Map Mode Integration**: BaseMap automatically creates a `MapProvider` internally,
|
|
56
|
+
* which sets up the map mode state management for this instance.
|
|
57
|
+
* - **Children**: Only Deck.gl layer components can be rendered as children. Custom Deck.gl
|
|
58
|
+
* layers can use `useMapMode()` without parameters to access context.
|
|
59
|
+
* - **Siblings**: UI components (buttons, toolbars, etc.) must be rendered as siblings
|
|
60
|
+
* and pass `id` to `useMapMode(id)`.
|
|
61
|
+
*
|
|
62
|
+
* **Event Bus**: Click and hover events are emitted through the event bus with the `id`
|
|
63
|
+
* included in the payload, allowing multiple map instances to coexist without interference.
|
|
64
|
+
*
|
|
65
|
+
* @param props - Component props including id (required), className, onClick, onHover, and all Deck.gl props
|
|
66
|
+
* @returns A map component with Deck.gl and MapLibre GL integration
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* Basic usage with id (recommended: module-level constant):
|
|
70
|
+
* ```tsx
|
|
71
|
+
* import { BaseMap } from '@accelint/map-toolkit/deckgl';
|
|
72
|
+
* import { View } from '@deckgl-fiber-renderer/dom';
|
|
73
|
+
* import { uuid } from '@accelint/core';
|
|
74
|
+
*
|
|
75
|
+
* // Create id at module level for stability and easy sharing
|
|
76
|
+
* const MAIN_MAP_ID = uuid();
|
|
77
|
+
*
|
|
78
|
+
* export function MapView() {
|
|
79
|
+
* return (
|
|
80
|
+
* <BaseMap className="w-full h-full" id={MAIN_MAP_ID}>
|
|
81
|
+
* <View id="main" controller />
|
|
82
|
+
* </BaseMap>
|
|
83
|
+
* );
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* With map mode and event handlers (module-level constant for sharing):
|
|
89
|
+
* ```tsx
|
|
90
|
+
* import { BaseMap } from '@accelint/map-toolkit/deckgl';
|
|
91
|
+
* import { useMapMode } from '@accelint/map-toolkit/map-mode';
|
|
92
|
+
* import { uuid } from '@accelint/core';
|
|
93
|
+
* import type { PickingInfo } from '@deck.gl/core';
|
|
94
|
+
* import type { MjolnirGestureEvent } from 'mjolnir.js';
|
|
95
|
+
*
|
|
96
|
+
* // Module-level constant - stable and shareable across all components
|
|
97
|
+
* const MAIN_MAP_ID = uuid();
|
|
98
|
+
*
|
|
99
|
+
* function Toolbar() {
|
|
100
|
+
* // Access map mode using the shared id
|
|
101
|
+
* const { mode, requestModeChange } = useMapMode(MAIN_MAP_ID);
|
|
102
|
+
* return <div>Current mode: {mode}</div>;
|
|
103
|
+
* }
|
|
104
|
+
*
|
|
105
|
+
* export function InteractiveMap() {
|
|
106
|
+
* const handleClick = (info: PickingInfo, event: MjolnirGestureEvent) => {
|
|
107
|
+
* console.log('Clicked:', info.object);
|
|
108
|
+
* };
|
|
109
|
+
*
|
|
110
|
+
* return (
|
|
111
|
+
* <div className="relative w-full h-full">
|
|
112
|
+
* <BaseMap className="absolute inset-0" id={MAIN_MAP_ID} onClick={handleClick}>
|
|
113
|
+
* <View id="main" controller />
|
|
114
|
+
* </BaseMap>
|
|
115
|
+
* <Toolbar />
|
|
116
|
+
* </div>
|
|
117
|
+
* );
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
function BaseMap({ id, className, children, controller = true, interleaved = true, parameters = {}, useDevicePixels = false, widgets: widgetsProp = [], onClick, onHover, onViewStateChange, ...rest }) {
|
|
122
|
+
const deckglInstance = useDeckgl();
|
|
123
|
+
const container = useId();
|
|
124
|
+
useMapLibre(deckglInstance, BASE_MAP_STYLE, useMemo(() => ({
|
|
125
|
+
container,
|
|
126
|
+
center: [INITIAL_VIEW_STATE.longitude, INITIAL_VIEW_STATE.latitude],
|
|
127
|
+
zoom: INITIAL_VIEW_STATE.zoom,
|
|
128
|
+
doubleClickZoom: false,
|
|
129
|
+
dragRotate: false,
|
|
130
|
+
pitchWithRotate: false,
|
|
131
|
+
rollEnabled: false,
|
|
132
|
+
attributionControl: { compact: true }
|
|
133
|
+
}), [container]));
|
|
134
|
+
const emitClick = useEmit(MapEvents.click);
|
|
135
|
+
const emitHover = useEmit(MapEvents.hover);
|
|
136
|
+
const emitViewport = useEmit(MapEvents.viewport);
|
|
137
|
+
const handleClick = useCallback((info, event) => {
|
|
138
|
+
onClick?.(info, event);
|
|
139
|
+
emitClick({
|
|
140
|
+
info: serializePickingInfo(info),
|
|
141
|
+
event: serializeMjolnirEvent(event),
|
|
142
|
+
id
|
|
143
|
+
});
|
|
144
|
+
}, [
|
|
145
|
+
emitClick,
|
|
146
|
+
id,
|
|
147
|
+
onClick
|
|
148
|
+
]);
|
|
149
|
+
const handleHover = useCallback((info, event) => {
|
|
150
|
+
onHover?.(info, event);
|
|
151
|
+
emitHover({
|
|
152
|
+
info: serializePickingInfo(info),
|
|
153
|
+
event: serializeMjolnirEvent(event),
|
|
154
|
+
id
|
|
155
|
+
});
|
|
156
|
+
}, [
|
|
157
|
+
emitHover,
|
|
158
|
+
id,
|
|
159
|
+
onHover
|
|
160
|
+
]);
|
|
161
|
+
const handleGetCursor = useCallback(() => {
|
|
162
|
+
return getCursor(id);
|
|
163
|
+
}, [id]);
|
|
164
|
+
const handleViewStateChange = useEffectEvent((params) => {
|
|
165
|
+
onViewStateChange?.(params);
|
|
166
|
+
const { viewId, viewState: { latitude, longitude, zoom } } = params;
|
|
167
|
+
const viewport = deckglInstance._deck.getViewports()?.find((vp) => vp.id === viewId);
|
|
168
|
+
emitViewport({
|
|
169
|
+
id,
|
|
170
|
+
bounds: viewport?.getBounds(),
|
|
171
|
+
latitude,
|
|
172
|
+
longitude,
|
|
173
|
+
zoom,
|
|
174
|
+
width: viewport?.width ?? 0,
|
|
175
|
+
height: viewport?.height ?? 0
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
const handleLoad = useEffectEvent(() => {
|
|
179
|
+
deckglInstance._deck.getViewports().forEach((vp) => {
|
|
180
|
+
handleViewStateChange({
|
|
181
|
+
viewId: vp.id,
|
|
182
|
+
viewState: {
|
|
183
|
+
latitude: vp.latitude,
|
|
184
|
+
longitude: vp.longitude,
|
|
185
|
+
zoom: vp.zoom,
|
|
186
|
+
id: vp.id,
|
|
187
|
+
bounds: vp.getBounds(),
|
|
188
|
+
width: vp.width,
|
|
189
|
+
height: vp.height
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
return /* @__PURE__ */ jsx("div", {
|
|
195
|
+
id: container,
|
|
196
|
+
className,
|
|
197
|
+
children: /* @__PURE__ */ jsx(MapProvider, {
|
|
198
|
+
id,
|
|
199
|
+
children: /* @__PURE__ */ jsx(Deckgl, {
|
|
200
|
+
...rest,
|
|
201
|
+
controller,
|
|
202
|
+
interleaved,
|
|
203
|
+
useDevicePixels,
|
|
204
|
+
onClick: handleClick,
|
|
205
|
+
onHover: handleHover,
|
|
206
|
+
onLoad: handleLoad,
|
|
207
|
+
onViewStateChange: handleViewStateChange,
|
|
208
|
+
getCursor: handleGetCursor,
|
|
209
|
+
parameters: {
|
|
210
|
+
...PARAMETERS,
|
|
211
|
+
...parameters
|
|
212
|
+
},
|
|
213
|
+
children
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
});
|
|
149
217
|
}
|
|
150
218
|
|
|
219
|
+
//#endregion
|
|
151
220
|
export { BaseMap };
|
|
152
|
-
//# sourceMappingURL=index.js.map
|
|
153
221
|
//# sourceMappingURL=index.js.map
|