@xyo-network/react-map 7.5.7 → 7.5.11
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/browser/Components/MapBox.d.ts.map +1 -1
- package/dist/browser/Components/MapBoxPoints.d.ts.map +1 -1
- package/dist/browser/MapBoxClasses/MapHeat.d.ts.map +1 -1
- package/dist/browser/MapBoxClasses/MapSettings.d.ts.map +1 -1
- package/dist/browser/hooks/useDynamicMapResize.d.ts.map +1 -1
- package/dist/browser/hooks/useQuadKeyPayloadsToFeatures.d.ts.map +1 -1
- package/dist/browser/index.mjs +481 -714
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +159 -36
- package/src/Components/AnimatedHeatMap.tsx +0 -61
- package/src/Components/AnimatedHeatMapLoaded.tsx +0 -61
- package/src/Components/FeaturesToLayersMap.ts +0 -8
- package/src/Components/HeatMapSettings.ts +0 -11
- package/src/Components/LayerAnimator.tsx +0 -119
- package/src/Components/Legend.tsx +0 -36
- package/src/Components/Legends/ColorGradient.tsx +0 -35
- package/src/Components/Legends/index.ts +0 -1
- package/src/Components/MapBox.stories.tsx +0 -92
- package/src/Components/MapBox.tsx +0 -79
- package/src/Components/MapBoxHeat.tsx +0 -19
- package/src/Components/MapBoxPoints.tsx +0 -99
- package/src/Components/MapSettingsComponents/Setting.tsx +0 -36
- package/src/Components/MapSettingsComponents/SettingsBox.tsx +0 -34
- package/src/Components/MapSettingsComponents/index.ts +0 -2
- package/src/Components/index.ts +0 -11
- package/src/Contexts/HeatMapInitializer/Context.ts +0 -7
- package/src/Contexts/HeatMapInitializer/Provider.tsx +0 -93
- package/src/Contexts/HeatMapInitializer/State.ts +0 -8
- package/src/Contexts/HeatMapInitializer/index.ts +0 -3
- package/src/Contexts/HeatMapInitializer/useHeatMapInitializer.tsx +0 -13
- package/src/Contexts/MapBoxInstance/Context.ts +0 -7
- package/src/Contexts/MapBoxInstance/Provider.tsx +0 -26
- package/src/Contexts/MapBoxInstance/State.ts +0 -8
- package/src/Contexts/MapBoxInstance/index.ts +0 -3
- package/src/Contexts/MapBoxInstance/useMapBoxInstance.tsx +0 -13
- package/src/Contexts/MapSettings/Context.ts +0 -7
- package/src/Contexts/MapSettings/Provider.tsx +0 -43
- package/src/Contexts/MapSettings/State.ts +0 -7
- package/src/Contexts/MapSettings/index.ts +0 -3
- package/src/Contexts/MapSettings/useMapSettings.tsx +0 -11
- package/src/Contexts/index.ts +0 -3
- package/src/Layers/Builders/LocationHeatMapLayerBuilder.ts +0 -36
- package/src/Layers/Builders/LocationHeatMapLayerBuilderAnimated.ts +0 -21
- package/src/Layers/Builders/LocationPointsMapLayerBuilder.ts +0 -17
- package/src/Layers/Builders/index.ts +0 -3
- package/src/Layers/CircleLayer.ts +0 -31
- package/src/Layers/Configs/HeatMapFillLayerConfig.ts +0 -13
- package/src/Layers/Configs/HeatMapLineLayerConfig.ts +0 -13
- package/src/Layers/Configs/HeatMapSymbolLayerConfig.ts +0 -18
- package/src/Layers/Configs/LocationPointLayerConfig.ts +0 -15
- package/src/Layers/Configs/index.ts +0 -4
- package/src/Layers/FillLayer.ts +0 -23
- package/src/Layers/LineLayer.ts +0 -24
- package/src/Layers/MapLayer.ts +0 -6
- package/src/Layers/SymbolLayer.ts +0 -23
- package/src/Layers/index.ts +0 -7
- package/src/MapBoxClasses/MapBase.ts +0 -45
- package/src/MapBoxClasses/MapHeat.ts +0 -184
- package/src/MapBoxClasses/MapPoints.ts +0 -39
- package/src/MapBoxClasses/MapSettings.ts +0 -132
- package/src/MapBoxClasses/index.ts +0 -4
- package/src/global.d.ts +0 -1
- package/src/hooks/index.ts +0 -3
- package/src/hooks/useDynamicMapResize.tsx +0 -43
- package/src/hooks/useDynamicPositioning.tsx +0 -68
- package/src/hooks/useQuadKeyPayloadsToFeatures.tsx +0 -54
- package/src/index.ts +0 -5
- package/src/lib/MapBoxBaseProps.ts +0 -20
- package/src/lib/index.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/react-map",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.11",
|
|
4
4
|
"description": "Common React library for all XYO projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xyo",
|
|
@@ -36,54 +36,177 @@
|
|
|
36
36
|
},
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
|
-
"module": "dist/browser/index.mjs",
|
|
40
|
-
"types": "dist/browser/index.d.ts",
|
|
41
39
|
"files": [
|
|
42
40
|
"dist",
|
|
43
|
-
"
|
|
41
|
+
"README.md"
|
|
44
42
|
],
|
|
45
43
|
"dependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@xylabs/react-flexbox": "~7.1.17",
|
|
49
|
-
"@xylabs/react-shared": "~7.1.17",
|
|
50
|
-
"@xylabs/react-theme": "~7.1.17",
|
|
51
|
-
"@xylabs/sdk-js": "~5.0.90",
|
|
52
|
-
"@xyo-network/react-archivist": "7.5.7",
|
|
53
|
-
"@xyo-network/react-map-model": "7.5.7",
|
|
54
|
-
"@xyo-network/sdk-geo": "~3.0.3",
|
|
55
|
-
"geojson": "~0.5.0",
|
|
56
|
-
"mapbox-gl": "~3.20.0"
|
|
44
|
+
"@xyo-network/react-archivist": "~7.5.11",
|
|
45
|
+
"@xyo-network/react-map-model": "~7.5.11"
|
|
57
46
|
},
|
|
58
47
|
"devDependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
48
|
+
"@bitauth/libauth": "~3.0.0",
|
|
49
|
+
"@emotion/react": "^11.14.0",
|
|
50
|
+
"@mui/icons-material": "^7.3.10",
|
|
51
|
+
"@mui/material": "^7.3.10",
|
|
52
|
+
"@mui/system": "^7.3.10",
|
|
53
|
+
"@mui/x-tree-view": "~8.27.2",
|
|
54
|
+
"@opentelemetry/api": "^1.9.1",
|
|
55
|
+
"@opentelemetry/sdk-trace-base": "^2.7.0",
|
|
56
|
+
"@scure/base": "~2.2.0",
|
|
57
|
+
"@scure/bip39": "~2.2.0",
|
|
58
|
+
"@storybook/react-vite": "~10.3.5",
|
|
59
|
+
"@types/geojson": "~7946.0.16",
|
|
60
|
+
"@types/node": "~25.6.0",
|
|
63
61
|
"@types/react": "^19.2.14",
|
|
64
|
-
"@xylabs/
|
|
65
|
-
"@xylabs/
|
|
66
|
-
"@xylabs/
|
|
67
|
-
"@xylabs/
|
|
68
|
-
"@xylabs/
|
|
69
|
-
"react": "
|
|
70
|
-
"react-
|
|
71
|
-
"react-
|
|
72
|
-
"
|
|
62
|
+
"@xylabs/geo": "^5.0.100",
|
|
63
|
+
"@xylabs/react-app-settings": "~7.1.20",
|
|
64
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
65
|
+
"@xylabs/react-button": "~7.1.20",
|
|
66
|
+
"@xylabs/react-crypto": "~7.1.20",
|
|
67
|
+
"@xylabs/react-dialogs": "~7.1.20",
|
|
68
|
+
"@xylabs/react-flexbox": "~7.1.20",
|
|
69
|
+
"@xylabs/react-hooks": "~7.1.20",
|
|
70
|
+
"@xylabs/react-identicon": "~7.1.20",
|
|
71
|
+
"@xylabs/react-link": "~7.1.20",
|
|
72
|
+
"@xylabs/react-number-status": "~7.1.20",
|
|
73
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
74
|
+
"@xylabs/react-quick-tip-button": "~7.1.20",
|
|
75
|
+
"@xylabs/react-select": "~7.1.20",
|
|
76
|
+
"@xylabs/react-shared": "~7.1.20",
|
|
77
|
+
"@xylabs/react-theme": "~7.1.20",
|
|
78
|
+
"@xylabs/sdk-js": "^5.0.100",
|
|
79
|
+
"@xylabs/threads": "~5.0.100",
|
|
80
|
+
"@xylabs/toolchain": "~7.11.9",
|
|
81
|
+
"@xylabs/tsconfig": "^7.11.9",
|
|
82
|
+
"@xylabs/tsconfig-dom": "^7.11.9",
|
|
83
|
+
"@xylabs/tsconfig-react": "~7.11.9",
|
|
84
|
+
"@xylabs/zod": "~5.0.100",
|
|
85
|
+
"@xyo-network/account": "~5.5.1",
|
|
86
|
+
"@xyo-network/account-model": "^5.5.1",
|
|
87
|
+
"@xyo-network/archivist-memory": "~5.5.5",
|
|
88
|
+
"@xyo-network/archivist-model": "^5.5.5",
|
|
89
|
+
"@xyo-network/boundwitness-builder": "^5.5.1",
|
|
90
|
+
"@xyo-network/boundwitness-model": "^5.5.1",
|
|
91
|
+
"@xyo-network/boundwitness-validator": "^5.5.1",
|
|
92
|
+
"@xyo-network/boundwitness-wrapper": "~5.5.1",
|
|
93
|
+
"@xyo-network/config-payload-plugin": "~5.5.1",
|
|
94
|
+
"@xyo-network/diviner-model": "^5.5.5",
|
|
95
|
+
"@xyo-network/manifest-model": "~5.5.1",
|
|
96
|
+
"@xyo-network/module-abstract": "^5.5.5",
|
|
97
|
+
"@xyo-network/module-model": "^5.5.5",
|
|
98
|
+
"@xyo-network/module-wrapper": "~5.5.5",
|
|
99
|
+
"@xyo-network/network": "~5.5.1",
|
|
100
|
+
"@xyo-network/node-memory": "~5.5.5",
|
|
101
|
+
"@xyo-network/node-model": "^5.5.5",
|
|
102
|
+
"@xyo-network/payload-builder": "^5.5.1",
|
|
103
|
+
"@xyo-network/payload-model": "^5.5.1",
|
|
104
|
+
"@xyo-network/query-payload-plugin": "~5.5.1",
|
|
105
|
+
"@xyo-network/sdk-geo": "~3.0.3",
|
|
106
|
+
"@xyo-network/wallet": "~5.5.1",
|
|
107
|
+
"@xyo-network/wallet-model": "^5.5.1",
|
|
108
|
+
"async-mutex": "^0.5.0",
|
|
109
|
+
"axios": "^1.15.2",
|
|
110
|
+
"bn.js": "^5.2.3",
|
|
111
|
+
"bowser": "^2.14.1",
|
|
112
|
+
"buffer": "^6.0.3",
|
|
113
|
+
"chalk": "^5.6.2",
|
|
114
|
+
"debug": "~4.4.3",
|
|
115
|
+
"esbuild": "~0.28.0",
|
|
116
|
+
"eslint": "^10.2.1",
|
|
117
|
+
"ethers": "^6.16.0",
|
|
118
|
+
"fast-deep-equal": "~3.1.3",
|
|
119
|
+
"geojson": "^0.5.0",
|
|
120
|
+
"hash-wasm": "~4.12.0",
|
|
121
|
+
"js-cookie": "~3.0.5",
|
|
122
|
+
"lru-cache": "^11.3.5",
|
|
123
|
+
"mapbox-gl": "^3.22.0",
|
|
124
|
+
"observable-fns": "~0.6.1",
|
|
125
|
+
"pako": "^2.1.0",
|
|
126
|
+
"react": "^19.2.5",
|
|
127
|
+
"react-dom": "^19.2.5",
|
|
128
|
+
"react-icons": "~5.6.0",
|
|
129
|
+
"react-router-dom": "^7.14.2",
|
|
130
|
+
"spark-md5": "~3.0.2",
|
|
131
|
+
"storybook": "^10.3.5",
|
|
73
132
|
"typescript": "^5.9.3",
|
|
74
|
-
"vite": "
|
|
133
|
+
"vite": "^8.0.10",
|
|
134
|
+
"wasm-feature-detect": "~1.8.0",
|
|
75
135
|
"zod": "^4.3.6"
|
|
76
136
|
},
|
|
77
137
|
"peerDependencies": {
|
|
78
|
-
"@
|
|
79
|
-
"@mui/material": "
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
138
|
+
"@emotion/react": "^11.14.0",
|
|
139
|
+
"@mui/icons-material": "^7.3.10",
|
|
140
|
+
"@mui/material": "^7.3.10",
|
|
141
|
+
"@mui/system": "^7.3.10",
|
|
142
|
+
"@mui/x-tree-view": "~8.27.2",
|
|
143
|
+
"@opentelemetry/api": "^1.9.1",
|
|
144
|
+
"@opentelemetry/sdk-trace-base": "^2.7.0",
|
|
145
|
+
"@scure/base": "~2.2.0",
|
|
146
|
+
"@scure/bip39": "~2.2.0",
|
|
147
|
+
"@xylabs/geo": "^5.0.100",
|
|
148
|
+
"@xylabs/react-app-settings": "~7.1.20",
|
|
149
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
150
|
+
"@xylabs/react-button": "~7.1.20",
|
|
151
|
+
"@xylabs/react-crypto": "~7.1.20",
|
|
152
|
+
"@xylabs/react-flexbox": "~7.1.20",
|
|
153
|
+
"@xylabs/react-hooks": "~7.1.20",
|
|
154
|
+
"@xylabs/react-identicon": "~7.1.20",
|
|
155
|
+
"@xylabs/react-link": "~7.1.20",
|
|
156
|
+
"@xylabs/react-number-status": "~7.1.20",
|
|
157
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
158
|
+
"@xylabs/react-quick-tip-button": "~7.1.20",
|
|
159
|
+
"@xylabs/react-select": "~7.1.20",
|
|
160
|
+
"@xylabs/react-shared": "~7.1.20",
|
|
161
|
+
"@xylabs/react-theme": "~7.1.20",
|
|
162
|
+
"@xylabs/sdk-js": "^5.0.100",
|
|
163
|
+
"@xylabs/tsconfig": "^7.11.9",
|
|
164
|
+
"@xylabs/tsconfig-dom": "^7.11.9",
|
|
165
|
+
"@xylabs/zod": "~5.0.100",
|
|
166
|
+
"@xyo-network/account": "~5.5.1",
|
|
167
|
+
"@xyo-network/account-model": "^5.5.1",
|
|
168
|
+
"@xyo-network/archivist-memory": "~5.5.5",
|
|
169
|
+
"@xyo-network/archivist-model": "^5.5.5",
|
|
170
|
+
"@xyo-network/boundwitness-builder": "^5.5.1",
|
|
171
|
+
"@xyo-network/boundwitness-model": "^5.5.1",
|
|
172
|
+
"@xyo-network/boundwitness-validator": "^5.5.1",
|
|
173
|
+
"@xyo-network/boundwitness-wrapper": "~5.5.1",
|
|
174
|
+
"@xyo-network/config-payload-plugin": "~5.5.1",
|
|
175
|
+
"@xyo-network/diviner-model": "^5.5.5",
|
|
176
|
+
"@xyo-network/manifest-model": "~5.5.1",
|
|
177
|
+
"@xyo-network/module-abstract": "^5.5.5",
|
|
178
|
+
"@xyo-network/module-model": "^5.5.5",
|
|
179
|
+
"@xyo-network/module-wrapper": "~5.5.5",
|
|
180
|
+
"@xyo-network/network": "~5.5.1",
|
|
181
|
+
"@xyo-network/node-memory": "~5.5.5",
|
|
182
|
+
"@xyo-network/node-model": "^5.5.5",
|
|
183
|
+
"@xyo-network/payload-builder": "^5.5.1",
|
|
184
|
+
"@xyo-network/payload-model": "^5.5.1",
|
|
185
|
+
"@xyo-network/query-payload-plugin": "~5.5.1",
|
|
186
|
+
"@xyo-network/sdk-geo": "~3.0.3",
|
|
187
|
+
"@xyo-network/wallet": "~5.5.1",
|
|
188
|
+
"@xyo-network/wallet-model": "^5.5.1",
|
|
189
|
+
"async-mutex": "^0.5.0",
|
|
190
|
+
"axios": "^1.15.2",
|
|
191
|
+
"bn.js": "^5.2.3",
|
|
192
|
+
"bowser": "^2.14.1",
|
|
193
|
+
"buffer": "^6.0.3",
|
|
194
|
+
"chalk": "^5.6.2",
|
|
195
|
+
"ethers": "^6.16.0",
|
|
196
|
+
"fast-deep-equal": "~3.1.3",
|
|
197
|
+
"js-cookie": "~3.0.5",
|
|
198
|
+
"lru-cache": "^11.3.5",
|
|
199
|
+
"mapbox-gl": "^3.22.0",
|
|
200
|
+
"pako": "^2.1.0",
|
|
201
|
+
"react": "^19.2.5",
|
|
202
|
+
"react-dom": "^19.2.5",
|
|
203
|
+
"react-icons": "~5.6.0",
|
|
204
|
+
"react-router-dom": "^7.14.2",
|
|
205
|
+
"spark-md5": "~3.0.2",
|
|
206
|
+
"zod": "^4.3.6"
|
|
84
207
|
},
|
|
85
208
|
"publishConfig": {
|
|
86
209
|
"access": "public"
|
|
87
210
|
},
|
|
88
211
|
"docs": "dist/docs.json"
|
|
89
|
-
}
|
|
212
|
+
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { useTheme } from '@mui/material'
|
|
2
|
-
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
-
import { darkenCss } from '@xylabs/react-theme'
|
|
4
|
-
import type { AnimatedHeatMapColorProps, MapSetting } from '@xyo-network/react-map-model'
|
|
5
|
-
import type { Feature, Polygon } from 'geojson'
|
|
6
|
-
import type { PropsWithChildren } from 'react'
|
|
7
|
-
import React, { useState } from 'react'
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
HeatMapInitializerProvider, MapBoxInstanceProvider, MapSettingsProvider,
|
|
11
|
-
} from '../Contexts/index.ts'
|
|
12
|
-
import type { MapLayer } from '../Layers/index.ts'
|
|
13
|
-
import { LocationHeatMapLayerBuilderAnimated, MapHeatConstants } from '../Layers/index.ts'
|
|
14
|
-
import { MapboxHeatFlexBox } from './MapBoxHeat.tsx'
|
|
15
|
-
|
|
16
|
-
export interface AnimatedHeatMapProps {
|
|
17
|
-
accessToken: string
|
|
18
|
-
animatedFeatureSets: Feature<Polygon>[][]
|
|
19
|
-
defaultMapSettings?: MapSetting
|
|
20
|
-
heatMapColorProps: AnimatedHeatMapColorProps
|
|
21
|
-
staticFeatureSet: Feature<Polygon>[]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const AnimatedHeatMap: React.FC<PropsWithChildren<AnimatedHeatMapProps>> = ({
|
|
25
|
-
accessToken,
|
|
26
|
-
animatedFeatureSets,
|
|
27
|
-
defaultMapSettings,
|
|
28
|
-
heatMapColorProps,
|
|
29
|
-
staticFeatureSet,
|
|
30
|
-
...props
|
|
31
|
-
}) => {
|
|
32
|
-
const theme = useTheme()
|
|
33
|
-
const {
|
|
34
|
-
staticMapColor, lowUsageColor, highUsageColor,
|
|
35
|
-
} = heatMapColorProps || {}
|
|
36
|
-
const localStaticMapColor = staticMapColor ?? theme.vars.palette.primary.light
|
|
37
|
-
|
|
38
|
-
const [layers] = useState<MapLayer[]>(() => [
|
|
39
|
-
LocationHeatMapLayerBuilderAnimated(localStaticMapColor, 0, 'static'),
|
|
40
|
-
LocationHeatMapLayerBuilderAnimated(lowUsageColor || localStaticMapColor, 0, 'animated'),
|
|
41
|
-
LocationHeatMapLayerBuilderAnimated(highUsageColor || darkenCss(localStaticMapColor, 0.9), 1, 'animated'),
|
|
42
|
-
])
|
|
43
|
-
|
|
44
|
-
return animatedFeatureSets?.length
|
|
45
|
-
? (
|
|
46
|
-
<MapBoxInstanceProvider>
|
|
47
|
-
<MapSettingsProvider defaultMapSettings={defaultMapSettings} debugLayerName={MapHeatConstants.LocationDebugLayerId}>
|
|
48
|
-
<HeatMapInitializerProvider
|
|
49
|
-
features={staticFeatureSet}
|
|
50
|
-
layers={[layers[0]]}
|
|
51
|
-
featureSets={animatedFeatureSets}
|
|
52
|
-
featureSetsLayers={layers.slice(1, 3)}
|
|
53
|
-
heatMapColorProps={heatMapColorProps}
|
|
54
|
-
>
|
|
55
|
-
<MapboxHeatFlexBox accessToken={accessToken} {...props}></MapboxHeatFlexBox>
|
|
56
|
-
</HeatMapInitializerProvider>
|
|
57
|
-
</MapSettingsProvider>
|
|
58
|
-
</MapBoxInstanceProvider>
|
|
59
|
-
)
|
|
60
|
-
: <FlexCol minHeight={160} minWidth={160} busy />
|
|
61
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Alert, AlertTitle } from '@mui/material'
|
|
2
|
-
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
3
|
-
import { FlexCol } from '@xylabs/react-flexbox'
|
|
4
|
-
import { useWeakArchivistFromNode, useWeakArchivistGet } from '@xyo-network/react-archivist'
|
|
5
|
-
import type { NetworkLocationHeatmapQuadkeyAnswerPayload } from '@xyo-network/react-map-model'
|
|
6
|
-
import {
|
|
7
|
-
AnimatedHeatMapSettings,
|
|
8
|
-
useFindHashes, useHeatMapColors,
|
|
9
|
-
} from '@xyo-network/react-map-model'
|
|
10
|
-
import type { Feature, Polygon } from 'geojson'
|
|
11
|
-
import React from 'react'
|
|
12
|
-
|
|
13
|
-
import { useQuadKeyPayloadsToFeatures } from '../hooks/index.ts'
|
|
14
|
-
import { AnimatedHeatMap } from './AnimatedHeatMap.tsx'
|
|
15
|
-
import { AnimatedHeatMapLegend } from './Legend.tsx'
|
|
16
|
-
|
|
17
|
-
export interface AnimatedHeatMapLoadedProps extends FlexBoxProps {
|
|
18
|
-
accessToken: string
|
|
19
|
-
archivistNameOrAddress: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const AnimatedHeatMapLoaded: React.FC<AnimatedHeatMapLoadedProps> = ({
|
|
23
|
-
accessToken, archivistNameOrAddress, ...props
|
|
24
|
-
}) => {
|
|
25
|
-
const hashes = useFindHashes()
|
|
26
|
-
const [archivist] = useWeakArchivistFromNode(archivistNameOrAddress)
|
|
27
|
-
const [payloads, xyoError] = useWeakArchivistGet<NetworkLocationHeatmapQuadkeyAnswerPayload>(archivist, hashes)
|
|
28
|
-
const { multipleFeatureSets } = useQuadKeyPayloadsToFeatures(payloads)
|
|
29
|
-
const { heatMapColorProps, legendProps } = useHeatMapColors()
|
|
30
|
-
|
|
31
|
-
const MapBoxHeatProps = {
|
|
32
|
-
flexGrow: 1,
|
|
33
|
-
legend: legendProps ? <AnimatedHeatMapLegend {...legendProps} /> : null,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<FlexCol alignItems="stretch" {...props}>
|
|
38
|
-
{xyoError
|
|
39
|
-
? (
|
|
40
|
-
<Alert sx={{ mt: 2 }}>
|
|
41
|
-
<AlertTitle>Error Loading Map</AlertTitle>
|
|
42
|
-
{xyoError.message ? `Error: ${xyoError.message}` : null}
|
|
43
|
-
You might try authenticating again.
|
|
44
|
-
</Alert>
|
|
45
|
-
)
|
|
46
|
-
: null}
|
|
47
|
-
{hashes === undefined
|
|
48
|
-
? <Alert>Missing answer hash for heat map query</Alert>
|
|
49
|
-
: (
|
|
50
|
-
<AnimatedHeatMap
|
|
51
|
-
accessToken={accessToken}
|
|
52
|
-
defaultMapSettings={AnimatedHeatMapSettings}
|
|
53
|
-
animatedFeatureSets={multipleFeatureSets.slice(1) as Feature<Polygon>[][]}
|
|
54
|
-
staticFeatureSet={multipleFeatureSets[0] as Feature<Polygon>[]}
|
|
55
|
-
heatMapColorProps={heatMapColorProps}
|
|
56
|
-
{...MapBoxHeatProps}
|
|
57
|
-
/>
|
|
58
|
-
)}
|
|
59
|
-
</FlexCol>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DefaultMapSettings } from '@xyo-network/react-map-model'
|
|
2
|
-
|
|
3
|
-
const HeatMapSettings = DefaultMapSettings()
|
|
4
|
-
const {
|
|
5
|
-
debugLayer, scrollToZoom, fitToPoints,
|
|
6
|
-
} = HeatMapSettings
|
|
7
|
-
debugLayer.hidden = false
|
|
8
|
-
scrollToZoom.value = true
|
|
9
|
-
fitToPoints.value = true
|
|
10
|
-
|
|
11
|
-
export { HeatMapSettings }
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { useInterval } from '@xylabs/react-shared'
|
|
2
|
-
import type { Map } from 'mapbox-gl'
|
|
3
|
-
import type { PropsWithChildren } from 'react'
|
|
4
|
-
import React, {
|
|
5
|
-
useCallback, useEffect, useMemo, useRef,
|
|
6
|
-
} from 'react'
|
|
7
|
-
|
|
8
|
-
import type { MapLayer } from '../Layers/index.ts'
|
|
9
|
-
import type { MapboxFlexBoxProps } from '../lib/index.ts'
|
|
10
|
-
|
|
11
|
-
export interface LayerAnimatorProps {
|
|
12
|
-
animateLayers?: boolean
|
|
13
|
-
layers: MapboxFlexBoxProps['layers']
|
|
14
|
-
layersInitialized: boolean
|
|
15
|
-
map: Map | undefined
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const timeIncrement = 2000
|
|
19
|
-
const animatedLayerCount = 3
|
|
20
|
-
|
|
21
|
-
export const LayerAnimator: React.FC<PropsWithChildren<LayerAnimatorProps>> = ({
|
|
22
|
-
animateLayers, children, layers, layersInitialized, map,
|
|
23
|
-
}) => {
|
|
24
|
-
const layerIndexQueue = useRef<number[]>([])
|
|
25
|
-
|
|
26
|
-
const fillLayers: MapLayer[] = useMemo(() => {
|
|
27
|
-
if (layers?.length && map && layersInitialized) {
|
|
28
|
-
return layers.filter((layer) => {
|
|
29
|
-
const fillLayer = layer.id.startsWith('location-fill')
|
|
30
|
-
if (fillLayer) {
|
|
31
|
-
map.setPaintProperty(layer.id, 'fill-opacity-transition', { delay: 0, duration: 4000 })
|
|
32
|
-
}
|
|
33
|
-
return fillLayer
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
return []
|
|
37
|
-
}, [layers, layersInitialized, map])
|
|
38
|
-
|
|
39
|
-
const incrementQueue = useCallback(
|
|
40
|
-
(index: number) => {
|
|
41
|
-
if (fillLayers[index]) {
|
|
42
|
-
layerIndexQueue.current.push(index)
|
|
43
|
-
} else {
|
|
44
|
-
layerIndexQueue.current.push(0)
|
|
45
|
-
}
|
|
46
|
-
return layerIndexQueue.current.at(-1)
|
|
47
|
-
},
|
|
48
|
-
[fillLayers],
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
const lastQueuedIndex = useCallback(() => {
|
|
52
|
-
const last = layerIndexQueue.current.at(-1)
|
|
53
|
-
if (last === undefined) {
|
|
54
|
-
incrementQueue(0)
|
|
55
|
-
return 0
|
|
56
|
-
} else {
|
|
57
|
-
return last
|
|
58
|
-
}
|
|
59
|
-
}, [incrementQueue])
|
|
60
|
-
|
|
61
|
-
const unshiftQueue = useCallback(() => {
|
|
62
|
-
layerIndexQueue.current.shift()
|
|
63
|
-
}, [])
|
|
64
|
-
|
|
65
|
-
const getNextLayer = useCallback(() => {
|
|
66
|
-
const nextLayer = fillLayers[lastQueuedIndex()]
|
|
67
|
-
incrementQueue(lastQueuedIndex() + 1)
|
|
68
|
-
return nextLayer
|
|
69
|
-
}, [fillLayers, incrementQueue, lastQueuedIndex])
|
|
70
|
-
|
|
71
|
-
const layerAnimateWorker = useCallback(
|
|
72
|
-
(layer: MapLayer) => {
|
|
73
|
-
if (layer) {
|
|
74
|
-
map?.setPaintProperty(layer.id, 'fill-opacity', 0.85)
|
|
75
|
-
setTimeout(() => {
|
|
76
|
-
map?.setPaintProperty(layer.id, 'fill-opacity', 0)
|
|
77
|
-
unshiftQueue()
|
|
78
|
-
}, timeIncrement * 2)
|
|
79
|
-
} else {
|
|
80
|
-
console.warn('tried to queue an empty layer')
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
[map, unshiftQueue],
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
//
|
|
87
|
-
const queueLayerAnimation = useCallback(() => {
|
|
88
|
-
const animatedLayers: MapLayer[] = []
|
|
89
|
-
|
|
90
|
-
for (let i = 0; i < animatedLayerCount; i++) {
|
|
91
|
-
animatedLayers.push(getNextLayer())
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
for (const [index, layer] of animatedLayers.entries()) {
|
|
95
|
-
if (index === 0) {
|
|
96
|
-
layerAnimateWorker(layer)
|
|
97
|
-
} else {
|
|
98
|
-
setTimeout(() => {
|
|
99
|
-
layerAnimateWorker(layer)
|
|
100
|
-
}, timeIncrement * index)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}, [getNextLayer, layerAnimateWorker])
|
|
104
|
-
|
|
105
|
-
// Run a single layer animation before the interval kicks in
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
|
|
108
|
-
queueLayerAnimation()
|
|
109
|
-
}
|
|
110
|
-
}, [animateLayers, fillLayers.length, layersInitialized, map, queueLayerAnimation])
|
|
111
|
-
|
|
112
|
-
useInterval(() => {
|
|
113
|
-
if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
|
|
114
|
-
queueLayerAnimation()
|
|
115
|
-
}
|
|
116
|
-
}, timeIncrement * animatedLayerCount)
|
|
117
|
-
|
|
118
|
-
return <>{children}</>
|
|
119
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useMediaQuery, useTheme } from '@mui/material'
|
|
2
|
-
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
-
import type { ColorGradientLegendProps } from '@xyo-network/react-map-model'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
import { ColorGradientLegend } from './Legends/index.ts'
|
|
7
|
-
|
|
8
|
-
const AnimatedHeatMapLegend: React.FC<ColorGradientLegendProps> = ({ ...legendProps }) => {
|
|
9
|
-
const {
|
|
10
|
-
startColor, endColor, startLabel, endLabel, heading, textColor,
|
|
11
|
-
} = legendProps
|
|
12
|
-
const theme = useTheme()
|
|
13
|
-
const isSmall = useMediaQuery(theme.breakpoints.down('sm'))
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<FlexCol position="absolute" bottom={0} right={0}>
|
|
17
|
-
<ColorGradientLegend
|
|
18
|
-
startColor={startColor}
|
|
19
|
-
endColor={endColor}
|
|
20
|
-
startLabel={startLabel}
|
|
21
|
-
endLabel={endLabel}
|
|
22
|
-
heading={heading}
|
|
23
|
-
textColor={textColor}
|
|
24
|
-
{...{
|
|
25
|
-
alignItems: 'stretch',
|
|
26
|
-
marginBottom: theme.spacing(4),
|
|
27
|
-
marginLeft: isSmall ? theme.spacing(3) : 0,
|
|
28
|
-
marginRight: isSmall ? theme.spacing(2) : theme.spacing(3),
|
|
29
|
-
width: isSmall ? '40vw' : theme.spacing(18),
|
|
30
|
-
}}
|
|
31
|
-
/>
|
|
32
|
-
</FlexCol>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { AnimatedHeatMapLegend }
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Typography, useTheme } from '@mui/material'
|
|
2
|
-
import { FlexCol, FlexRow } from '@xylabs/react-flexbox'
|
|
3
|
-
import type { ColorGradientLegendProps } from '@xyo-network/react-map-model'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
const ColorGradientLegend: React.FC<ColorGradientLegendProps> = ({
|
|
7
|
-
startColor, endColor, startLabel, endLabel, heading, textColor, ...props
|
|
8
|
-
}) => {
|
|
9
|
-
const theme = useTheme()
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<FlexCol {...props}>
|
|
13
|
-
<Typography mb={theme.spacing(0.25)} color={textColor} variant="caption" textAlign="center">
|
|
14
|
-
{heading}
|
|
15
|
-
</Typography>
|
|
16
|
-
<FlexCol flexGrow={1} alignItems="stretch" paddingX={theme.spacing(1)} mb={theme.spacing(0.25)}>
|
|
17
|
-
<FlexCol
|
|
18
|
-
height={theme.spacing(0.75)}
|
|
19
|
-
border={`1px solid ${textColor}`}
|
|
20
|
-
sx={{ backgroundImage: `linear-gradient(to right, ${startColor},${endColor})` }}
|
|
21
|
-
/>
|
|
22
|
-
</FlexCol>
|
|
23
|
-
<FlexRow flexGrow={1} justifyContent="space-between">
|
|
24
|
-
<Typography color={textColor} variant="caption">
|
|
25
|
-
{startLabel}
|
|
26
|
-
</Typography>
|
|
27
|
-
<Typography color={textColor} variant="caption">
|
|
28
|
-
{endLabel}
|
|
29
|
-
</Typography>
|
|
30
|
-
</FlexRow>
|
|
31
|
-
</FlexCol>
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { ColorGradientLegend }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ColorGradient.tsx'
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
2
|
-
import { Button } from '@mui/material'
|
|
3
|
-
import type {
|
|
4
|
-
Decorator, Meta, StoryFn,
|
|
5
|
-
} from '@storybook/react-vite'
|
|
6
|
-
import { FlexGrowCol } from '@xylabs/react-flexbox'
|
|
7
|
-
import { DefaultMapSettings } from '@xyo-network/react-map-model'
|
|
8
|
-
import React, { useRef } from 'react'
|
|
9
|
-
|
|
10
|
-
import { MapBoxInstanceProvider, MapSettingsProvider } from '../Contexts/index.ts'
|
|
11
|
-
import { MapBox } from './MapBox.tsx'
|
|
12
|
-
import { MapSettingsBox } from './MapSettingsComponents/index.ts'
|
|
13
|
-
|
|
14
|
-
const WithMapboxProviders: Decorator = (Story, props) => {
|
|
15
|
-
const defaultSettings = DefaultMapSettings()
|
|
16
|
-
defaultSettings.enableControls.hidden = false
|
|
17
|
-
defaultSettings.scrollToZoom.hidden = false
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<MapBoxInstanceProvider>
|
|
21
|
-
<MapSettingsProvider defaultMapSettings={defaultSettings}>
|
|
22
|
-
<Story {...props} />
|
|
23
|
-
</MapSettingsProvider>
|
|
24
|
-
</MapBoxInstanceProvider>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const WithMapSettingsDecorator: Decorator = (Story, args) => {
|
|
29
|
-
return (
|
|
30
|
-
<>
|
|
31
|
-
<Story {...args} />
|
|
32
|
-
<MapSettingsBox developerMode={true} />
|
|
33
|
-
</>
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default {
|
|
38
|
-
args: { accessToken: import.meta.env.VITE_MAPBOX_TOKEN },
|
|
39
|
-
component: MapBox,
|
|
40
|
-
decorators: [WithMapboxProviders],
|
|
41
|
-
parameters: { docs: { page: null } },
|
|
42
|
-
title: 'map/Mapbox',
|
|
43
|
-
} as Meta
|
|
44
|
-
|
|
45
|
-
const Template: StoryFn<typeof MapBox> = (args) => {
|
|
46
|
-
return (
|
|
47
|
-
<div style={{
|
|
48
|
-
minHeight: 'calc(100vh - 2rem)', minWidth: '100%', position: 'relative', transition: 'min-width 300ms ease',
|
|
49
|
-
}}
|
|
50
|
-
>
|
|
51
|
-
<MapBox {...args} />
|
|
52
|
-
</div>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const ContainerResizeTemplate: StoryFn<typeof MapBox> = (args) => {
|
|
57
|
-
const containerRef = useRef<HTMLDivElement | null>(null)
|
|
58
|
-
const handleClick = () => {
|
|
59
|
-
if (containerRef.current) {
|
|
60
|
-
const containerWidth = containerRef.current.style.minWidth
|
|
61
|
-
containerRef.current.style.minWidth = containerWidth === '100%' ? '50%' : '100%'
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<FlexGrowCol rowGap={2} alignItems="start">
|
|
67
|
-
<Button variant="contained" sx={{ my: 1 }} onClick={handleClick}>
|
|
68
|
-
Toggle Container minWidth
|
|
69
|
-
</Button>
|
|
70
|
-
<div
|
|
71
|
-
ref={containerRef}
|
|
72
|
-
style={{
|
|
73
|
-
minHeight: 'calc(100vh - 2rem)', minWidth: '100%', position: 'relative', transition: 'min-width 300ms ease',
|
|
74
|
-
}}
|
|
75
|
-
>
|
|
76
|
-
<MapBox {...args} />
|
|
77
|
-
</div>
|
|
78
|
-
</FlexGrowCol>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const Default = Template.bind({})
|
|
83
|
-
Default.args = {}
|
|
84
|
-
|
|
85
|
-
const WithContainerResize = ContainerResizeTemplate.bind({})
|
|
86
|
-
|
|
87
|
-
const WithMapSettings = Template.bind({})
|
|
88
|
-
WithMapSettings.decorators = [WithMapSettingsDecorator]
|
|
89
|
-
|
|
90
|
-
export {
|
|
91
|
-
Default, WithContainerResize, WithMapSettings,
|
|
92
|
-
}
|