@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.
Files changed (69) hide show
  1. package/dist/browser/Components/MapBox.d.ts.map +1 -1
  2. package/dist/browser/Components/MapBoxPoints.d.ts.map +1 -1
  3. package/dist/browser/MapBoxClasses/MapHeat.d.ts.map +1 -1
  4. package/dist/browser/MapBoxClasses/MapSettings.d.ts.map +1 -1
  5. package/dist/browser/hooks/useDynamicMapResize.d.ts.map +1 -1
  6. package/dist/browser/hooks/useQuadKeyPayloadsToFeatures.d.ts.map +1 -1
  7. package/dist/browser/index.mjs +481 -714
  8. package/dist/browser/index.mjs.map +1 -1
  9. package/package.json +159 -36
  10. package/src/Components/AnimatedHeatMap.tsx +0 -61
  11. package/src/Components/AnimatedHeatMapLoaded.tsx +0 -61
  12. package/src/Components/FeaturesToLayersMap.ts +0 -8
  13. package/src/Components/HeatMapSettings.ts +0 -11
  14. package/src/Components/LayerAnimator.tsx +0 -119
  15. package/src/Components/Legend.tsx +0 -36
  16. package/src/Components/Legends/ColorGradient.tsx +0 -35
  17. package/src/Components/Legends/index.ts +0 -1
  18. package/src/Components/MapBox.stories.tsx +0 -92
  19. package/src/Components/MapBox.tsx +0 -79
  20. package/src/Components/MapBoxHeat.tsx +0 -19
  21. package/src/Components/MapBoxPoints.tsx +0 -99
  22. package/src/Components/MapSettingsComponents/Setting.tsx +0 -36
  23. package/src/Components/MapSettingsComponents/SettingsBox.tsx +0 -34
  24. package/src/Components/MapSettingsComponents/index.ts +0 -2
  25. package/src/Components/index.ts +0 -11
  26. package/src/Contexts/HeatMapInitializer/Context.ts +0 -7
  27. package/src/Contexts/HeatMapInitializer/Provider.tsx +0 -93
  28. package/src/Contexts/HeatMapInitializer/State.ts +0 -8
  29. package/src/Contexts/HeatMapInitializer/index.ts +0 -3
  30. package/src/Contexts/HeatMapInitializer/useHeatMapInitializer.tsx +0 -13
  31. package/src/Contexts/MapBoxInstance/Context.ts +0 -7
  32. package/src/Contexts/MapBoxInstance/Provider.tsx +0 -26
  33. package/src/Contexts/MapBoxInstance/State.ts +0 -8
  34. package/src/Contexts/MapBoxInstance/index.ts +0 -3
  35. package/src/Contexts/MapBoxInstance/useMapBoxInstance.tsx +0 -13
  36. package/src/Contexts/MapSettings/Context.ts +0 -7
  37. package/src/Contexts/MapSettings/Provider.tsx +0 -43
  38. package/src/Contexts/MapSettings/State.ts +0 -7
  39. package/src/Contexts/MapSettings/index.ts +0 -3
  40. package/src/Contexts/MapSettings/useMapSettings.tsx +0 -11
  41. package/src/Contexts/index.ts +0 -3
  42. package/src/Layers/Builders/LocationHeatMapLayerBuilder.ts +0 -36
  43. package/src/Layers/Builders/LocationHeatMapLayerBuilderAnimated.ts +0 -21
  44. package/src/Layers/Builders/LocationPointsMapLayerBuilder.ts +0 -17
  45. package/src/Layers/Builders/index.ts +0 -3
  46. package/src/Layers/CircleLayer.ts +0 -31
  47. package/src/Layers/Configs/HeatMapFillLayerConfig.ts +0 -13
  48. package/src/Layers/Configs/HeatMapLineLayerConfig.ts +0 -13
  49. package/src/Layers/Configs/HeatMapSymbolLayerConfig.ts +0 -18
  50. package/src/Layers/Configs/LocationPointLayerConfig.ts +0 -15
  51. package/src/Layers/Configs/index.ts +0 -4
  52. package/src/Layers/FillLayer.ts +0 -23
  53. package/src/Layers/LineLayer.ts +0 -24
  54. package/src/Layers/MapLayer.ts +0 -6
  55. package/src/Layers/SymbolLayer.ts +0 -23
  56. package/src/Layers/index.ts +0 -7
  57. package/src/MapBoxClasses/MapBase.ts +0 -45
  58. package/src/MapBoxClasses/MapHeat.ts +0 -184
  59. package/src/MapBoxClasses/MapPoints.ts +0 -39
  60. package/src/MapBoxClasses/MapSettings.ts +0 -132
  61. package/src/MapBoxClasses/index.ts +0 -4
  62. package/src/global.d.ts +0 -1
  63. package/src/hooks/index.ts +0 -3
  64. package/src/hooks/useDynamicMapResize.tsx +0 -43
  65. package/src/hooks/useDynamicPositioning.tsx +0 -68
  66. package/src/hooks/useQuadKeyPayloadsToFeatures.tsx +0 -54
  67. package/src/index.ts +0 -5
  68. package/src/lib/MapBoxBaseProps.ts +0 -20
  69. package/src/lib/index.ts +0 -1
@@ -1,68 +0,0 @@
1
- import { useWindowSize } from '@xylabs/react-shared'
2
- import type { MapOptions } from 'mapbox-gl'
3
- import { useMemo } from 'react'
4
-
5
- /**
6
- * Zoom level for the map
7
- *
8
- * Note: Changing zoom will require changes to Lat/Lng Ranges
9
- */
10
- const defaultZoom = 1.6
11
-
12
- /**
13
- * Range of aspect ratio values (width / height = aspect ratio) to scale against degrees
14
- * On lower aspect ratios, the width is larger than the height and vice-versa for higher
15
- */
16
- const defaultAspectRatioRange = [0.5, 2]
17
-
18
- /**
19
- * Lat/Lng ranges, the first index is the minimum and the second is the maximum
20
- * Index 0 is for portrait screens and centers on the Eastern Hemisphere
21
- * Index 1 is for wider screens near the Prime Meridian and north of the Equator
22
- *
23
- * Note: Values are based off the zoom level
24
- */
25
- const latRange = [0.912_164_420_526_366_4, 1.717_850_315_594_39]
26
- const lngRange = [-81.474_201_485_195_9, 12.788_958_675_506_933]
27
-
28
- /**
29
- * Function to interpolate an aspect ratio value across a range of degrees and aspect ratios
30
- *
31
- * Inspired by - https://stackoverflow.com/questions/14224535/scaling-between-two-number-ranges
32
- *
33
- * @param aspectRatio aspect ratio to scale
34
- * @param degreeRange A latitude or longitude range (i.e. [minLat, maxLat])
35
- * @param aspectRatioRange A range of aspect ratios to scale against degreeRange parameter
36
- * @returns number
37
- */
38
- const linearInterpolate = (aspectRatio: number, degreeRange: number[], aspectRatioRange?: number[]): number => {
39
- const [degreeMin, degreeMax] = degreeRange
40
- const [aspectRatioMin, aspectRatioMax] = aspectRatioRange || defaultAspectRatioRange
41
-
42
- const aspectRatioRangeSpan = aspectRatioMax - aspectRatioMin
43
- const degreeRangeSpan = degreeMax - degreeMin
44
-
45
- const percent = (aspectRatio - aspectRatioMin) / aspectRatioRangeSpan
46
- const scaledDegree = percent * degreeRangeSpan + degreeMin
47
-
48
- return scaledDegree
49
- }
50
-
51
- const useDynamicPositioning = () => {
52
- const { width, height } = useWindowSize()
53
-
54
- const options = useMemo(() => {
55
- if (width && height) {
56
- const aspectRatio = width / height
57
-
58
- return {
59
- center: [linearInterpolate(aspectRatio, lngRange), linearInterpolate(aspectRatio, latRange)],
60
- zoom: defaultZoom,
61
- } as Partial<MapOptions>
62
- }
63
- }, [height, width])
64
-
65
- return { options }
66
- }
67
-
68
- export { useDynamicPositioning }
@@ -1,54 +0,0 @@
1
- import { GeoJson } from '@xylabs/geo'
2
- import { exists } from '@xylabs/sdk-js'
3
- import type { NetworkLocationHeatmapQuadkeyAnswerPayload } from '@xyo-network/react-map-model'
4
- import type { Feature, Geometry } from 'geojson'
5
- import { useEffect, useState } from 'react'
6
-
7
- const quadKeyToFeature = ({ density, quadkey }: { density: number; quadkey: string }) => {
8
- const polygonFeature = new GeoJson(quadkey).polygonFeature()
9
- polygonFeature.properties = {
10
- count: density,
11
- density,
12
- }
13
- return polygonFeature
14
- }
15
-
16
- const setDensity = (feature: Feature) => {
17
- if (feature.properties) {
18
- feature.properties.value = feature.properties.density / 5
19
- }
20
- return feature
21
- }
22
-
23
- const useQuadKeyPayloadsToFeatures = (payloads?: NetworkLocationHeatmapQuadkeyAnswerPayload[] | NetworkLocationHeatmapQuadkeyAnswerPayload) => {
24
- const [multipleFeatureSets, setMultipleFeatureSets] = useState<Feature<Geometry>[][]>([[]])
25
- const [features, setFeatures] = useState<Feature<Geometry>[]>([])
26
- const [error, setError] = useState<Error>()
27
-
28
- useEffect(() => {
29
- // Convert Multiple Payloads from Quadkey to GeoJson
30
- if (Array.isArray(payloads)) {
31
- if ((payloads)?.filter(exists).length > 0) {
32
- const mappedFeatures = payloads?.map(payload => payload?.result.map(quadKeyToFeature))
33
-
34
- setMultipleFeatureSets(mappedFeatures.map(features => features?.map(setDensity) ?? []))
35
- } else {
36
- setError(new Error('Cannot find payloads for provided hashes'))
37
- }
38
- }
39
-
40
- // Convert Single Payload from Quadkey to GeoJson
41
- if (payloads && (payloads as NetworkLocationHeatmapQuadkeyAnswerPayload).result) {
42
- const singlePayload = payloads as NetworkLocationHeatmapQuadkeyAnswerPayload
43
- const mappedFeatures = singlePayload.result.map(quadKeyToFeature)
44
-
45
- setFeatures(mappedFeatures.map(setDensity))
46
- }
47
- }, [payloads])
48
-
49
- return {
50
- error, features, multipleFeatureSets,
51
- }
52
- }
53
-
54
- export { useQuadKeyPayloadsToFeatures }
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './Components/index.ts'
2
- export * from './Contexts/index.ts'
3
- export * from './hooks/index.ts'
4
- export * from './Layers/index.ts'
5
- export * from './MapBoxClasses/index.ts'
@@ -1,20 +0,0 @@
1
- import type { FlexBoxProps } from '@xylabs/react-flexbox'
2
- import type { Feature } from 'geojson'
3
- import type { MapOptions } from 'mapbox-gl'
4
- import type { ReactNode } from 'react'
5
-
6
- import type { MapLayer } from '../Layers/index.ts'
7
-
8
- export interface MapboxFlexBoxProps extends FlexBoxProps {
9
- accessToken: string
10
- developerMode?: boolean
11
- disableControls?: boolean
12
- disableFitToPoints?: boolean
13
- features?: Feature[]
14
- fitToPointsPadding?: number
15
- layers?: MapLayer[]
16
- legend?: ReactNode
17
- mapBoxOptions?: Partial<MapOptions>
18
- requestLocation?: boolean
19
- zoom?: number
20
- }
package/src/lib/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './MapBoxBaseProps.ts'