@xyo-network/react-map 2.52.0 → 2.54.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/dist/cjs/Colors/{XyoMapColorProps.js → MapColorProps.js} +1 -1
- package/dist/cjs/Colors/MapColorProps.js.map +1 -0
- package/dist/cjs/Colors/index.js +1 -1
- package/dist/cjs/Colors/index.js.map +1 -1
- package/dist/cjs/Components/AnimatedHeatMap.js +1 -1
- package/dist/cjs/Components/AnimatedHeatMap.js.map +1 -1
- package/dist/cjs/Components/AnimatedHeatMapLoaded.js.map +1 -1
- package/dist/cjs/Components/LayerAnimator.js.map +1 -1
- package/dist/cjs/Components/MapBox.js +3 -3
- package/dist/cjs/Components/MapBox.js.map +1 -1
- package/dist/cjs/Components/MapBoxHeat.js +4 -4
- package/dist/cjs/Components/MapBoxHeat.js.map +1 -1
- package/dist/cjs/Components/MapBoxPoints.js +14 -14
- package/dist/cjs/Components/MapBoxPoints.js.map +1 -1
- package/dist/cjs/Components/MapSettingsComponents/{Settings.js → SettingsBox.js} +4 -4
- package/dist/cjs/Components/MapSettingsComponents/SettingsBox.js.map +1 -0
- package/dist/cjs/Components/MapSettingsComponents/index.js +1 -1
- package/dist/cjs/Components/MapSettingsComponents/index.js.map +1 -1
- package/dist/cjs/Contexts/HeatMapInitializer/Provider.js +10 -10
- package/dist/cjs/Contexts/HeatMapInitializer/Provider.js.map +1 -1
- package/dist/cjs/Contexts/MapSettings/Provider.js +1 -1
- package/dist/cjs/Contexts/MapSettings/Provider.js.map +1 -1
- package/dist/cjs/Layers/{XyoMapLayer.js → MapLayer.js} +1 -1
- package/dist/cjs/Layers/MapLayer.js.map +1 -0
- package/dist/cjs/Layers/index.js +1 -1
- package/dist/cjs/Layers/index.js.map +1 -1
- package/dist/cjs/MapBoxClasses/{XyoMapBase.js → MapBase.js} +4 -4
- package/dist/cjs/MapBoxClasses/MapBase.js.map +1 -0
- package/dist/cjs/MapBoxClasses/{XyoMapHeat.js → MapHeat.js} +6 -6
- package/dist/cjs/MapBoxClasses/MapHeat.js.map +1 -0
- package/dist/cjs/MapBoxClasses/{XyoMapPoints.js → MapPoints.js} +5 -5
- package/dist/cjs/MapBoxClasses/MapPoints.js.map +1 -0
- package/dist/cjs/MapBoxClasses/{XyoMapSettings.js → MapSettings.js} +8 -8
- package/dist/cjs/MapBoxClasses/MapSettings.js.map +1 -0
- package/dist/cjs/MapBoxClasses/index.js +4 -4
- package/dist/cjs/MapBoxClasses/index.js.map +1 -1
- package/dist/cjs/hooks/useFetchPayloads.js.map +1 -1
- package/dist/cjs/hooks/useFindHashes.js.map +1 -1
- package/dist/cjs/hooks/useHeatMapColors.js.map +1 -1
- package/dist/cjs/hooks/useQuadKeyPayloadsToFeatures.js.map +1 -1
- package/dist/cjs/lib/{XyoMapBoxBaseProps.js → MapBoxBaseProps.js} +1 -1
- package/dist/cjs/lib/MapBoxBaseProps.js.map +1 -0
- package/dist/cjs/lib/MapStyle.js +13 -0
- package/dist/cjs/lib/MapStyle.js.map +1 -0
- package/dist/cjs/lib/index.js +2 -2
- package/dist/cjs/lib/index.js.map +1 -1
- package/dist/docs.json +1719 -1719
- package/dist/esm/Colors/MapColorProps.js +2 -0
- package/dist/esm/Colors/MapColorProps.js.map +1 -0
- package/dist/esm/Colors/index.js +1 -1
- package/dist/esm/Colors/index.js.map +1 -1
- package/dist/esm/Components/AnimatedHeatMap.js +2 -2
- package/dist/esm/Components/AnimatedHeatMap.js.map +1 -1
- package/dist/esm/Components/AnimatedHeatMapLoaded.js.map +1 -1
- package/dist/esm/Components/LayerAnimator.js.map +1 -1
- package/dist/esm/Components/MapBox.js +4 -4
- package/dist/esm/Components/MapBox.js.map +1 -1
- package/dist/esm/Components/MapBoxHeat.js +3 -3
- package/dist/esm/Components/MapBoxHeat.js.map +1 -1
- package/dist/esm/Components/MapBoxPoints.js +14 -14
- package/dist/esm/Components/MapBoxPoints.js.map +1 -1
- package/dist/esm/Components/MapSettingsComponents/{Settings.js → SettingsBox.js} +2 -2
- package/dist/esm/Components/MapSettingsComponents/SettingsBox.js.map +1 -0
- package/dist/esm/Components/MapSettingsComponents/index.js +1 -1
- package/dist/esm/Components/MapSettingsComponents/index.js.map +1 -1
- package/dist/esm/Contexts/HeatMapInitializer/Provider.js +11 -11
- package/dist/esm/Contexts/HeatMapInitializer/Provider.js.map +1 -1
- package/dist/esm/Contexts/MapSettings/Provider.js +2 -2
- package/dist/esm/Contexts/MapSettings/Provider.js.map +1 -1
- package/dist/esm/Layers/MapLayer.js +2 -0
- package/dist/esm/Layers/MapLayer.js.map +1 -0
- package/dist/esm/Layers/index.js +1 -1
- package/dist/esm/Layers/index.js.map +1 -1
- package/dist/esm/MapBoxClasses/{XyoMapBase.js → MapBase.js} +2 -2
- package/dist/esm/MapBoxClasses/MapBase.js.map +1 -0
- package/dist/esm/MapBoxClasses/{XyoMapHeat.js → MapHeat.js} +3 -3
- package/dist/esm/MapBoxClasses/MapHeat.js.map +1 -0
- package/dist/esm/MapBoxClasses/{XyoMapPoints.js → MapPoints.js} +3 -3
- package/dist/esm/MapBoxClasses/MapPoints.js.map +1 -0
- package/dist/esm/MapBoxClasses/{XyoMapSettings.js → MapSettings.js} +5 -5
- package/dist/esm/MapBoxClasses/MapSettings.js.map +1 -0
- package/dist/esm/MapBoxClasses/index.js +4 -4
- package/dist/esm/MapBoxClasses/index.js.map +1 -1
- package/dist/esm/hooks/useFetchPayloads.js.map +1 -1
- package/dist/esm/hooks/useFindHashes.js.map +1 -1
- package/dist/esm/hooks/useHeatMapColors.js.map +1 -1
- package/dist/esm/hooks/useQuadKeyPayloadsToFeatures.js.map +1 -1
- package/dist/esm/lib/MapBoxBaseProps.js +2 -0
- package/dist/esm/lib/MapBoxBaseProps.js.map +1 -0
- package/dist/esm/lib/MapStyle.js +10 -0
- package/dist/esm/lib/MapStyle.js.map +1 -0
- package/dist/esm/lib/index.js +2 -2
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/types/Colors/{XyoMapColorProps.d.ts → MapColorProps.d.ts} +3 -3
- package/dist/types/Colors/MapColorProps.d.ts.map +1 -0
- package/dist/types/Colors/index.d.ts +1 -1
- package/dist/types/Colors/index.d.ts.map +1 -1
- package/dist/types/Components/AnimatedHeatMap.d.ts +2 -2
- package/dist/types/Components/AnimatedHeatMap.d.ts.map +1 -1
- package/dist/types/Components/FeaturesToLayersMap.d.ts +2 -2
- package/dist/types/Components/FeaturesToLayersMap.d.ts.map +1 -1
- package/dist/types/Components/LayerAnimator.d.ts +2 -2
- package/dist/types/Components/LayerAnimator.d.ts.map +1 -1
- package/dist/types/Components/MapBoxHeat.d.ts +2 -2
- package/dist/types/Components/MapBoxHeat.d.ts.map +1 -1
- package/dist/types/Components/MapBoxPoints.d.ts +3 -3
- package/dist/types/Components/MapBoxPoints.d.ts.map +1 -1
- package/dist/types/Components/MapSettingsComponents/SettingsBox.d.ts +7 -0
- package/dist/types/Components/MapSettingsComponents/SettingsBox.d.ts.map +1 -0
- package/dist/types/Components/MapSettingsComponents/index.d.ts +1 -1
- package/dist/types/Components/MapSettingsComponents/index.d.ts.map +1 -1
- package/dist/types/Contexts/HeatMapInitializer/Provider.d.ts +5 -5
- package/dist/types/Contexts/HeatMapInitializer/Provider.d.ts.map +1 -1
- package/dist/types/Contexts/HeatMapInitializer/State.d.ts +4 -4
- package/dist/types/Contexts/HeatMapInitializer/State.d.ts.map +1 -1
- package/dist/types/Layers/{XyoMapLayer.d.ts → MapLayer.d.ts} +2 -2
- package/dist/types/Layers/MapLayer.d.ts.map +1 -0
- package/dist/types/Layers/index.d.ts +1 -1
- package/dist/types/Layers/index.d.ts.map +1 -1
- package/dist/types/MapBoxClasses/MapBase.d.ts +16 -0
- package/dist/types/MapBoxClasses/MapBase.d.ts.map +1 -0
- package/dist/types/MapBoxClasses/MapHeat.d.ts +14 -0
- package/dist/types/MapBoxClasses/MapHeat.d.ts.map +1 -0
- package/dist/types/MapBoxClasses/MapPoints.d.ts +12 -0
- package/dist/types/MapBoxClasses/MapPoints.d.ts.map +1 -0
- package/dist/types/MapBoxClasses/{XyoMapSettings.d.ts → MapSettings.d.ts} +7 -7
- package/dist/types/MapBoxClasses/MapSettings.d.ts.map +1 -0
- package/dist/types/MapBoxClasses/index.d.ts +4 -4
- package/dist/types/MapBoxClasses/index.d.ts.map +1 -1
- package/dist/types/hooks/useHeatMapColors.d.ts +2 -2
- package/dist/types/hooks/useHeatMapColors.d.ts.map +1 -1
- package/dist/types/hooks/useQuadKeyPayloadsToFeatures.d.ts +2 -2
- package/dist/types/hooks/useQuadKeyPayloadsToFeatures.d.ts.map +1 -1
- package/dist/types/lib/{XyoMapBoxBaseProps.d.ts → MapBoxBaseProps.d.ts} +4 -4
- package/dist/types/lib/MapBoxBaseProps.d.ts.map +1 -0
- package/dist/types/lib/{XyoMapStyle.d.ts → MapStyle.d.ts} +2 -2
- package/dist/types/lib/MapStyle.d.ts.map +1 -0
- package/dist/types/lib/index.d.ts +2 -2
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/types/NetworkLocationAnswerBase.d.ts +3 -3
- package/dist/types/types/NetworkLocationAnswerBase.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/Colors/{XyoMapColorProps.ts → MapColorProps.ts} +2 -2
- package/src/Colors/index.ts +1 -1
- package/src/Components/AnimatedHeatMap.tsx +6 -6
- package/src/Components/AnimatedHeatMapLoaded.tsx +2 -2
- package/src/Components/FeaturesToLayersMap.ts +2 -2
- package/src/Components/LayerAnimator.tsx +6 -6
- package/src/Components/MapBox.stories.tsx +2 -2
- package/src/Components/MapBox.tsx +4 -4
- package/src/Components/MapBoxHeat.tsx +4 -12
- package/src/Components/MapBoxPoints.tsx +16 -16
- package/src/Components/MapSettingsComponents/{Settings.tsx → SettingsBox.tsx} +2 -2
- package/src/Components/MapSettingsComponents/index.tsx +1 -1
- package/src/Contexts/HeatMapInitializer/Provider.tsx +17 -17
- package/src/Contexts/HeatMapInitializer/State.ts +4 -4
- package/src/Contexts/MapSettings/Provider.tsx +2 -2
- package/src/Layers/{XyoMapLayer.ts → MapLayer.ts} +1 -1
- package/src/Layers/index.ts +1 -1
- package/src/MapBoxClasses/{XyoMapBase.ts → MapBase.ts} +6 -6
- package/src/MapBoxClasses/{XyoMapHeat.ts → MapHeat.ts} +8 -8
- package/src/MapBoxClasses/{XyoMapPoints.ts → MapPoints.ts} +5 -5
- package/src/MapBoxClasses/{XyoMapSettings.ts → MapSettings.ts} +6 -6
- package/src/MapBoxClasses/index.ts +4 -4
- package/src/hooks/useFetchPayloads.tsx +3 -3
- package/src/hooks/useFindHashes.tsx +2 -2
- package/src/hooks/useHeatMapColors.tsx +2 -2
- package/src/hooks/useQuadKeyPayloadsToFeatures.tsx +5 -5
- package/src/lib/{XyoMapBoxBaseProps.ts → MapBoxBaseProps.ts} +3 -3
- package/src/lib/{XyoMapStyle.ts → MapStyle.ts} +1 -1
- package/src/lib/index.ts +2 -2
- package/src/types/NetworkLocationAnswerBase.ts +3 -3
- package/dist/cjs/Colors/XyoMapColorProps.js.map +0 -1
- package/dist/cjs/Components/MapSettingsComponents/Settings.js.map +0 -1
- package/dist/cjs/Layers/XyoMapLayer.js.map +0 -1
- package/dist/cjs/MapBoxClasses/XyoMapBase.js.map +0 -1
- package/dist/cjs/MapBoxClasses/XyoMapHeat.js.map +0 -1
- package/dist/cjs/MapBoxClasses/XyoMapPoints.js.map +0 -1
- package/dist/cjs/MapBoxClasses/XyoMapSettings.js.map +0 -1
- package/dist/cjs/lib/XyoMapBoxBaseProps.js.map +0 -1
- package/dist/cjs/lib/XyoMapStyle.js +0 -13
- package/dist/cjs/lib/XyoMapStyle.js.map +0 -1
- package/dist/esm/Colors/XyoMapColorProps.js +0 -2
- package/dist/esm/Colors/XyoMapColorProps.js.map +0 -1
- package/dist/esm/Components/MapSettingsComponents/Settings.js.map +0 -1
- package/dist/esm/Layers/XyoMapLayer.js +0 -2
- package/dist/esm/Layers/XyoMapLayer.js.map +0 -1
- package/dist/esm/MapBoxClasses/XyoMapBase.js.map +0 -1
- package/dist/esm/MapBoxClasses/XyoMapHeat.js.map +0 -1
- package/dist/esm/MapBoxClasses/XyoMapPoints.js.map +0 -1
- package/dist/esm/MapBoxClasses/XyoMapSettings.js.map +0 -1
- package/dist/esm/lib/XyoMapBoxBaseProps.js +0 -2
- package/dist/esm/lib/XyoMapBoxBaseProps.js.map +0 -1
- package/dist/esm/lib/XyoMapStyle.js +0 -10
- package/dist/esm/lib/XyoMapStyle.js.map +0 -1
- package/dist/types/Colors/XyoMapColorProps.d.ts.map +0 -1
- package/dist/types/Components/MapSettingsComponents/Settings.d.ts +0 -7
- package/dist/types/Components/MapSettingsComponents/Settings.d.ts.map +0 -1
- package/dist/types/Layers/XyoMapLayer.d.ts.map +0 -1
- package/dist/types/MapBoxClasses/XyoMapBase.d.ts +0 -16
- package/dist/types/MapBoxClasses/XyoMapBase.d.ts.map +0 -1
- package/dist/types/MapBoxClasses/XyoMapHeat.d.ts +0 -14
- package/dist/types/MapBoxClasses/XyoMapHeat.d.ts.map +0 -1
- package/dist/types/MapBoxClasses/XyoMapPoints.d.ts +0 -12
- package/dist/types/MapBoxClasses/XyoMapPoints.d.ts.map +0 -1
- package/dist/types/MapBoxClasses/XyoMapSettings.d.ts.map +0 -1
- package/dist/types/lib/XyoMapBoxBaseProps.d.ts.map +0 -1
- package/dist/types/lib/XyoMapStyle.d.ts.map +0 -1
|
@@ -2,12 +2,12 @@ import { useInterval, WithChildren } from '@xylabs/react-shared'
|
|
|
2
2
|
import { Map } from 'mapbox-gl'
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { MapLayer } from '../Layers'
|
|
6
|
+
import { MapboxFlexBoxProps } from '../lib'
|
|
7
7
|
|
|
8
8
|
export interface LayerAnimatorProps {
|
|
9
9
|
animateLayers?: boolean
|
|
10
|
-
layers:
|
|
10
|
+
layers: MapboxFlexBoxProps['layers']
|
|
11
11
|
layersInitialized: boolean
|
|
12
12
|
map: Map | undefined
|
|
13
13
|
}
|
|
@@ -16,7 +16,7 @@ const timeIncrement = 2000
|
|
|
16
16
|
const animatedLayerCount = 3
|
|
17
17
|
|
|
18
18
|
export const LayerAnimator: React.FC<WithChildren<LayerAnimatorProps>> = ({ animateLayers, children, layers, layersInitialized, map }) => {
|
|
19
|
-
const [fillLayers, setFillLayers] = useState<
|
|
19
|
+
const [fillLayers, setFillLayers] = useState<MapLayer[]>([])
|
|
20
20
|
const layerIndexQueue = useRef<number[]>([])
|
|
21
21
|
|
|
22
22
|
const incrementQueue = useCallback(
|
|
@@ -52,7 +52,7 @@ export const LayerAnimator: React.FC<WithChildren<LayerAnimatorProps>> = ({ anim
|
|
|
52
52
|
}, [fillLayers, incrementQueue, lastQueuedIndex])
|
|
53
53
|
|
|
54
54
|
const layerAnimateWorker = useCallback(
|
|
55
|
-
(layer:
|
|
55
|
+
(layer: MapLayer) => {
|
|
56
56
|
if (layer) {
|
|
57
57
|
map?.setPaintProperty(layer.id, 'fill-opacity', 0.85)
|
|
58
58
|
setTimeout(() => {
|
|
@@ -83,7 +83,7 @@ export const LayerAnimator: React.FC<WithChildren<LayerAnimatorProps>> = ({ anim
|
|
|
83
83
|
|
|
84
84
|
//
|
|
85
85
|
const queueLayerAnimation = useCallback(() => {
|
|
86
|
-
const animatedLayers:
|
|
86
|
+
const animatedLayers: MapLayer[] = []
|
|
87
87
|
|
|
88
88
|
for (let i = 0; i < animatedLayerCount; i++) {
|
|
89
89
|
animatedLayers.push(getNextLayer())
|
|
@@ -6,7 +6,7 @@ import { useRef } from 'react'
|
|
|
6
6
|
import { MapBoxInstanceProvider, MapSettingsProvider } from '../Contexts'
|
|
7
7
|
import { DefaultMapSettings } from '../Settings'
|
|
8
8
|
import { MapBox } from './MapBox'
|
|
9
|
-
import {
|
|
9
|
+
import { MapSettingsBox } from './MapSettingsComponents'
|
|
10
10
|
|
|
11
11
|
const WithMapboxProviders: Decorator = (Story, props) => {
|
|
12
12
|
const defaultSettings = DefaultMapSettings()
|
|
@@ -26,7 +26,7 @@ const WithMapSettingsDecorator: Decorator = (Story, args) => {
|
|
|
26
26
|
return (
|
|
27
27
|
<>
|
|
28
28
|
<Story {...args} />
|
|
29
|
-
<
|
|
29
|
+
<MapSettingsBox developerMode={true} />
|
|
30
30
|
</>
|
|
31
31
|
)
|
|
32
32
|
}
|
|
@@ -6,7 +6,7 @@ import { useEffect, useRef, useState } from 'react'
|
|
|
6
6
|
|
|
7
7
|
import { useMapBoxInstance, useMapSettings } from '../Contexts'
|
|
8
8
|
import { useDynamicMapResize } from '../hooks'
|
|
9
|
-
import {
|
|
9
|
+
import { MapStyle } from '../lib'
|
|
10
10
|
|
|
11
11
|
export interface MapBoxProps {
|
|
12
12
|
accessToken: string
|
|
@@ -27,9 +27,9 @@ export const MapBox: React.FC<MapBoxProps> = ({ accessToken, darkMode = false, o
|
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
if (mapSettings?.preferDark?.value === true) {
|
|
30
|
-
map?.setStyle(`mapbox://styles/${
|
|
30
|
+
map?.setStyle(`mapbox://styles/${MapStyle.Dark}`)
|
|
31
31
|
} else {
|
|
32
|
-
map?.setStyle(`mapbox://styles/${darkMode ?
|
|
32
|
+
map?.setStyle(`mapbox://styles/${darkMode ? MapStyle.Dark : MapStyle.Light}`)
|
|
33
33
|
}
|
|
34
34
|
}, [map, darkMode, mapSettings])
|
|
35
35
|
|
|
@@ -38,7 +38,7 @@ export const MapBox: React.FC<MapBoxProps> = ({ accessToken, darkMode = false, o
|
|
|
38
38
|
accessToken,
|
|
39
39
|
center: [0, 0],
|
|
40
40
|
container: mapContainerRef.current ?? '',
|
|
41
|
-
style: `mapbox://styles/${
|
|
41
|
+
style: `mapbox://styles/${MapStyle.Light}`,
|
|
42
42
|
zoom,
|
|
43
43
|
...options,
|
|
44
44
|
})
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { FlexCol } from '@xylabs/react-flexbox'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { MapboxFlexBoxProps } from '../lib'
|
|
4
4
|
import { MapBox } from './MapBox'
|
|
5
|
-
import {
|
|
5
|
+
import { MapSettingsBox } from './MapSettingsComponents'
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
accessToken,
|
|
9
|
-
children,
|
|
10
|
-
mapBoxOptions,
|
|
11
|
-
zoom,
|
|
12
|
-
legend,
|
|
13
|
-
developerMode,
|
|
14
|
-
...props
|
|
15
|
-
}) => {
|
|
7
|
+
export const MapboxHeatFlexBox: React.FC<MapboxFlexBoxProps> = ({ accessToken, children, mapBoxOptions, zoom, legend, developerMode, ...props }) => {
|
|
16
8
|
return (
|
|
17
9
|
<FlexCol {...props}>
|
|
18
10
|
<MapBox accessToken={accessToken} options={mapBoxOptions} zoom={zoom} />
|
|
19
|
-
<
|
|
11
|
+
<MapSettingsBox developerMode={developerMode} />
|
|
20
12
|
{legend}
|
|
21
13
|
{children}
|
|
22
14
|
</FlexCol>
|
|
@@ -5,17 +5,17 @@ import { FitBoundsOptions } from 'mapbox-gl'
|
|
|
5
5
|
import { useCallback, useEffect, useState } from 'react'
|
|
6
6
|
|
|
7
7
|
import { useMapBoxInstance, useMapSettings } from '../Contexts'
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { MapboxFlexBoxProps } from '../lib'
|
|
9
|
+
import { MapPoints } from '../MapBoxClasses'
|
|
10
10
|
import { MapBox } from './MapBox'
|
|
11
|
-
import {
|
|
11
|
+
import { MapSettingsBox } from './MapSettingsComponents'
|
|
12
12
|
|
|
13
|
-
export interface
|
|
13
|
+
export interface MapboxPointsFlexBoxProps extends MapboxFlexBoxProps {
|
|
14
14
|
accessToken: string
|
|
15
15
|
features?: Feature<Point>[]
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const
|
|
18
|
+
export const MapboxPointsFlexBox: React.FC<MapboxPointsFlexBoxProps> = ({
|
|
19
19
|
accessToken,
|
|
20
20
|
features,
|
|
21
21
|
fitToPointsPadding = 20,
|
|
@@ -23,7 +23,7 @@ export const XyoMapboxPointsFlexBox: React.FC<XyoMapboxPointsFlexBoxProps> = ({
|
|
|
23
23
|
zoom,
|
|
24
24
|
...props
|
|
25
25
|
}) => {
|
|
26
|
-
const [
|
|
26
|
+
const [mapPoints, setMapPoints] = useState<MapPoints>()
|
|
27
27
|
const { mapSettings } = useMapSettings()
|
|
28
28
|
const { map, mapInitialized } = useMapBoxInstance()
|
|
29
29
|
|
|
@@ -41,31 +41,31 @@ export const XyoMapboxPointsFlexBox: React.FC<XyoMapboxPointsFlexBoxProps> = ({
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const updateFeatures = useCallback(() => {
|
|
44
|
-
if (
|
|
44
|
+
if (mapPoints?.isMapReady && features?.length) {
|
|
45
45
|
layers?.forEach((layer) => {
|
|
46
|
-
|
|
46
|
+
mapPoints.initializeMapSource(layer)
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
|
-
}, [
|
|
49
|
+
}, [mapPoints, features, layers])
|
|
50
50
|
|
|
51
51
|
const updateMapSetup = useCallback(() => {
|
|
52
52
|
const { fitToPoints } = mapSettings || {}
|
|
53
53
|
|
|
54
|
-
if (
|
|
54
|
+
if (mapPoints && map) {
|
|
55
55
|
if (fitToPoints?.value === true) {
|
|
56
|
-
|
|
56
|
+
mapPoints.initialMapPositioning({ padding: fitToPointsPadding, ...customFitToBoundsOptions(zoom) })
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
}, [mapSettings,
|
|
59
|
+
}, [mapSettings, mapPoints, map, fitToPointsPadding, zoom])
|
|
60
60
|
|
|
61
61
|
const reInitializeMap = useCallback(() => {
|
|
62
|
-
|
|
62
|
+
mapPoints?.initialMapPositioning({ padding: fitToPointsPadding, ...customFitToBoundsOptions(zoom) })
|
|
63
63
|
updateFeatures()
|
|
64
|
-
}, [
|
|
64
|
+
}, [mapPoints, fitToPointsPadding, updateFeatures, zoom])
|
|
65
65
|
|
|
66
66
|
useEffect(() => {
|
|
67
67
|
if (map && features?.length) {
|
|
68
|
-
setMapPoints(new
|
|
68
|
+
setMapPoints(new MapPoints({ features, map, zoom }))
|
|
69
69
|
}
|
|
70
70
|
}, [map, features, zoom])
|
|
71
71
|
|
|
@@ -81,7 +81,7 @@ export const XyoMapboxPointsFlexBox: React.FC<XyoMapboxPointsFlexBoxProps> = ({
|
|
|
81
81
|
{features ? (
|
|
82
82
|
<>
|
|
83
83
|
<MapBox accessToken={accessToken} zoom={zoom} />
|
|
84
|
-
<
|
|
84
|
+
<MapSettingsBox />
|
|
85
85
|
</>
|
|
86
86
|
) : (
|
|
87
87
|
<Alert severity="error">No data to show</Alert>
|
|
@@ -5,11 +5,11 @@ import { useAppSettings } from '@xyo-network/react-app-settings'
|
|
|
5
5
|
import { useMapSettings } from '../../Contexts'
|
|
6
6
|
import { MapSettingSwitch } from './Setting'
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface MapSettingsBoxProps extends FlexBoxProps {
|
|
9
9
|
developerMode?: boolean
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const MapSettingsBox: React.FC<MapSettingsBoxProps> = ({ developerMode, ...props }) => {
|
|
13
13
|
const { mapSettings } = useMapSettings()
|
|
14
14
|
const { developerMode: devModeFromContext } = useAppSettings()
|
|
15
15
|
const resolveDeveloperMode = developerMode ?? devModeFromContext
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './Setting'
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './SettingsBox'
|
|
@@ -3,10 +3,10 @@ import { WithChildren } from '@xylabs/react-shared'
|
|
|
3
3
|
import { Feature, Polygon } from 'geojson'
|
|
4
4
|
import { useEffect, useState } from 'react'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { AnimatedHeatMapColorProps, HeatMapColorProps } from '../../Colors'
|
|
7
7
|
import { useDynamicPositioning } from '../../hooks'
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { MapLayer } from '../../Layers'
|
|
9
|
+
import { MapHeat } from '../../MapBoxClasses'
|
|
10
10
|
import { useMapBoxInstance } from '../MapBoxInstance'
|
|
11
11
|
import { useMapSettings } from '../MapSettings'
|
|
12
12
|
import { HeatMapInitializerContext } from './Context'
|
|
@@ -14,11 +14,11 @@ import { HeatMapInitializerState } from './State'
|
|
|
14
14
|
|
|
15
15
|
export interface MapInitializerProviderProps {
|
|
16
16
|
featureSets?: Feature<Polygon>[][]
|
|
17
|
-
featureSetsLayers?:
|
|
17
|
+
featureSetsLayers?: MapLayer[]
|
|
18
18
|
features?: Feature<Polygon>[]
|
|
19
19
|
fitToPadding?: number
|
|
20
|
-
heatMapColorProps:
|
|
21
|
-
layers?:
|
|
20
|
+
heatMapColorProps: HeatMapColorProps | AnimatedHeatMapColorProps
|
|
21
|
+
layers?: MapLayer[]
|
|
22
22
|
zoom?: number
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -32,32 +32,32 @@ export const HeatMapInitializerProvider: React.FC<WithChildren<MapInitializerPro
|
|
|
32
32
|
layers,
|
|
33
33
|
zoom,
|
|
34
34
|
}) => {
|
|
35
|
-
const [
|
|
35
|
+
const [mapHeat, setMapHeat] = useState<MapHeat>()
|
|
36
36
|
const { options } = useDynamicPositioning()
|
|
37
37
|
const { mapSettings } = useMapSettings()
|
|
38
38
|
const { map, mapInitialized } = useMapBoxInstance()
|
|
39
39
|
|
|
40
40
|
const value: HeatMapInitializerState = {
|
|
41
|
-
MapHeat,
|
|
41
|
+
MapHeat: mapHeat,
|
|
42
42
|
heatMapColorProps,
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
if (mapInitialized && featureSets?.length && featureSets[0].length && map && featureSetsLayers?.length) {
|
|
47
|
-
const { lowUsageColor, highUsageColor } = heatMapColorProps as
|
|
48
|
-
forget(
|
|
47
|
+
const { lowUsageColor, highUsageColor } = heatMapColorProps as AnimatedHeatMapColorProps
|
|
48
|
+
forget(MapHeat.initializeAnimatedHeatMapSource(featureSetsLayers, featureSets, map, lowUsageColor, highUsageColor))
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
return () => {
|
|
52
|
-
|
|
52
|
+
MapHeat.animationStarted = false
|
|
53
53
|
}
|
|
54
54
|
}, [featureSets, featureSetsLayers, mapInitialized, map, heatMapColorProps])
|
|
55
55
|
|
|
56
56
|
useEffect(() => {
|
|
57
|
-
if (
|
|
58
|
-
|
|
57
|
+
if (mapHeat && mapInitialized && features?.length && layers?.length) {
|
|
58
|
+
mapHeat.initializeHeatMapSource(layers)
|
|
59
59
|
}
|
|
60
|
-
}, [
|
|
60
|
+
}, [mapHeat, features?.length, layers, mapInitialized])
|
|
61
61
|
|
|
62
62
|
useEffect(() => {
|
|
63
63
|
if (mapInitialized) {
|
|
@@ -65,19 +65,19 @@ export const HeatMapInitializerProvider: React.FC<WithChildren<MapInitializerPro
|
|
|
65
65
|
|
|
66
66
|
if (map) {
|
|
67
67
|
if (fitToPoints?.value === true) {
|
|
68
|
-
|
|
68
|
+
MapHeat.initialMapPositioning({ padding: fitToPadding }, map, features)
|
|
69
69
|
} else if (options.zoom && options.center) {
|
|
70
70
|
map.setZoom(options.zoom)
|
|
71
71
|
map.setCenter(options.center)
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
}, [
|
|
75
|
+
}, [mapHeat, map, mapSettings, fitToPadding, options, mapInitialized, features])
|
|
76
76
|
|
|
77
77
|
useEffect(() => {
|
|
78
78
|
if (map && features?.length) {
|
|
79
79
|
// Every time we get a new map or features, we make a new class
|
|
80
|
-
setMapHeat(new
|
|
80
|
+
setMapHeat(new MapHeat({ features, map, zoom }))
|
|
81
81
|
}
|
|
82
82
|
}, [map, features, zoom])
|
|
83
83
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { HeatMapColorProps } from '../../Colors'
|
|
2
|
+
import { MapHeat } from '../../MapBoxClasses'
|
|
3
3
|
|
|
4
4
|
export interface HeatMapInitializerState {
|
|
5
|
-
MapHeat?:
|
|
6
|
-
heatMapColorProps?:
|
|
5
|
+
MapHeat?: MapHeat
|
|
6
|
+
heatMapColorProps?: HeatMapColorProps
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WithChildren } from '@xylabs/react-shared'
|
|
2
2
|
import { useEffect, useState } from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { MapSettings } from '../../MapBoxClasses'
|
|
5
5
|
import { MapSetting } from '../../Settings'
|
|
6
6
|
import { useMapBoxInstance } from '../MapBoxInstance'
|
|
7
7
|
import { MapSettingsContext } from './Context'
|
|
@@ -31,7 +31,7 @@ export const MapSettingsProvider: React.FC<WithChildren<MapSettingsProviderProps
|
|
|
31
31
|
|
|
32
32
|
useEffect(() => {
|
|
33
33
|
if (mapSettings && map && mapInitialized) {
|
|
34
|
-
|
|
34
|
+
MapSettings.updateSettings({ debugLayerName, map, requestLocation, settings: mapSettings, zoom })
|
|
35
35
|
}
|
|
36
36
|
}, [debugLayerName, map, mapInitialized, mapSettings, requestLocation, zoom])
|
|
37
37
|
|
|
@@ -2,6 +2,6 @@ import { LayerBase } from '@xyo-network/sdk-geo'
|
|
|
2
2
|
// eslint-disable-next-line no-restricted-imports
|
|
3
3
|
import { AnyLayer, Layer } from 'mapbox-gl'
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface MapLayer extends Layer {
|
|
6
6
|
update: LayerBase<AnyLayer>['update']
|
|
7
7
|
}
|
package/src/Layers/index.ts
CHANGED
|
@@ -4,19 +4,19 @@ import { Feature, Geometry } from 'geojson'
|
|
|
4
4
|
// eslint-disable-next-line no-restricted-imports
|
|
5
5
|
import { GeoJSONSource, Map } from 'mapbox-gl'
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { MapLayer } from '../Layers'
|
|
8
8
|
|
|
9
|
-
export interface
|
|
9
|
+
export interface MapBaseConfig<T extends Geometry> {
|
|
10
10
|
features: Feature<T>[]
|
|
11
11
|
map: Map
|
|
12
12
|
requestLocation?: boolean
|
|
13
13
|
zoom?: number
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export abstract class
|
|
17
|
-
private _config:
|
|
16
|
+
export abstract class MapBase<T extends Geometry> {
|
|
17
|
+
private _config: MapBaseConfig<T>
|
|
18
18
|
|
|
19
|
-
constructor(config:
|
|
19
|
+
constructor(config: MapBaseConfig<T>) {
|
|
20
20
|
this._config = { requestLocation: true, zoom: 2, ...config }
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -24,7 +24,7 @@ export abstract class XyoMapBase<T extends Geometry> {
|
|
|
24
24
|
return !!this._config.map
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
initializeMapSource(layer:
|
|
27
|
+
initializeMapSource(layer: MapLayer) {
|
|
28
28
|
const getSource = () => {
|
|
29
29
|
const featuresCollection = GeoJson.featureCollection(this._config.features)
|
|
30
30
|
return GeoJson.featuresSource(featuresCollection)
|
|
@@ -5,14 +5,14 @@ import { GeoJson } from '@xyo-network/sdk-geo'
|
|
|
5
5
|
import { Feature, Polygon } from 'geojson'
|
|
6
6
|
import { FitBoundsOptions, GeoJSONSource, GeoJSONSourceRaw, LngLatBounds, Map } from 'mapbox-gl'
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { MapLayer } from '../Layers'
|
|
9
|
+
import { MapBase, MapBaseConfig } from './MapBase'
|
|
10
10
|
|
|
11
|
-
export class
|
|
11
|
+
export class MapHeat extends MapBase<Polygon> {
|
|
12
12
|
static animationStarted = false
|
|
13
13
|
|
|
14
|
-
config:
|
|
15
|
-
constructor(config:
|
|
14
|
+
config: MapBaseConfig<Polygon>
|
|
15
|
+
constructor(config: MapBaseConfig<Polygon>) {
|
|
16
16
|
super(config)
|
|
17
17
|
this.config = config
|
|
18
18
|
}
|
|
@@ -44,7 +44,7 @@ export class XyoMapHeat extends XyoMapBase<Polygon> {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
static async initializeAnimatedHeatMapSource(
|
|
47
|
-
layers:
|
|
47
|
+
layers: MapLayer[],
|
|
48
48
|
featureSet: Feature<Polygon>[][],
|
|
49
49
|
map: Map,
|
|
50
50
|
startColor?: string,
|
|
@@ -144,7 +144,7 @@ export class XyoMapHeat extends XyoMapBase<Polygon> {
|
|
|
144
144
|
await startAnimation()
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
private static updateLayer(map: Map, layer:
|
|
147
|
+
private static updateLayer(map: Map, layer: MapLayer, source: GeoJSONSourceRaw) {
|
|
148
148
|
const existingSource = map.getSource(layer.source as string) as GeoJSONSource
|
|
149
149
|
if (existingSource && source.data) {
|
|
150
150
|
existingSource.setData(source.data as GeoJSON.Feature<GeoJSON.Geometry> | GeoJSON.FeatureCollection<GeoJSON.Geometry>)
|
|
@@ -155,7 +155,7 @@ export class XyoMapHeat extends XyoMapBase<Polygon> {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// Build layers each with the same features
|
|
158
|
-
initializeHeatMapSource(layers:
|
|
158
|
+
initializeHeatMapSource(layers: MapLayer[]) {
|
|
159
159
|
const getSource = (_: number) => {
|
|
160
160
|
const featuresCollection = GeoJson.featureCollection(this.config.features)
|
|
161
161
|
return GeoJson.featuresSource(featuresCollection)
|
|
@@ -2,16 +2,16 @@ import { Feature, Point } from 'geojson'
|
|
|
2
2
|
// eslint-disable-next-line no-restricted-imports
|
|
3
3
|
import { FitBoundsOptions, LngLatBounds } from 'mapbox-gl'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { MapBase, MapBaseConfig } from './MapBase'
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface MapPointsConfig extends MapBaseConfig<Point> {
|
|
8
8
|
features: Feature<Point>[]
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export class
|
|
12
|
-
private config:
|
|
11
|
+
export class MapPoints extends MapBase<Point> {
|
|
12
|
+
private config: MapPointsConfig
|
|
13
13
|
|
|
14
|
-
constructor(config:
|
|
14
|
+
constructor(config: MapPointsConfig) {
|
|
15
15
|
super(config)
|
|
16
16
|
this.config = config
|
|
17
17
|
}
|
|
@@ -2,7 +2,7 @@ import { EventData, GeolocateControl, Map, MapLayerMouseEvent, MapLayerTouchEven
|
|
|
2
2
|
|
|
3
3
|
import { MapSetting } from '../Settings'
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface MapSettingsConfig {
|
|
6
6
|
debugLayerName?: string
|
|
7
7
|
map: Map
|
|
8
8
|
requestLocation?: boolean
|
|
@@ -15,7 +15,7 @@ export interface XyoMapSettingsConfig {
|
|
|
15
15
|
*
|
|
16
16
|
* Methods are pure functions dedicated to map manipulation
|
|
17
17
|
*/
|
|
18
|
-
export class
|
|
18
|
+
export class MapSettings {
|
|
19
19
|
static geoLocateControl: GeolocateControl | undefined
|
|
20
20
|
static mapListeners = {
|
|
21
21
|
logData: (ev?: MapLayerMouseEvent | (MapLayerTouchEvent & EventData), map?: Map) => {
|
|
@@ -31,9 +31,9 @@ export class XyoMapSettings {
|
|
|
31
31
|
|
|
32
32
|
static toggleControls(value: boolean | undefined, map: Map, zoom?: number, requestLocation?: boolean) {
|
|
33
33
|
if (value) {
|
|
34
|
-
|
|
34
|
+
MapSettings.addControls(map, zoom, requestLocation)
|
|
35
35
|
} else {
|
|
36
|
-
|
|
36
|
+
MapSettings.removeControls(map)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return this
|
|
@@ -73,11 +73,11 @@ export class XyoMapSettings {
|
|
|
73
73
|
return this
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
static updateSettings(config:
|
|
76
|
+
static updateSettings(config: MapSettingsConfig) {
|
|
77
77
|
const { settings, map, zoom, requestLocation, debugLayerName = '' } = config
|
|
78
78
|
const { scrollToZoom, enableControls, debugLayer, debugLogging } = settings
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
MapSettings.toggleControls(enableControls?.value, map, zoom, requestLocation)
|
|
81
81
|
.toggleScrollToZoom(scrollToZoom?.value, map)
|
|
82
82
|
.toggleDebugLayer(debugLayer?.value, map, debugLayerName)
|
|
83
83
|
.toggleDebugLogging(debugLogging.value, map)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
1
|
+
export * from './MapBase'
|
|
2
|
+
export * from './MapHeat'
|
|
3
|
+
export * from './MapPoints'
|
|
4
|
+
export * from './MapSettings'
|
|
@@ -5,7 +5,7 @@ import { ModuleError, WrapperError } from '@xyo-network/module'
|
|
|
5
5
|
import { useArchivist } from '@xyo-network/react-archivist'
|
|
6
6
|
import { useState } from 'react'
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { NetworkLocationHeatmapQuadkeyAnswerPayload } from '../types'
|
|
9
9
|
import { useQuadKeyPayloadsToFeatures } from './useQuadKeyPayloadsToFeatures'
|
|
10
10
|
|
|
11
11
|
/** @deprecated - use useArchivistGet */
|
|
@@ -13,7 +13,7 @@ const useFetchPayloads = (hashes?: string[]) => {
|
|
|
13
13
|
const [archivist] = useArchivist()
|
|
14
14
|
|
|
15
15
|
const [apiError, setApiError] = useState<ModuleError>()
|
|
16
|
-
const [payloads, setPayloads] = useState<
|
|
16
|
+
const [payloads, setPayloads] = useState<NetworkLocationHeatmapQuadkeyAnswerPayload[]>()
|
|
17
17
|
const { features, multipleFeatureSets } = useQuadKeyPayloadsToFeatures(payloads)
|
|
18
18
|
const [notFound, setNotFound] = useState(false)
|
|
19
19
|
const [inFlight, setInFlight] = useState(false)
|
|
@@ -31,7 +31,7 @@ const useFetchPayloads = (hashes?: string[]) => {
|
|
|
31
31
|
setNotFound(true)
|
|
32
32
|
setPayloads([])
|
|
33
33
|
} else {
|
|
34
|
-
setPayloads(payloads as
|
|
34
|
+
setPayloads(payloads as NetworkLocationHeatmapQuadkeyAnswerPayload[])
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
} catch (e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArchivistPreset, useNetwork } from '@xyo-network/react-network'
|
|
2
2
|
import { useMemo } from 'react'
|
|
3
3
|
|
|
4
4
|
const animatedAnswerHashesConst = [
|
|
@@ -19,7 +19,7 @@ const staticAnswerHashConst = 'c7bbf61f61cfd4a1b2def160c28136fc1d100d39fbdb67b22
|
|
|
19
19
|
|
|
20
20
|
export const useFindHashes = () => {
|
|
21
21
|
const { network } = useNetwork()
|
|
22
|
-
const exploreMapHashes = (network?.nodes?.find((node) => node.type === 'archivist') as
|
|
22
|
+
const exploreMapHashes = (network?.nodes?.find((node) => node.type === 'archivist') as ArchivistPreset)?.explorerMapHashes
|
|
23
23
|
const animatedAnswerHashes = exploreMapHashes?.animatedAnswerHashes || animatedAnswerHashesConst
|
|
24
24
|
const staticAnswerHash = exploreMapHashes?.staticAnswerHash || staticAnswerHashConst
|
|
25
25
|
const foundHashes = useMemo(() => [staticAnswerHash, ...animatedAnswerHashes], [animatedAnswerHashes, staticAnswerHash])
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useTheme } from '@mui/material'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { AnimatedHeatMapColorProps, ColorGradientLegendProps } from '../Colors'
|
|
4
4
|
|
|
5
5
|
const useHeatMapColors = () => {
|
|
6
6
|
const theme = useTheme()
|
|
7
7
|
const staticMapColor = '#FFFF75'
|
|
8
8
|
const highUsageColor = '#FF0000'
|
|
9
9
|
|
|
10
|
-
const heatMapColorProps:
|
|
10
|
+
const heatMapColorProps: AnimatedHeatMapColorProps = {
|
|
11
11
|
highUsageColor,
|
|
12
12
|
lowUsageColor: '#FFB3B3',
|
|
13
13
|
staticMapColor,
|
|
@@ -3,7 +3,7 @@ import { Feature, Geometry } from 'geojson'
|
|
|
3
3
|
import compact from 'lodash/compact'
|
|
4
4
|
import { useEffect, useState } from 'react'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { NetworkLocationHeatmapQuadkeyAnswerPayload } from '../types'
|
|
7
7
|
|
|
8
8
|
const quadKeyToFeature = ({ density, quadkey }: { density: number; quadkey: string }) => {
|
|
9
9
|
const polygonFeature = new GeoJson(quadkey).polygonFeature()
|
|
@@ -21,7 +21,7 @@ const setDensity = (feature: Feature) => {
|
|
|
21
21
|
return feature
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const useQuadKeyPayloadsToFeatures = (payloads?:
|
|
24
|
+
const useQuadKeyPayloadsToFeatures = (payloads?: NetworkLocationHeatmapQuadkeyAnswerPayload[] | NetworkLocationHeatmapQuadkeyAnswerPayload) => {
|
|
25
25
|
const [multipleFeatureSets, setMultipleFeatureSets] = useState<Feature<Geometry>[][]>([[]])
|
|
26
26
|
const [features, setFeatures] = useState<Feature<Geometry>[]>([])
|
|
27
27
|
const [error, setError] = useState<Error>()
|
|
@@ -30,7 +30,7 @@ const useQuadKeyPayloadsToFeatures = (payloads?: NetworkXyoLocationHeatmapQuadke
|
|
|
30
30
|
// Convert Multiple Payloads from Quadkey to GeoJson
|
|
31
31
|
if (Array.isArray(payloads)) {
|
|
32
32
|
if (compact(payloads).length !== 0) {
|
|
33
|
-
const payloadsArray = payloads as (
|
|
33
|
+
const payloadsArray = payloads as (NetworkLocationHeatmapQuadkeyAnswerPayload | null)[]
|
|
34
34
|
const mappedFeatures = payloadsArray?.map((payload) => payload?.result.map(quadKeyToFeature))
|
|
35
35
|
|
|
36
36
|
setMultipleFeatureSets(mappedFeatures.map((features) => features?.map(setDensity) ?? []))
|
|
@@ -40,8 +40,8 @@ const useQuadKeyPayloadsToFeatures = (payloads?: NetworkXyoLocationHeatmapQuadke
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// Convert Single Payload from Quadkey to GeoJson
|
|
43
|
-
if (payloads && (payloads as
|
|
44
|
-
const singlePayload = payloads as
|
|
43
|
+
if (payloads && (payloads as NetworkLocationHeatmapQuadkeyAnswerPayload).result) {
|
|
44
|
+
const singlePayload = payloads as NetworkLocationHeatmapQuadkeyAnswerPayload
|
|
45
45
|
const mappedFeatures = singlePayload.result.map(quadKeyToFeature)
|
|
46
46
|
|
|
47
47
|
setFeatures(mappedFeatures.map(setDensity))
|
|
@@ -3,16 +3,16 @@ import { Feature } from 'geojson'
|
|
|
3
3
|
import { MapboxOptions } from 'mapbox-gl'
|
|
4
4
|
import { ReactNode } from 'react'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { MapLayer } from '../Layers'
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface MapboxFlexBoxProps extends FlexBoxProps {
|
|
9
9
|
accessToken: string
|
|
10
10
|
developerMode?: boolean
|
|
11
11
|
disableControls?: boolean
|
|
12
12
|
disableFitToPoints?: boolean
|
|
13
13
|
features?: Feature[]
|
|
14
14
|
fitToPointsPadding?: number
|
|
15
|
-
layers?:
|
|
15
|
+
layers?: MapLayer[]
|
|
16
16
|
legend?: ReactNode
|
|
17
17
|
mapBoxOptions?: Partial<MapboxOptions>
|
|
18
18
|
requestLocation?: boolean
|