@react-fabric/map 1.0.0-beta.61 → 1.0.0-beta.63
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/layers/Json.js +3 -3
- package/dist/cjs/layers/Marker.js +4 -8
- package/dist/cjs/markers/Fill.js +6 -7
- package/dist/cjs/markers/Pin.js +4 -4
- package/dist/cjs/markers/context.js +34 -0
- package/dist/cjs/renderers/Heatmap.js +7 -7
- package/dist/cjs/tools/BasemapGallery.js +2 -2
- package/dist/cjs/tools/Home.js +4 -4
- package/dist/cjs/tools/Zoom.js +2 -2
- package/dist/cjs/viewer/{Context.js → Provider.js} +2 -6
- package/dist/cjs/viewer/Viewer.js +2 -2
- package/dist/cjs/viewer/context.js +34 -0
- package/dist/esm/layers/Json.js +2 -2
- package/dist/esm/layers/Marker.js +4 -7
- package/dist/esm/markers/Fill.js +4 -5
- package/dist/esm/markers/Pin.js +2 -2
- package/dist/esm/markers/context.js +33 -0
- package/dist/esm/renderers/Heatmap.js +7 -7
- package/dist/esm/tools/BasemapGallery.js +1 -1
- package/dist/esm/tools/Home.js +3 -3
- package/dist/esm/tools/Zoom.js +1 -1
- package/dist/esm/viewer/{Context.js → Provider.js} +4 -7
- package/dist/esm/viewer/Viewer.js +1 -1
- package/dist/esm/viewer/context.js +33 -0
- package/dist/types/index.d.ts +10 -10
- package/dist/types/layers/Json.d.ts +2 -1
- package/dist/types/layers/Marker.d.ts +2 -3
- package/dist/types/markers/Fill.d.ts +2 -1
- package/dist/types/markers/Pin.d.ts +2 -1
- package/dist/types/markers/context.d.ts +3 -0
- package/dist/types/renderers/Cluster.d.ts +3 -3
- package/dist/types/renderers/Heatmap.d.ts +3 -3
- package/dist/types/viewer/Provider.d.ts +5 -0
- package/dist/types/viewer/context.d.ts +25 -0
- package/package.json +13 -13
- package/src/layers/Json.tsx +4 -4
- package/src/layers/Marker.tsx +6 -19
- package/src/markers/Fill.tsx +8 -17
- package/src/markers/Pin.tsx +5 -12
- package/src/markers/context.ts +29 -0
- package/src/renderers/Cluster.tsx +10 -14
- package/src/renderers/Heatmap.tsx +10 -14
- package/src/renderers/Simple.tsx +1 -1
- package/src/tools/BasemapGallery.tsx +4 -22
- package/src/tools/Home.tsx +3 -11
- package/src/tools/Zoom.tsx +1 -1
- package/src/viewer/{Context.tsx → Provider.tsx} +14 -29
- package/src/viewer/Viewer.tsx +1 -1
- package/src/viewer/context.ts +42 -0
- package/dist/types/viewer/Context.d.ts +0 -16
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useContext, createContext } from 'react';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* React Fabric
|
|
7
|
+
* @version: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* The MIT License (MIT)
|
|
11
|
+
* Copyright (c) 2026 Adarsh Pastakia
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
14
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
15
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
16
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
17
|
+
* subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
20
|
+
* portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
23
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
24
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
25
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
var MapContext = /*#__PURE__*/createContext({});
|
|
29
|
+
var useMap = function useMap() {
|
|
30
|
+
return useContext(MapContext);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { MapContext, useMap };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare namespace MapTools {
|
|
|
10
10
|
}) => false | import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
}
|
|
12
12
|
export declare namespace MapLayers {
|
|
13
|
-
const Markers: ({ children, ...props }: Omit<
|
|
13
|
+
const Markers: ({ children, ...props }: Omit<import("@arcgis/core/layers/GraphicsLayer").GraphicsLayerProperties, "graphics"> & {
|
|
14
14
|
children?: import("react").ReactElement<(({ coords, style, color, borderWidth, borderColor, animate, ...props }: {
|
|
15
15
|
coords: import("@react-fabric/utilities").LngLatLike[];
|
|
16
16
|
color?: string;
|
|
@@ -18,7 +18,7 @@ export declare namespace MapLayers {
|
|
|
18
18
|
borderWidth?: string | number;
|
|
19
19
|
borderColor?: string;
|
|
20
20
|
animate?: boolean;
|
|
21
|
-
} & Omit<
|
|
21
|
+
} & Omit<import("@arcgis/core/Graphic").GraphicProperties, "geometry" | "symbol">) => null) | (({ coords, style, size, color, path, borderWidth, borderColor, animate, ...props }: {
|
|
22
22
|
coords: import("@react-fabric/utilities").LngLatLike;
|
|
23
23
|
size?: string | number;
|
|
24
24
|
color?: string;
|
|
@@ -27,14 +27,14 @@ export declare namespace MapLayers {
|
|
|
27
27
|
borderWidth?: string | number;
|
|
28
28
|
borderColor?: string;
|
|
29
29
|
animate?: boolean;
|
|
30
|
-
} & Omit<
|
|
30
|
+
} & Omit<import("@arcgis/core/Graphic").GraphicProperties, "geometry" | "symbol">) => null), string | import("react").JSXElementConstructor<any>> | import("react").ReactElement<(({ coords, style, color, borderWidth, borderColor, animate, ...props }: {
|
|
31
31
|
coords: import("@react-fabric/utilities").LngLatLike[];
|
|
32
32
|
color?: string;
|
|
33
33
|
style?: "backward-diagonal" | "cross" | "diagonal-cross" | "forward-diagonal" | "horizontal" | "none" | "solid" | "vertical";
|
|
34
34
|
borderWidth?: string | number;
|
|
35
35
|
borderColor?: string;
|
|
36
36
|
animate?: boolean;
|
|
37
|
-
} & Omit<
|
|
37
|
+
} & Omit<import("@arcgis/core/Graphic").GraphicProperties, "geometry" | "symbol">) => null) | (({ coords, style, size, color, path, borderWidth, borderColor, animate, ...props }: {
|
|
38
38
|
coords: import("@react-fabric/utilities").LngLatLike;
|
|
39
39
|
size?: string | number;
|
|
40
40
|
color?: string;
|
|
@@ -43,9 +43,9 @@ export declare namespace MapLayers {
|
|
|
43
43
|
borderWidth?: string | number;
|
|
44
44
|
borderColor?: string;
|
|
45
45
|
animate?: boolean;
|
|
46
|
-
} & Omit<
|
|
46
|
+
} & Omit<import("@arcgis/core/Graphic").GraphicProperties, "geometry" | "symbol">) => null), string | import("react").JSXElementConstructor<any>>[];
|
|
47
47
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
48
|
-
const Json: (props:
|
|
48
|
+
const Json: (props: import("@arcgis/core/layers/GeoJSONLayer").GeoJSONLayerProperties) => null;
|
|
49
49
|
}
|
|
50
50
|
export declare namespace MapMarkers {
|
|
51
51
|
const Fill: ({ coords, style, color, borderWidth, borderColor, animate, ...props }: {
|
|
@@ -55,7 +55,7 @@ export declare namespace MapMarkers {
|
|
|
55
55
|
borderWidth?: string | number;
|
|
56
56
|
borderColor?: string;
|
|
57
57
|
animate?: boolean;
|
|
58
|
-
} & Omit<
|
|
58
|
+
} & Omit<import("@arcgis/core/Graphic").GraphicProperties, "geometry" | "symbol">) => null;
|
|
59
59
|
const Pin: ({ coords, style, size, color, path, borderWidth, borderColor, animate, ...props }: {
|
|
60
60
|
coords: import("@react-fabric/utilities").LngLatLike;
|
|
61
61
|
size?: string | number;
|
|
@@ -65,9 +65,9 @@ export declare namespace MapMarkers {
|
|
|
65
65
|
borderWidth?: string | number;
|
|
66
66
|
borderColor?: string;
|
|
67
67
|
animate?: boolean;
|
|
68
|
-
} & Omit<
|
|
68
|
+
} & Omit<import("@arcgis/core/Graphic").GraphicProperties, "geometry" | "symbol">) => null;
|
|
69
69
|
}
|
|
70
70
|
export declare namespace MapRenderers {
|
|
71
|
-
const useSimple: (props?: import("./renderers/Simple").Props) =>
|
|
72
|
-
const useHeatmap: (props?: import("./renderers/Heatmap").Props) =>
|
|
71
|
+
const useSimple: (props?: import("./renderers/Simple").Props) => import("@arcgis/core/renderers/SimpleRenderer").default;
|
|
72
|
+
const useHeatmap: (props?: import("./renderers/Heatmap").Props) => import("@arcgis/core/renderers/HeatmapRenderer").default;
|
|
73
73
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { type GeoJSONLayerProperties } from "@arcgis/core/layers/GeoJSONLayer";
|
|
2
|
+
export declare const JsonLayer: (props: GeoJSONLayerProperties) => null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type GraphicsLayerProperties } from "@arcgis/core/layers/GraphicsLayer";
|
|
2
2
|
import "@arcgis/map-components/components/arcgis-features";
|
|
3
3
|
import { type ReactElement } from "react";
|
|
4
4
|
import { type Fill } from "../markers/Fill";
|
|
@@ -7,8 +7,7 @@ type MarkerChildren = ReactElement<typeof Fill | typeof Pin>;
|
|
|
7
7
|
/**
|
|
8
8
|
* MarkerLayer component for displaying a layer of markers on the map.
|
|
9
9
|
*/
|
|
10
|
-
export declare const MarkerLayer: ({ children, ...props }: Omit<
|
|
10
|
+
export declare const MarkerLayer: ({ children, ...props }: Omit<GraphicsLayerProperties, "graphics"> & {
|
|
11
11
|
children?: MarkerChildren | MarkerChildren[];
|
|
12
12
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export declare const useMarkerLayer: () => GraphicsLayer;
|
|
14
13
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type GraphicProperties } from "@arcgis/core/Graphic";
|
|
1
2
|
import { type LngLatLike } from "@react-fabric/utilities";
|
|
2
3
|
/**
|
|
3
4
|
* Fill graphic for displaying a fill polygon on the map.
|
|
@@ -9,4 +10,4 @@ export declare const Fill: ({ coords, style, color, borderWidth, borderColor, an
|
|
|
9
10
|
borderWidth?: string | number;
|
|
10
11
|
borderColor?: string;
|
|
11
12
|
animate?: boolean;
|
|
12
|
-
} & Omit<
|
|
13
|
+
} & Omit<GraphicProperties, "geometry" | "symbol">) => null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type GraphicProperties } from "@arcgis/core/Graphic";
|
|
1
2
|
import { type LngLatLike } from "@react-fabric/utilities";
|
|
2
3
|
type Markers = "pin" | "pin-radius" | "marker" | "marker-radius";
|
|
3
4
|
/**
|
|
@@ -12,5 +13,5 @@ export declare const Pin: ({ coords, style, size, color, path, borderWidth, bord
|
|
|
12
13
|
borderWidth?: string | number;
|
|
13
14
|
borderColor?: string;
|
|
14
15
|
animate?: boolean;
|
|
15
|
-
} & Omit<
|
|
16
|
+
} & Omit<GraphicProperties, "geometry" | "symbol">) => null;
|
|
16
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import HeatmapRenderer from "@arcgis/core/renderers/HeatmapRenderer";
|
|
1
|
+
import HeatmapRenderer, { type HeatmapRendererProperties } from "@arcgis/core/renderers/HeatmapRenderer";
|
|
2
2
|
interface Props {
|
|
3
3
|
/**
|
|
4
4
|
* Field name to be used for heatmap intensity
|
|
@@ -12,8 +12,8 @@ interface Props {
|
|
|
12
12
|
* [color1, color2, color3]: creates a multi-stop gradient color1 to color2 to color3
|
|
13
13
|
*/
|
|
14
14
|
colors?: string[];
|
|
15
|
-
minDensity?:
|
|
16
|
-
maxDensity?:
|
|
15
|
+
minDensity?: HeatmapRendererProperties["minDensity"];
|
|
16
|
+
maxDensity?: HeatmapRendererProperties["maxDensity"];
|
|
17
17
|
}
|
|
18
18
|
export declare const useHeatmapRenderer: (props?: Props) => HeatmapRenderer;
|
|
19
19
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import HeatmapRenderer from "@arcgis/core/renderers/HeatmapRenderer";
|
|
1
|
+
import HeatmapRenderer, { type HeatmapRendererProperties } from "@arcgis/core/renderers/HeatmapRenderer";
|
|
2
2
|
export interface Props {
|
|
3
3
|
/**
|
|
4
4
|
* Field name to be used for heatmap intensity
|
|
@@ -12,7 +12,7 @@ export interface Props {
|
|
|
12
12
|
* [color1, color2, color3]: creates a multi-stop gradient color1 to color2 to color3
|
|
13
13
|
*/
|
|
14
14
|
colors?: string[];
|
|
15
|
-
minDensity?:
|
|
16
|
-
maxDensity?:
|
|
15
|
+
minDensity?: HeatmapRendererProperties["minDensity"];
|
|
16
|
+
maxDensity?: HeatmapRendererProperties["maxDensity"];
|
|
17
17
|
}
|
|
18
18
|
export declare const useHeatmapRenderer: (props?: Props) => HeatmapRenderer;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "@arcgis/map-components/components/arcgis-map";
|
|
2
|
+
import "@arcgis/map-components/components/arcgis-popup";
|
|
3
|
+
import "@arcgis/map-components/components/arcgis-scene";
|
|
4
|
+
import { type MapViewerProps } from "../types";
|
|
5
|
+
export declare const MapProvider: ({ children, onClick, basemaps, center, zoom, enable3D, disableDrag, disableZoom, }: MapViewerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Map from "@arcgis/core/Map";
|
|
2
|
+
import MapView from "@arcgis/core/views/MapView";
|
|
3
|
+
import SceneView from "@arcgis/core/views/SceneView";
|
|
4
|
+
import { LngLatLike } from "@react-fabric/utilities";
|
|
5
|
+
import { FabricBaseMap } from "../types";
|
|
6
|
+
export declare const MapContext: import("react").Context<{
|
|
7
|
+
map?: Map | null;
|
|
8
|
+
view?: MapView | SceneView;
|
|
9
|
+
disableDrag?: boolean;
|
|
10
|
+
disableZoom?: boolean;
|
|
11
|
+
basemaps: FabricBaseMap[];
|
|
12
|
+
center: LngLatLike;
|
|
13
|
+
zoom: number;
|
|
14
|
+
is3D: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const useMap: () => {
|
|
17
|
+
map?: Map | null;
|
|
18
|
+
view?: MapView | SceneView;
|
|
19
|
+
disableDrag?: boolean;
|
|
20
|
+
disableZoom?: boolean;
|
|
21
|
+
basemaps: FabricBaseMap[];
|
|
22
|
+
center: LngLatLike;
|
|
23
|
+
zoom: number;
|
|
24
|
+
is3D: boolean;
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/map",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.63",
|
|
4
4
|
"description": "RUF: ArcGIS Map Component for React",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,27 +35,27 @@
|
|
|
35
35
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@arcgis/core": "~
|
|
38
|
+
"@arcgis/core": "~5.0.10",
|
|
39
39
|
"@arcgis/map-components-react": "~4.34.5",
|
|
40
40
|
"@esri/calcite-components-react": "~3.3.3",
|
|
41
|
-
"@
|
|
42
|
-
"@react-fabric/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
41
|
+
"@react-fabric/core": "^1.0.0-beta.63",
|
|
42
|
+
"@react-fabric/utilities": "^1.0.0-beta.63",
|
|
43
|
+
"chroma-js": "~3.2.0",
|
|
44
|
+
"dom-to-image": "~2.6.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"i18next": "~25.
|
|
48
|
-
"react": "~19.2.
|
|
49
|
-
"react-dom": "~19.2.
|
|
50
|
-
"react-i18next": "~16.
|
|
47
|
+
"i18next": "~25.8.18",
|
|
48
|
+
"react": "~19.2.4",
|
|
49
|
+
"react-dom": "~19.2.4",
|
|
50
|
+
"react-i18next": "~16.5.8"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/dom-to-image": "~2.6.7",
|
|
54
54
|
"@types/highlight.js": "~10.1.0"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
|
-
"node": ">=18.
|
|
58
|
-
"npm": ">=8.
|
|
57
|
+
"node": ">=22.18.0",
|
|
58
|
+
"npm": ">=10.8.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "6e0652b15c6384fbc316842862572e21299a5466"
|
|
61
61
|
}
|
package/src/layers/Json.tsx
CHANGED
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import GeoJSONLayer from "@arcgis/core/layers/GeoJSONLayer";
|
|
24
|
+
import GeoJSONLayer, { type GeoJSONLayerProperties } from "@arcgis/core/layers/GeoJSONLayer";
|
|
25
25
|
import { useEffect, useMemo } from "react";
|
|
26
|
-
import { useMap } from "../viewer/
|
|
26
|
+
import { useMap } from "../viewer/context";
|
|
27
27
|
|
|
28
|
-
export const JsonLayer = (props:
|
|
28
|
+
export const JsonLayer = (props: GeoJSONLayerProperties) => {
|
|
29
29
|
const { map, view } = useMap();
|
|
30
30
|
|
|
31
31
|
const layer = useMemo(() => {
|
|
@@ -37,7 +37,7 @@ export const JsonLayer = (props: __esri.GeoJSONLayerProperties) => {
|
|
|
37
37
|
useEffect(() => {
|
|
38
38
|
if (map && view) {
|
|
39
39
|
void layer.when(() => {
|
|
40
|
-
void view.goTo(layer.fullExtent);
|
|
40
|
+
void (layer.fullExtent && view.goTo(layer.fullExtent));
|
|
41
41
|
});
|
|
42
42
|
map.add(layer);
|
|
43
43
|
|
package/src/layers/Marker.tsx
CHANGED
|
@@ -21,22 +21,13 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer";
|
|
24
|
+
import GraphicsLayer, { type GraphicsLayerProperties } from "@arcgis/core/layers/GraphicsLayer";
|
|
25
25
|
import "@arcgis/map-components/components/arcgis-features";
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
type ReactElement,
|
|
29
|
-
useContext,
|
|
30
|
-
useEffect,
|
|
31
|
-
useMemo,
|
|
32
|
-
} from "react";
|
|
26
|
+
import { type ReactElement, useEffect, useMemo } from "react";
|
|
27
|
+
import { MarkerContext } from "../markers/context";
|
|
33
28
|
import { type Fill } from "../markers/Fill";
|
|
34
29
|
import { type Pin } from "../markers/Pin";
|
|
35
|
-
import { useMap } from "../viewer/
|
|
36
|
-
|
|
37
|
-
const MarkerContext = createContext<__esri.GraphicsLayer>(
|
|
38
|
-
null as unknown as __esri.GraphicsLayer,
|
|
39
|
-
);
|
|
30
|
+
import { useMap } from "../viewer/context";
|
|
40
31
|
|
|
41
32
|
type MarkerChildren = ReactElement<typeof Fill | typeof Pin>;
|
|
42
33
|
|
|
@@ -46,7 +37,7 @@ type MarkerChildren = ReactElement<typeof Fill | typeof Pin>;
|
|
|
46
37
|
export const MarkerLayer = ({
|
|
47
38
|
children,
|
|
48
39
|
...props
|
|
49
|
-
}: Omit<
|
|
40
|
+
}: Omit<GraphicsLayerProperties, "graphics"> & {
|
|
50
41
|
children?: MarkerChildren | MarkerChildren[];
|
|
51
42
|
}) => {
|
|
52
43
|
const { map, view } = useMap();
|
|
@@ -77,9 +68,5 @@ export const MarkerLayer = ({
|
|
|
77
68
|
}
|
|
78
69
|
}, [layer, map, view]);
|
|
79
70
|
|
|
80
|
-
return
|
|
81
|
-
<MarkerContext.Provider value={layer}>{children}</MarkerContext.Provider>
|
|
82
|
-
);
|
|
71
|
+
return <MarkerContext.Provider value={layer}>{children}</MarkerContext.Provider>;
|
|
83
72
|
};
|
|
84
|
-
|
|
85
|
-
export const useMarkerLayer = () => useContext(MarkerContext);
|
package/src/markers/Fill.tsx
CHANGED
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import Polygon from "@arcgis/core/geometry/Polygon";
|
|
25
|
-
import Graphic from "@arcgis/core/Graphic";
|
|
25
|
+
import Graphic, { type GraphicProperties } from "@arcgis/core/Graphic";
|
|
26
26
|
import SimpleFillSymbol from "@arcgis/core/symbols/SimpleFillSymbol";
|
|
27
27
|
import { type LngLatLike, convertLatLng } from "@react-fabric/utilities";
|
|
28
|
+
import chroma from "chroma-js";
|
|
28
29
|
import { useEffect, useMemo } from "react";
|
|
29
|
-
import {
|
|
30
|
-
import
|
|
31
|
-
import { useMap } from "../viewer/Context";
|
|
30
|
+
import { useMap } from "../viewer/context";
|
|
31
|
+
import { useMarkerLayer } from "./context";
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Fill graphic for displaying a fill polygon on the map.
|
|
@@ -44,19 +44,11 @@ export const Fill = ({
|
|
|
44
44
|
}: {
|
|
45
45
|
coords: LngLatLike[];
|
|
46
46
|
color?: string;
|
|
47
|
-
style?:
|
|
48
|
-
| "backward-diagonal"
|
|
49
|
-
| "cross"
|
|
50
|
-
| "diagonal-cross"
|
|
51
|
-
| "forward-diagonal"
|
|
52
|
-
| "horizontal"
|
|
53
|
-
| "none"
|
|
54
|
-
| "solid"
|
|
55
|
-
| "vertical";
|
|
47
|
+
style?: "backward-diagonal" | "cross" | "diagonal-cross" | "forward-diagonal" | "horizontal" | "none" | "solid" | "vertical";
|
|
56
48
|
borderWidth?: string | number;
|
|
57
49
|
borderColor?: string;
|
|
58
50
|
animate?: boolean;
|
|
59
|
-
} & Omit<
|
|
51
|
+
} & Omit<GraphicProperties, "geometry" | "symbol">) => {
|
|
60
52
|
const layer = useMarkerLayer();
|
|
61
53
|
const { is3D } = useMap();
|
|
62
54
|
|
|
@@ -95,10 +87,9 @@ export const Fill = ({
|
|
|
95
87
|
if (sat >= 0.9) up = -0.1;
|
|
96
88
|
if (sat <= 0.1) up = 0.1;
|
|
97
89
|
sat += up;
|
|
98
|
-
symbol.color =
|
|
90
|
+
symbol.color = chroma(color as any)
|
|
99
91
|
.darken(sat)
|
|
100
|
-
.
|
|
101
|
-
.array();
|
|
92
|
+
.rgba();
|
|
102
93
|
requestAnimationFrame(() => {
|
|
103
94
|
graphic.symbol = symbol.clone();
|
|
104
95
|
});
|
package/src/markers/Pin.tsx
CHANGED
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import Point from "@arcgis/core/geometry/Point";
|
|
25
|
-
import Graphic from "@arcgis/core/Graphic";
|
|
25
|
+
import Graphic, { type GraphicProperties } from "@arcgis/core/Graphic";
|
|
26
26
|
import SimpleMarkerSymbol from "@arcgis/core/symbols/SimpleMarkerSymbol";
|
|
27
27
|
import { type LngLatLike, getLatitudeLongitude } from "@react-fabric/utilities";
|
|
28
28
|
import { useEffect, useMemo } from "react";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
29
|
+
import { useMap } from "../viewer/context";
|
|
30
|
+
import { useMarkerLayer } from "./context";
|
|
31
31
|
|
|
32
32
|
type Markers = "pin" | "pin-radius" | "marker" | "marker-radius";
|
|
33
33
|
const paths: Record<Markers, string> = {
|
|
@@ -58,18 +58,11 @@ export const Pin = ({
|
|
|
58
58
|
size?: string | number;
|
|
59
59
|
color?: string;
|
|
60
60
|
path?: string;
|
|
61
|
-
style?:
|
|
62
|
-
| "circle"
|
|
63
|
-
| "square"
|
|
64
|
-
| "cross"
|
|
65
|
-
| "x"
|
|
66
|
-
| "diamond"
|
|
67
|
-
| "triangle"
|
|
68
|
-
| Markers;
|
|
61
|
+
style?: "circle" | "square" | "cross" | "x" | "diamond" | "triangle" | Markers;
|
|
69
62
|
borderWidth?: string | number;
|
|
70
63
|
borderColor?: string;
|
|
71
64
|
animate?: boolean;
|
|
72
|
-
} & Omit<
|
|
65
|
+
} & Omit<GraphicProperties, "geometry" | "symbol">) => {
|
|
73
66
|
const layer = useMarkerLayer();
|
|
74
67
|
const { is3D } = useMap();
|
|
75
68
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2026 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer";
|
|
25
|
+
import { createContext, useContext } from "react";
|
|
26
|
+
|
|
27
|
+
export const MarkerContext = createContext<GraphicsLayer>(null as unknown as GraphicsLayer);
|
|
28
|
+
|
|
29
|
+
export const useMarkerLayer = () => useContext(MarkerContext);
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import HeatmapRenderer from "@arcgis/core/renderers/HeatmapRenderer";
|
|
25
|
-
import
|
|
24
|
+
import HeatmapRenderer, { type HeatmapRendererProperties } from "@arcgis/core/renderers/HeatmapRenderer";
|
|
25
|
+
import chroma from "chroma-js";
|
|
26
26
|
import { useMemo } from "react";
|
|
27
27
|
|
|
28
28
|
interface Props {
|
|
@@ -39,8 +39,8 @@ interface Props {
|
|
|
39
39
|
*/
|
|
40
40
|
colors?: string[];
|
|
41
41
|
|
|
42
|
-
minDensity?:
|
|
43
|
-
maxDensity?:
|
|
42
|
+
minDensity?: HeatmapRendererProperties["minDensity"];
|
|
43
|
+
maxDensity?: HeatmapRendererProperties["maxDensity"];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export const useHeatmapRenderer = (props?: Props) => {
|
|
@@ -50,15 +50,15 @@ export const useHeatmapRenderer = (props?: Props) => {
|
|
|
50
50
|
let colorLow = "#FF3300FF";
|
|
51
51
|
|
|
52
52
|
if (props?.colors?.length === 1) {
|
|
53
|
-
colorHigh =
|
|
54
|
-
colorLow =
|
|
55
|
-
colorMid =
|
|
53
|
+
colorHigh = chroma(props.colors[0]).luminance(0.85, "oklab").hex();
|
|
54
|
+
colorLow = chroma(props.colors[0]).luminance(0.25, "oklab").hex();
|
|
55
|
+
colorMid = chroma.mix(colorHigh, colorLow, 0.5).hex();
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
if (props?.colors?.length === 2) {
|
|
59
59
|
colorHigh = props.colors[0];
|
|
60
60
|
colorLow = props.colors[1];
|
|
61
|
-
colorMid =
|
|
61
|
+
colorMid = chroma.mix(colorHigh, colorLow, 0.5).hex();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (props?.colors?.length === 3) {
|
|
@@ -76,15 +76,11 @@ export const useHeatmapRenderer = (props?: Props) => {
|
|
|
76
76
|
: [
|
|
77
77
|
...Array.from({ length: 6 }, (_, i) => ({
|
|
78
78
|
ratio: (i + 1) / 12,
|
|
79
|
-
color:
|
|
80
|
-
.mix(Color(colorMid), i / 6)
|
|
81
|
-
.toString(),
|
|
79
|
+
color: chroma.mix(colorLow, colorMid, i / 6).hex(),
|
|
82
80
|
})),
|
|
83
81
|
...Array.from({ length: 6 }, (_, i) => ({
|
|
84
82
|
ratio: (i + 6) / 12,
|
|
85
|
-
color:
|
|
86
|
-
.mix(Color(colorHigh), i / 6)
|
|
87
|
-
.toString(),
|
|
83
|
+
color: chroma.mix(colorMid, colorHigh, i / 6).hex(),
|
|
88
84
|
})),
|
|
89
85
|
];
|
|
90
86
|
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import HeatmapRenderer from "@arcgis/core/renderers/HeatmapRenderer";
|
|
25
|
-
import
|
|
24
|
+
import HeatmapRenderer, { type HeatmapRendererProperties } from "@arcgis/core/renderers/HeatmapRenderer";
|
|
25
|
+
import chroma from "chroma-js";
|
|
26
26
|
import { useMemo } from "react";
|
|
27
27
|
|
|
28
28
|
export interface Props {
|
|
@@ -39,8 +39,8 @@ export interface Props {
|
|
|
39
39
|
*/
|
|
40
40
|
colors?: string[];
|
|
41
41
|
|
|
42
|
-
minDensity?:
|
|
43
|
-
maxDensity?:
|
|
42
|
+
minDensity?: HeatmapRendererProperties["minDensity"];
|
|
43
|
+
maxDensity?: HeatmapRendererProperties["maxDensity"];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export const useHeatmapRenderer = (props?: Props) => {
|
|
@@ -50,15 +50,15 @@ export const useHeatmapRenderer = (props?: Props) => {
|
|
|
50
50
|
let colorLow = "#FF3300FF";
|
|
51
51
|
|
|
52
52
|
if (props?.colors?.length === 1) {
|
|
53
|
-
colorHigh =
|
|
54
|
-
colorLow =
|
|
55
|
-
colorMid =
|
|
53
|
+
colorHigh = chroma(props.colors[0]).luminance(0.85, "oklab").hex();
|
|
54
|
+
colorLow = chroma(props.colors[0]).luminance(0.25, "oklab").hex();
|
|
55
|
+
colorMid = chroma.mix(colorHigh, colorLow, 0.5).hex();
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
if (props?.colors?.length === 2) {
|
|
59
59
|
colorHigh = props.colors[0];
|
|
60
60
|
colorLow = props.colors[1];
|
|
61
|
-
colorMid =
|
|
61
|
+
colorMid = chroma.mix(colorHigh, colorLow, 0.5).hex();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (props?.colors?.length === 3) {
|
|
@@ -76,15 +76,11 @@ export const useHeatmapRenderer = (props?: Props) => {
|
|
|
76
76
|
: [
|
|
77
77
|
...Array.from({ length: 6 }, (_, i) => ({
|
|
78
78
|
ratio: (i + 1) / 12,
|
|
79
|
-
color:
|
|
80
|
-
.mix(Color(colorMid), i / 6)
|
|
81
|
-
.toString(),
|
|
79
|
+
color: chroma.mix(colorLow, colorMid, i / 6).hex(),
|
|
82
80
|
})),
|
|
83
81
|
...Array.from({ length: 6 }, (_, i) => ({
|
|
84
82
|
ratio: (i + 6) / 12,
|
|
85
|
-
color:
|
|
86
|
-
.mix(Color(colorHigh), i / 6)
|
|
87
|
-
.toString(),
|
|
83
|
+
color: chroma.mix(colorMid, colorHigh, i / 6).hex(),
|
|
88
84
|
})),
|
|
89
85
|
];
|
|
90
86
|
|
package/src/renderers/Simple.tsx
CHANGED
|
@@ -24,28 +24,17 @@
|
|
|
24
24
|
import Basemap from "@arcgis/core/Basemap";
|
|
25
25
|
import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
|
|
26
26
|
import LocalBasemapsSource from "@arcgis/core/widgets/BasemapGallery/support/LocalBasemapsSource";
|
|
27
|
-
import {
|
|
28
|
-
ArcgisBasemapGallery,
|
|
29
|
-
ArcgisBasemapLayerList,
|
|
30
|
-
ArcgisExpand,
|
|
31
|
-
} from "@arcgis/map-components-react";
|
|
27
|
+
import { ArcgisBasemapGallery, ArcgisBasemapLayerList, ArcgisExpand } from "@arcgis/map-components-react";
|
|
32
28
|
import "@arcgis/map-components/components/arcgis-basemap-gallery";
|
|
33
29
|
import "@arcgis/map-components/components/arcgis-basemap-layer-list";
|
|
34
30
|
import "@arcgis/map-components/components/arcgis-expand";
|
|
35
|
-
import { useMap } from "../viewer/
|
|
31
|
+
import { useMap } from "../viewer/context";
|
|
36
32
|
|
|
37
33
|
export const BasemapGallery = () => {
|
|
38
34
|
const { basemaps, map } = useMap();
|
|
39
35
|
return (
|
|
40
36
|
<>
|
|
41
|
-
<ArcgisExpand
|
|
42
|
-
className="mb-2"
|
|
43
|
-
expandIcon="basemap"
|
|
44
|
-
collapseIcon="x"
|
|
45
|
-
mode="floating"
|
|
46
|
-
slot="top-right"
|
|
47
|
-
autoCollapse
|
|
48
|
-
>
|
|
37
|
+
<ArcgisExpand className="mb-2" expandIcon="basemap" collapseIcon="x" mode="floating" slot="top-right" autoCollapse>
|
|
49
38
|
<ArcgisBasemapGallery
|
|
50
39
|
source={
|
|
51
40
|
new LocalBasemapsSource({
|
|
@@ -75,14 +64,7 @@ export const BasemapGallery = () => {
|
|
|
75
64
|
/>
|
|
76
65
|
</ArcgisExpand>
|
|
77
66
|
{(map?.basemap?.baseLayers.length ?? 1) > 1 && (
|
|
78
|
-
<ArcgisExpand
|
|
79
|
-
className="mb-2"
|
|
80
|
-
expandIcon="layer-map"
|
|
81
|
-
collapseIcon="x"
|
|
82
|
-
mode="floating"
|
|
83
|
-
slot="top-right"
|
|
84
|
-
autoCollapse
|
|
85
|
-
>
|
|
67
|
+
<ArcgisExpand className="mb-2" expandIcon="layer-map" collapseIcon="x" mode="floating" slot="top-right" autoCollapse>
|
|
86
68
|
<ArcgisBasemapLayerList />
|
|
87
69
|
</ArcgisExpand>
|
|
88
70
|
)}
|