@xyo-network/react-map 2.41.37 → 2.41.38
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/README.md +4 -61
- package/dist/cjs/Components/AnimatedHeatMap.js +1 -1
- package/dist/cjs/Components/AnimatedHeatMap.js.map +1 -1
- package/dist/cjs/Components/LayerAnimator.js +1 -1
- package/dist/cjs/Components/LayerAnimator.js.map +1 -1
- package/dist/cjs/Components/MapBox.js +1 -1
- package/dist/cjs/Components/MapBox.js.map +1 -1
- package/dist/cjs/Components/MapBoxPoints.js +1 -1
- package/dist/cjs/Components/MapBoxPoints.js.map +1 -1
- package/dist/cjs/Components/MapSettingsComponents/Setting.js +1 -1
- package/dist/cjs/Components/MapSettingsComponents/Setting.js.map +1 -1
- package/dist/cjs/Contexts/HeatMapInitializer/Provider.js +1 -1
- package/dist/cjs/Contexts/HeatMapInitializer/Provider.js.map +1 -1
- package/dist/cjs/MapBoxClasses/XyoMapHeat.js +29 -29
- package/dist/cjs/MapBoxClasses/XyoMapHeat.js.map +1 -1
- package/dist/cjs/MapBoxClasses/XyoMapSettings.js +17 -17
- package/dist/cjs/MapBoxClasses/XyoMapSettings.js.map +1 -1
- package/dist/cjs/hooks/useQuadKeyPayloadsToFeatures.js +1 -1
- package/dist/docs.json +485 -485
- package/dist/esm/Components/AnimatedHeatMap.js +1 -1
- package/dist/esm/Components/AnimatedHeatMap.js.map +1 -1
- package/dist/esm/Components/LayerAnimator.js +1 -1
- package/dist/esm/Components/LayerAnimator.js.map +1 -1
- package/dist/esm/Components/MapBox.js +1 -1
- package/dist/esm/Components/MapBox.js.map +1 -1
- package/dist/esm/Components/MapBoxPoints.js +1 -1
- package/dist/esm/Components/MapBoxPoints.js.map +1 -1
- package/dist/esm/Components/MapSettingsComponents/Setting.js +1 -1
- package/dist/esm/Components/MapSettingsComponents/Setting.js.map +1 -1
- package/dist/esm/Contexts/HeatMapInitializer/Provider.js +1 -1
- package/dist/esm/Contexts/HeatMapInitializer/Provider.js.map +1 -1
- package/dist/esm/MapBoxClasses/XyoMapHeat.js +29 -29
- package/dist/esm/MapBoxClasses/XyoMapHeat.js.map +1 -1
- package/dist/esm/MapBoxClasses/XyoMapSettings.js +19 -19
- package/dist/esm/MapBoxClasses/XyoMapSettings.js.map +1 -1
- package/dist/esm/hooks/useQuadKeyPayloadsToFeatures.js +1 -1
- package/dist/types/Colors/XyoMapColorProps.d.ts +3 -3
- package/dist/types/Colors/XyoMapColorProps.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/LayerAnimator.d.ts +2 -2
- package/dist/types/Components/LayerAnimator.d.ts.map +1 -1
- package/dist/types/Components/MapBox.d.ts +2 -2
- package/dist/types/Components/MapBox.d.ts.map +1 -1
- package/dist/types/Components/MapBoxPoints.d.ts +1 -1
- package/dist/types/Components/MapBoxPoints.d.ts.map +1 -1
- package/dist/types/Components/MapSettingsComponents/Setting.d.ts +1 -1
- package/dist/types/Components/MapSettingsComponents/Setting.d.ts.map +1 -1
- package/dist/types/Contexts/HeatMapInitializer/Provider.d.ts +3 -3
- package/dist/types/Contexts/HeatMapInitializer/Provider.d.ts.map +1 -1
- package/dist/types/Contexts/MapSettings/Provider.d.ts +1 -1
- package/dist/types/Contexts/MapSettings/Provider.d.ts.map +1 -1
- package/dist/types/Contexts/MapSettings/State.d.ts +1 -1
- package/dist/types/Contexts/MapSettings/State.d.ts.map +1 -1
- package/dist/types/MapBoxClasses/XyoMapBase.d.ts +1 -1
- package/dist/types/MapBoxClasses/XyoMapBase.d.ts.map +1 -1
- package/dist/types/MapBoxClasses/XyoMapHeat.d.ts +2 -2
- package/dist/types/MapBoxClasses/XyoMapHeat.d.ts.map +1 -1
- package/dist/types/MapBoxClasses/XyoMapSettings.d.ts +7 -7
- package/dist/types/MapBoxClasses/XyoMapSettings.d.ts.map +1 -1
- package/dist/types/Settings/MapSetting.d.ts +6 -6
- package/dist/types/Settings/MapSetting.d.ts.map +1 -1
- package/dist/types/lib/XyoMapBoxBaseProps.d.ts +3 -3
- package/dist/types/lib/XyoMapBoxBaseProps.d.ts.map +1 -1
- package/dist/types/types/NetworkLocationAnswerBase.d.ts +1 -1
- package/package.json +10 -10
- package/src/Colors/XyoMapColorProps.ts +3 -3
- package/src/Components/AnimatedHeatMap.tsx +3 -3
- package/src/Components/LayerAnimator.tsx +3 -3
- package/src/Components/MapBox.tsx +3 -3
- package/src/Components/MapBoxPoints.tsx +2 -2
- package/src/Components/MapSettingsComponents/Setting.tsx +2 -2
- package/src/Contexts/HeatMapInitializer/Provider.tsx +6 -6
- package/src/Contexts/MapSettings/Provider.tsx +1 -1
- package/src/Contexts/MapSettings/State.ts +1 -1
- package/src/MapBoxClasses/XyoMapBase.ts +1 -1
- package/src/MapBoxClasses/XyoMapHeat.ts +31 -31
- package/src/MapBoxClasses/XyoMapSettings.ts +25 -25
- package/src/Settings/MapSetting.ts +6 -6
- package/src/hooks/useQuadKeyPayloadsToFeatures.tsx +1 -1
- package/src/lib/XyoMapBoxBaseProps.ts +3 -3
- package/src/types/NetworkLocationAnswerBase.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XyoMapSettings.d.ts","sourceRoot":"","sources":["../../../src/MapBoxClasses/XyoMapSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEvH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,WAAW,oBAAoB;IACnC,
|
|
1
|
+
{"version":3,"file":"XyoMapSettings.d.ts","sourceRoot":"","sources":["../../../src/MapBoxClasses/XyoMapSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEvH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,GAAG,EAAE,GAAG,CAAA;IACR,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,EAAE,UAAU,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;GAIG;AACH,qBAAa,cAAc;IACzB,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACrD,MAAM,CAAC,YAAY;uBACF,kBAAkB,GAAG,CAAC,kBAAkB,GAAG,SAAS,CAAC,QAAQ,GAAG;MAOhF;IACD,MAAM,CAAC,UAAU,EAAE,iBAAiB,GAAG,SAAS,CAAA;IAChD,MAAM,CAAC,eAAe,EAAE,OAAO,GAAG,SAAS,CAAA;IAE3C,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,OAAO;IAUpG,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM;IAa/E,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,GAAG;IAW9D,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,GAAG;IAU9D,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,oBAAoB;IAWlD,OAAO,CAAC,MAAM,CAAC,WAAW;IA+B1B,OAAO,CAAC,MAAM,CAAC,cAAc;CAa9B"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export type MapSettingFields = 'debugLayer' | 'fitToPoints' | 'scrollToZoom' | 'enableControls' | 'debugLogging' | 'preferDark' | 'dynamicMapResize';
|
|
2
2
|
export type MapSetting = {
|
|
3
3
|
[field in MapSettingFields | string]: {
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/** Setting only available when application is in developerMode */
|
|
5
|
+
devMode?: boolean;
|
|
6
6
|
/** Machine-readable string to reference setting */
|
|
7
7
|
field: string;
|
|
8
|
-
/** Label in the UI */
|
|
9
|
-
label: string;
|
|
10
8
|
/** Hide the setting from the UI */
|
|
11
9
|
hidden?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
|
|
10
|
+
/** Label in the UI */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Initial toggle value for a setting */
|
|
13
|
+
value: boolean;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=MapSetting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapSetting.d.ts","sourceRoot":"","sources":["../../../src/Settings/MapSetting.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,gBAAgB,GAAG,cAAc,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAEpJ,MAAM,MAAM,UAAU,GAAG;KACtB,KAAK,IAAI,gBAAgB,GAAG,MAAM,GAAG;QACpC,
|
|
1
|
+
{"version":3,"file":"MapSetting.d.ts","sourceRoot":"","sources":["../../../src/Settings/MapSetting.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,gBAAgB,GAAG,cAAc,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAEpJ,MAAM,MAAM,UAAU,GAAG;KACtB,KAAK,IAAI,gBAAgB,GAAG,MAAM,GAAG;QACpC,kEAAkE;QAClE,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,mDAAmD;QACnD,KAAK,EAAE,MAAM,CAAA;QACb,mCAAmC;QACnC,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,sBAAsB;QACtB,KAAK,EAAE,MAAM,CAAA;QACb,yCAAyC;QACzC,KAAK,EAAE,OAAO,CAAA;KACf;CACF,CAAA"}
|
|
@@ -4,16 +4,16 @@ import { MapboxOptions } from 'mapbox-gl';
|
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import { XyoMapLayer } from '../Layers';
|
|
6
6
|
export interface XyoMapboxFlexBoxProps extends FlexBoxProps {
|
|
7
|
+
accessToken: string;
|
|
7
8
|
developerMode?: boolean;
|
|
8
9
|
disableControls?: boolean;
|
|
9
10
|
disableFitToPoints?: boolean;
|
|
10
11
|
features?: Feature[];
|
|
12
|
+
fitToPointsPadding?: number;
|
|
11
13
|
layers?: XyoMapLayer[];
|
|
14
|
+
legend?: ReactNode;
|
|
12
15
|
mapBoxOptions?: Partial<MapboxOptions>;
|
|
13
|
-
fitToPointsPadding?: number;
|
|
14
16
|
requestLocation?: boolean;
|
|
15
17
|
zoom?: number;
|
|
16
|
-
legend?: ReactNode;
|
|
17
|
-
accessToken: string;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=XyoMapBoxBaseProps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XyoMapBoxBaseProps.d.ts","sourceRoot":"","sources":["../../../src/lib/XyoMapBoxBaseProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IACpB,
|
|
1
|
+
{"version":3,"file":"XyoMapBoxBaseProps.d.ts","sourceRoot":"","sources":["../../../src/lib/XyoMapBoxBaseProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IACtC,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -10,7 +10,7 @@ export type NetworkXyoLocationHeatmapAnswerPayload = NetworkLocationAnswerBase<{
|
|
|
10
10
|
features: Feature<Polygon>[];
|
|
11
11
|
}>;
|
|
12
12
|
export type NetworkXyoLocationHeatmapQuadkeyAnswerPayload = NetworkLocationAnswerBase<{
|
|
13
|
-
quadkey: string;
|
|
14
13
|
density: number;
|
|
14
|
+
quadkey: string;
|
|
15
15
|
}[]>;
|
|
16
16
|
//# sourceMappingURL=NetworkLocationAnswerBase.d.ts.map
|
package/package.json
CHANGED
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"@xylabs/forget": "^2.6.16",
|
|
16
16
|
"@xylabs/react-flexbox": "^2.15.11",
|
|
17
17
|
"@xylabs/react-shared": "^2.15.11",
|
|
18
|
-
"@xyo-network/archivist": "^2.43.
|
|
19
|
-
"@xyo-network/module": "^2.43.
|
|
20
|
-
"@xyo-network/payload-model": "^2.43.
|
|
21
|
-
"@xyo-network/react-app-settings": "^2.41.
|
|
22
|
-
"@xyo-network/react-archivist": "^2.41.
|
|
23
|
-
"@xyo-network/react-network": "^2.41.
|
|
24
|
-
"@xyo-network/react-shared": "^2.41.
|
|
18
|
+
"@xyo-network/archivist": "^2.43.22",
|
|
19
|
+
"@xyo-network/module": "^2.43.22",
|
|
20
|
+
"@xyo-network/payload-model": "^2.43.22",
|
|
21
|
+
"@xyo-network/react-app-settings": "^2.41.38",
|
|
22
|
+
"@xyo-network/react-archivist": "^2.41.38",
|
|
23
|
+
"@xyo-network/react-network": "^2.41.38",
|
|
24
|
+
"@xyo-network/react-shared": "^2.41.38",
|
|
25
25
|
"@xyo-network/sdk-geo": "^2.7.0",
|
|
26
26
|
"geojson": "^0.5.0",
|
|
27
27
|
"mapbox-gl": "^2.12.0"
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"description": "Common React library for all XYO projects that use React",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@storybook/react": "^6.5.
|
|
40
|
+
"@storybook/react": "^6.5.16",
|
|
41
41
|
"@types/mapbox-gl": "^2.7.10",
|
|
42
|
-
"@xylabs/ts-scripts-yarn3": "2.12.
|
|
42
|
+
"@xylabs/ts-scripts-yarn3": "2.12.29",
|
|
43
43
|
"require-from-string": "^2.0.2"
|
|
44
44
|
},
|
|
45
45
|
"browser": "dist/esm/index.js",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
},
|
|
85
85
|
"sideEffects": false,
|
|
86
86
|
"types": "dist/types/index.d.ts",
|
|
87
|
-
"version": "2.41.
|
|
87
|
+
"version": "2.41.38"
|
|
88
88
|
}
|
|
@@ -3,16 +3,16 @@ export interface XyoHeatMapColorProps {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export interface XyoAnimatedHeatMapColorProps extends XyoHeatMapColorProps {
|
|
6
|
-
lowUsageColor: string
|
|
7
6
|
highUsageColor: string
|
|
7
|
+
lowUsageColor: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface ColorGradientLegendProps {
|
|
11
|
-
startColor: string
|
|
12
11
|
endColor: string
|
|
12
|
+
endLabel: string
|
|
13
13
|
heading: string
|
|
14
|
+
startColor: string
|
|
14
15
|
startLabel: string
|
|
15
|
-
endLabel: string
|
|
16
16
|
textColor: string
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -11,19 +11,19 @@ import { MapSetting } from '../Settings'
|
|
|
11
11
|
import { XyoMapboxHeatFlexBox } from './MapBoxHeat'
|
|
12
12
|
|
|
13
13
|
export interface AnimatedHeatMapProps {
|
|
14
|
+
accessToken: string
|
|
14
15
|
animatedFeatureSets: Feature<Polygon>[][]
|
|
15
|
-
staticFeatureSet: Feature<Polygon>[]
|
|
16
16
|
defaultMapSettings?: MapSetting
|
|
17
17
|
heatMapColorProps: XyoAnimatedHeatMapColorProps
|
|
18
|
-
|
|
18
|
+
staticFeatureSet: Feature<Polygon>[]
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export const AnimatedHeatMap: React.FC<WithChildren<AnimatedHeatMapProps>> = ({
|
|
22
22
|
accessToken,
|
|
23
23
|
animatedFeatureSets,
|
|
24
24
|
defaultMapSettings,
|
|
25
|
-
staticFeatureSet,
|
|
26
25
|
heatMapColorProps,
|
|
26
|
+
staticFeatureSet,
|
|
27
27
|
...props
|
|
28
28
|
}) => {
|
|
29
29
|
const theme = useTheme()
|
|
@@ -6,16 +6,16 @@ import { XyoMapLayer } from '../Layers'
|
|
|
6
6
|
import { XyoMapboxFlexBoxProps } from '../lib'
|
|
7
7
|
|
|
8
8
|
export interface LayerAnimatorProps {
|
|
9
|
-
map: Map | undefined
|
|
10
9
|
animateLayers?: boolean
|
|
11
|
-
layersInitialized: boolean
|
|
12
10
|
layers: XyoMapboxFlexBoxProps['layers']
|
|
11
|
+
layersInitialized: boolean
|
|
12
|
+
map: Map | undefined
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const timeIncrement = 2000
|
|
16
16
|
const animatedLayerCount = 3
|
|
17
17
|
|
|
18
|
-
export const LayerAnimator: React.FC<WithChildren<LayerAnimatorProps>> = ({ children,
|
|
18
|
+
export const LayerAnimator: React.FC<WithChildren<LayerAnimatorProps>> = ({ animateLayers, children, layers, layersInitialized, map }) => {
|
|
19
19
|
const [fillLayers, setFillLayers] = useState<XyoMapLayer[]>([])
|
|
20
20
|
const layerIndexQueue = useRef<number[]>([])
|
|
21
21
|
|
|
@@ -9,13 +9,13 @@ import { useDynamicMapResize } from '../hooks'
|
|
|
9
9
|
import { XyoMapStyle } from '../lib'
|
|
10
10
|
|
|
11
11
|
export interface MapBoxProps {
|
|
12
|
+
accessToken: string
|
|
13
|
+
darkMode?: boolean
|
|
12
14
|
options?: Partial<MapboxOptions>
|
|
13
15
|
zoom?: number
|
|
14
|
-
darkMode?: boolean
|
|
15
|
-
accessToken: string
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const MapBox: React.FC<MapBoxProps> = ({ accessToken, darkMode = false, zoom = 2,
|
|
18
|
+
export const MapBox: React.FC<MapBoxProps> = ({ accessToken, darkMode = false, options, zoom = 2, ...props }) => {
|
|
19
19
|
const [map, setMap] = useState<Map>()
|
|
20
20
|
const mapContainerRef = useRef<HTMLDivElement | null>(null)
|
|
21
21
|
const mapCanvasRef = useRef<HTMLCanvasElement | null>(null)
|
|
@@ -11,15 +11,15 @@ import { MapBox } from './MapBox'
|
|
|
11
11
|
import { MapSettings } from './MapSettingsComponents'
|
|
12
12
|
|
|
13
13
|
export interface XyoMapboxPointsFlexBoxProps extends XyoMapboxFlexBoxProps {
|
|
14
|
-
features?: Feature<Point>[]
|
|
15
14
|
accessToken: string
|
|
15
|
+
features?: Feature<Point>[]
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const XyoMapboxPointsFlexBox: React.FC<XyoMapboxPointsFlexBoxProps> = ({
|
|
19
19
|
accessToken,
|
|
20
20
|
features,
|
|
21
|
-
layers,
|
|
22
21
|
fitToPointsPadding = 20,
|
|
22
|
+
layers,
|
|
23
23
|
zoom,
|
|
24
24
|
...props
|
|
25
25
|
}) => {
|
|
@@ -3,11 +3,11 @@ import { FormControlLabel, Switch, SwitchProps } from '@mui/material'
|
|
|
3
3
|
import { useMapSettings } from '../../Contexts'
|
|
4
4
|
|
|
5
5
|
export interface MapSettingSwitchProps extends SwitchProps {
|
|
6
|
-
field: string
|
|
7
6
|
developerMode?: boolean
|
|
7
|
+
field: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MapSettingSwitch: React.FC<MapSettingSwitchProps> = ({
|
|
10
|
+
export const MapSettingSwitch: React.FC<MapSettingSwitchProps> = ({ developerMode, field, ...props }) => {
|
|
11
11
|
const { mapSettings, setMapSettings } = useMapSettings()
|
|
12
12
|
const setting = mapSettings?.[field]
|
|
13
13
|
|
|
@@ -13,24 +13,24 @@ import { HeatMapInitializerContext } from './Context'
|
|
|
13
13
|
import { HeatMapInitializerState } from './State'
|
|
14
14
|
|
|
15
15
|
interface MapInitializerProviderProps {
|
|
16
|
-
features?: Feature<Polygon>[]
|
|
17
16
|
featureSets?: Feature<Polygon>[][]
|
|
18
17
|
featureSetsLayers?: XyoMapLayer[]
|
|
19
|
-
|
|
20
|
-
zoom?: number
|
|
18
|
+
features?: Feature<Polygon>[]
|
|
21
19
|
fitToPadding?: number
|
|
22
20
|
heatMapColorProps: XyoHeatMapColorProps | XyoAnimatedHeatMapColorProps
|
|
21
|
+
layers?: XyoMapLayer[]
|
|
22
|
+
zoom?: number
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export const HeatMapInitializerProvider: React.FC<WithChildren<MapInitializerProviderProps>> = ({
|
|
26
26
|
children,
|
|
27
|
-
features,
|
|
28
27
|
featureSets,
|
|
29
28
|
featureSetsLayers,
|
|
30
|
-
|
|
29
|
+
features,
|
|
31
30
|
fitToPadding,
|
|
32
|
-
layers,
|
|
33
31
|
heatMapColorProps,
|
|
32
|
+
layers,
|
|
33
|
+
zoom,
|
|
34
34
|
}) => {
|
|
35
35
|
const [MapHeat, setMapHeat] = useState<XyoMapHeat>()
|
|
36
36
|
const { options } = useDynamicPositioning()
|
|
@@ -8,10 +8,10 @@ import { MapSettingsContext } from './Context'
|
|
|
8
8
|
import { MapSettingsState } from './State'
|
|
9
9
|
|
|
10
10
|
export interface MapSettingsProviderProps {
|
|
11
|
+
debugLayerName?: string
|
|
11
12
|
defaultMapSettings?: MapSetting
|
|
12
13
|
requestLocation?: boolean
|
|
13
14
|
zoom?: number
|
|
14
|
-
debugLayerName?: string
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const MapSettingsProvider: React.FC<WithChildren<MapSettingsProviderProps>> = ({
|
|
@@ -3,6 +3,6 @@ import { Dispatch } from 'react'
|
|
|
3
3
|
import { MapSetting } from '../../Settings'
|
|
4
4
|
|
|
5
5
|
export interface MapSettingsState {
|
|
6
|
-
setMapSettings?: Dispatch<React.SetStateAction<MapSetting>>
|
|
7
6
|
mapSettings?: MapSetting
|
|
7
|
+
setMapSettings?: Dispatch<React.SetStateAction<MapSetting>>
|
|
8
8
|
}
|
|
@@ -17,27 +17,6 @@ export class XyoMapHeat extends XyoMapBase<Polygon> {
|
|
|
17
17
|
this.config = config
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// Build layers each with the same features
|
|
21
|
-
initializeHeatMapSource(layers: XyoMapLayer[]) {
|
|
22
|
-
const getSource = (_: number) => {
|
|
23
|
-
const featuresCollection = GeoJson.featureCollection(this.config.features)
|
|
24
|
-
return GeoJson.featuresSource(featuresCollection)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
layers.forEach((layer, index) => {
|
|
28
|
-
const existingSource = this.config.map.getSource(layer.source as string) as GeoJSONSource
|
|
29
|
-
const source = getSource(index)
|
|
30
|
-
if (existingSource) {
|
|
31
|
-
existingSource.setData(assertEx(source.data) as GeoJSON.Feature<GeoJSON.Geometry> | GeoJSON.FeatureCollection<GeoJSON.Geometry>)
|
|
32
|
-
} else {
|
|
33
|
-
this.config.map.addSource(layer.source as string, source)
|
|
34
|
-
}
|
|
35
|
-
layer.update(this.config.map, true)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
return this
|
|
39
|
-
}
|
|
40
|
-
|
|
41
20
|
static initialMapPositioning(options: FitBoundsOptions, map: Map, features?: Feature<Polygon>[], initialBounds?: LngLatBounds) {
|
|
42
21
|
if (!features) {
|
|
43
22
|
return
|
|
@@ -64,16 +43,6 @@ export class XyoMapHeat extends XyoMapBase<Polygon> {
|
|
|
64
43
|
return this
|
|
65
44
|
}
|
|
66
45
|
|
|
67
|
-
private static updateLayer(map: Map, layer: XyoMapLayer, source: GeoJSONSourceRaw) {
|
|
68
|
-
const existingSource = map.getSource(layer.source as string) as GeoJSONSource
|
|
69
|
-
if (existingSource && source.data) {
|
|
70
|
-
existingSource.setData(source.data as GeoJSON.Feature<GeoJSON.Geometry> | GeoJSON.FeatureCollection<GeoJSON.Geometry>)
|
|
71
|
-
} else if (source) {
|
|
72
|
-
map.addSource(layer.source as string, source)
|
|
73
|
-
}
|
|
74
|
-
layer.update(map, true)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
46
|
static async initializeAnimatedHeatMapSource(
|
|
78
47
|
layers: XyoMapLayer[],
|
|
79
48
|
featureSet: Feature<Polygon>[][],
|
|
@@ -174,4 +143,35 @@ export class XyoMapHeat extends XyoMapBase<Polygon> {
|
|
|
174
143
|
|
|
175
144
|
await startAnimation()
|
|
176
145
|
}
|
|
146
|
+
|
|
147
|
+
private static updateLayer(map: Map, layer: XyoMapLayer, source: GeoJSONSourceRaw) {
|
|
148
|
+
const existingSource = map.getSource(layer.source as string) as GeoJSONSource
|
|
149
|
+
if (existingSource && source.data) {
|
|
150
|
+
existingSource.setData(source.data as GeoJSON.Feature<GeoJSON.Geometry> | GeoJSON.FeatureCollection<GeoJSON.Geometry>)
|
|
151
|
+
} else if (source) {
|
|
152
|
+
map.addSource(layer.source as string, source)
|
|
153
|
+
}
|
|
154
|
+
layer.update(map, true)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Build layers each with the same features
|
|
158
|
+
initializeHeatMapSource(layers: XyoMapLayer[]) {
|
|
159
|
+
const getSource = (_: number) => {
|
|
160
|
+
const featuresCollection = GeoJson.featureCollection(this.config.features)
|
|
161
|
+
return GeoJson.featuresSource(featuresCollection)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
layers.forEach((layer, index) => {
|
|
165
|
+
const existingSource = this.config.map.getSource(layer.source as string) as GeoJSONSource
|
|
166
|
+
const source = getSource(index)
|
|
167
|
+
if (existingSource) {
|
|
168
|
+
existingSource.setData(assertEx(source.data) as GeoJSON.Feature<GeoJSON.Geometry> | GeoJSON.FeatureCollection<GeoJSON.Geometry>)
|
|
169
|
+
} else {
|
|
170
|
+
this.config.map.addSource(layer.source as string, source)
|
|
171
|
+
}
|
|
172
|
+
layer.update(this.config.map, true)
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
return this
|
|
176
|
+
}
|
|
177
177
|
}
|
|
@@ -3,11 +3,11 @@ import { EventData, GeolocateControl, Map, MapLayerMouseEvent, MapLayerTouchEven
|
|
|
3
3
|
import { MapSetting } from '../Settings'
|
|
4
4
|
|
|
5
5
|
export interface XyoMapSettingsConfig {
|
|
6
|
-
|
|
6
|
+
debugLayerName?: string
|
|
7
7
|
map: Map
|
|
8
|
-
zoom?: number
|
|
9
8
|
requestLocation?: boolean
|
|
10
|
-
|
|
9
|
+
settings: MapSetting
|
|
10
|
+
zoom?: number
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -16,9 +16,7 @@ export interface XyoMapSettingsConfig {
|
|
|
16
16
|
* Methods are pure functions dedicated to map manipulation
|
|
17
17
|
*/
|
|
18
18
|
export class XyoMapSettings {
|
|
19
|
-
static navControl: NavigationControl | undefined
|
|
20
19
|
static geoLocateControl: GeolocateControl | undefined
|
|
21
|
-
static requestLocation: boolean | undefined
|
|
22
20
|
static mapListeners = {
|
|
23
21
|
logData: (ev?: MapLayerMouseEvent | (MapLayerTouchEvent & EventData), map?: Map) => {
|
|
24
22
|
const target = map || ev?.target
|
|
@@ -28,16 +26,8 @@ export class XyoMapSettings {
|
|
|
28
26
|
}
|
|
29
27
|
},
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
static
|
|
33
|
-
const { settings, map, zoom, requestLocation, debugLayerName = '' } = config
|
|
34
|
-
const { scrollToZoom, enableControls, debugLayer, debugLogging } = settings
|
|
35
|
-
|
|
36
|
-
XyoMapSettings.toggleControls(enableControls?.value, map, zoom, requestLocation)
|
|
37
|
-
.toggleScrollToZoom(scrollToZoom?.value, map)
|
|
38
|
-
.toggleDebugLayer(debugLayer?.value, map, debugLayerName)
|
|
39
|
-
.toggleDebugLogging(debugLogging.value, map)
|
|
40
|
-
}
|
|
29
|
+
static navControl: NavigationControl | undefined
|
|
30
|
+
static requestLocation: boolean | undefined
|
|
41
31
|
|
|
42
32
|
static toggleControls(value: boolean | undefined, map: Map, zoom?: number, requestLocation?: boolean) {
|
|
43
33
|
if (value) {
|
|
@@ -49,16 +39,6 @@ export class XyoMapSettings {
|
|
|
49
39
|
return this
|
|
50
40
|
}
|
|
51
41
|
|
|
52
|
-
static toggleScrollToZoom(value: boolean | undefined, map: Map) {
|
|
53
|
-
if (value) {
|
|
54
|
-
map.scrollZoom.enable()
|
|
55
|
-
} else {
|
|
56
|
-
map.scrollZoom.disable()
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return this
|
|
60
|
-
}
|
|
61
|
-
|
|
62
42
|
static toggleDebugLayer(value: boolean | undefined, map: Map, layerName: string) {
|
|
63
43
|
const debugLayer = map.getLayer(layerName)
|
|
64
44
|
if (debugLayer) {
|
|
@@ -83,6 +63,26 @@ export class XyoMapSettings {
|
|
|
83
63
|
}
|
|
84
64
|
}
|
|
85
65
|
|
|
66
|
+
static toggleScrollToZoom(value: boolean | undefined, map: Map) {
|
|
67
|
+
if (value) {
|
|
68
|
+
map.scrollZoom.enable()
|
|
69
|
+
} else {
|
|
70
|
+
map.scrollZoom.disable()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return this
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static updateSettings(config: XyoMapSettingsConfig) {
|
|
77
|
+
const { settings, map, zoom, requestLocation, debugLayerName = '' } = config
|
|
78
|
+
const { scrollToZoom, enableControls, debugLayer, debugLogging } = settings
|
|
79
|
+
|
|
80
|
+
XyoMapSettings.toggleControls(enableControls?.value, map, zoom, requestLocation)
|
|
81
|
+
.toggleScrollToZoom(scrollToZoom?.value, map)
|
|
82
|
+
.toggleDebugLayer(debugLayer?.value, map, debugLayerName)
|
|
83
|
+
.toggleDebugLogging(debugLogging.value, map)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
86
|
// Needs to be static so we ensure controls are only instantiated once
|
|
87
87
|
private static addControls(map: Map, zoom?: number, requestLocation?: boolean) {
|
|
88
88
|
const geolocateControl = new GeolocateControl({
|
|
@@ -2,15 +2,15 @@ export type MapSettingFields = 'debugLayer' | 'fitToPoints' | 'scrollToZoom' | '
|
|
|
2
2
|
|
|
3
3
|
export type MapSetting = {
|
|
4
4
|
[field in MapSettingFields | string]: {
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/** Setting only available when application is in developerMode */
|
|
6
|
+
devMode?: boolean
|
|
7
7
|
/** Machine-readable string to reference setting */
|
|
8
8
|
field: string
|
|
9
|
-
/** Label in the UI */
|
|
10
|
-
label: string
|
|
11
9
|
/** Hide the setting from the UI */
|
|
12
10
|
hidden?: boolean
|
|
13
|
-
/**
|
|
14
|
-
|
|
11
|
+
/** Label in the UI */
|
|
12
|
+
label: string
|
|
13
|
+
/** Initial toggle value for a setting */
|
|
14
|
+
value: boolean
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -4,7 +4,7 @@ import { useEffect, useState } from 'react'
|
|
|
4
4
|
|
|
5
5
|
import { NetworkXyoLocationHeatmapQuadkeyAnswerPayload } from '../types'
|
|
6
6
|
|
|
7
|
-
const quadKeyToFeature = ({
|
|
7
|
+
const quadKeyToFeature = ({ density, quadkey }: { density: number; quadkey: string }) => {
|
|
8
8
|
const polygonFeature = new GeoJson(quadkey).polygonFeature()
|
|
9
9
|
polygonFeature.properties = {
|
|
10
10
|
count: density,
|
|
@@ -6,15 +6,15 @@ import { ReactNode } from 'react'
|
|
|
6
6
|
import { XyoMapLayer } from '../Layers'
|
|
7
7
|
|
|
8
8
|
export interface XyoMapboxFlexBoxProps extends FlexBoxProps {
|
|
9
|
+
accessToken: string
|
|
9
10
|
developerMode?: boolean
|
|
10
11
|
disableControls?: boolean
|
|
11
12
|
disableFitToPoints?: boolean
|
|
12
13
|
features?: Feature[]
|
|
14
|
+
fitToPointsPadding?: number
|
|
13
15
|
layers?: XyoMapLayer[]
|
|
16
|
+
legend?: ReactNode
|
|
14
17
|
mapBoxOptions?: Partial<MapboxOptions>
|
|
15
|
-
fitToPointsPadding?: number
|
|
16
18
|
requestLocation?: boolean
|
|
17
19
|
zoom?: number
|
|
18
|
-
legend?: ReactNode
|
|
19
|
-
accessToken: string
|
|
20
20
|
}
|
|
@@ -7,4 +7,4 @@ export interface NetworkLocationAnswerBase<T> extends XyoPayload {
|
|
|
7
7
|
|
|
8
8
|
export type NetworkXyoLocationAnswerPayload = NetworkLocationAnswerBase<{ features: Feature<Point>[] }>
|
|
9
9
|
export type NetworkXyoLocationHeatmapAnswerPayload = NetworkLocationAnswerBase<{ features: Feature<Polygon>[] }>
|
|
10
|
-
export type NetworkXyoLocationHeatmapQuadkeyAnswerPayload = NetworkLocationAnswerBase<{
|
|
10
|
+
export type NetworkXyoLocationHeatmapQuadkeyAnswerPayload = NetworkLocationAnswerBase<{ density: number; quadkey: string }[]>
|