@react-fabric/map 1.0.0-beta.62 → 1.0.1
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/index.js +24 -18
- package/dist/cjs/layers/Json.js +6 -6
- package/dist/cjs/layers/Marker.js +6 -10
- package/dist/cjs/markers/Fill.js +14 -14
- package/dist/cjs/markers/Pin.js +11 -11
- package/dist/cjs/markers/context.js +34 -0
- package/dist/cjs/renderers/Heatmap.js +9 -9
- package/dist/cjs/renderers/Simple.js +5 -4
- package/dist/cjs/tools/BasemapGallery.js +8 -9
- package/dist/cjs/tools/Home.js +21 -22
- package/dist/cjs/tools/LayerList.js +4 -5
- package/dist/cjs/tools/ScaleBar.js +3 -4
- package/dist/cjs/tools/Zoom.js +5 -6
- package/dist/cjs/viewer/{Context.js → Provider.js} +10 -18
- package/dist/cjs/viewer/Viewer.js +4 -4
- package/dist/cjs/viewer/context.js +34 -0
- package/dist/esm/index.js +23 -19
- package/dist/esm/layers/Json.js +5 -5
- package/dist/esm/layers/Marker.js +7 -10
- package/dist/esm/markers/Fill.js +13 -13
- package/dist/esm/markers/Pin.js +9 -9
- package/dist/esm/markers/context.js +33 -0
- package/dist/esm/renderers/Heatmap.js +9 -9
- package/dist/esm/renderers/Simple.js +5 -4
- package/dist/esm/tools/BasemapGallery.js +7 -8
- package/dist/esm/tools/Home.js +20 -21
- package/dist/esm/tools/LayerList.js +4 -5
- package/dist/esm/tools/ScaleBar.js +3 -4
- package/dist/esm/tools/Zoom.js +4 -5
- package/dist/esm/viewer/{Context.js → Provider.js} +12 -19
- package/dist/esm/viewer/Viewer.js +4 -4
- package/dist/esm/viewer/context.js +33 -0
- package/dist/types/index.d.ts +48 -63
- package/dist/types/layers/Json.d.ts +2 -1
- package/dist/types/layers/Marker.d.ts +3 -4
- package/dist/types/markers/Fill.d.ts +3 -2
- package/dist/types/markers/Pin.d.ts +3 -2
- package/dist/types/markers/context.d.ts +3 -0
- package/dist/types/renderers/Cluster.d.ts +4 -4
- package/dist/types/renderers/Heatmap.d.ts +4 -4
- package/dist/types/renderers/Simple.d.ts +1 -1
- package/dist/types/tools/BasemapGallery.d.ts +1 -1
- package/dist/types/tools/Home.d.ts +3 -3
- package/dist/types/tools/LayerList.d.ts +1 -1
- package/dist/types/tools/ScaleBar.d.ts +1 -1
- package/dist/types/tools/Zoom.d.ts +1 -1
- package/dist/types/viewer/Provider.d.ts +5 -0
- package/dist/types/viewer/Viewer.d.ts +1 -1
- package/dist/types/viewer/context.d.ts +18 -0
- package/package.json +16 -22
- package/src/index.ts +23 -18
- package/src/layers/Json.tsx +5 -5
- package/src/layers/Marker.tsx +9 -22
- package/src/markers/Fill.tsx +23 -33
- package/src/markers/Pin.tsx +15 -22
- package/src/markers/context.ts +29 -0
- package/src/renderers/Cluster.tsx +12 -16
- package/src/renderers/Heatmap.tsx +12 -16
- package/src/renderers/Simple.tsx +6 -6
- package/src/tools/BasemapGallery.tsx +11 -28
- package/src/tools/Home.tsx +25 -30
- package/src/tools/LayerList.tsx +7 -13
- package/src/tools/ScaleBar.tsx +5 -4
- package/src/tools/Zoom.tsx +6 -5
- package/src/viewer/{Context.tsx → Provider.tsx} +25 -39
- package/src/viewer/Viewer.tsx +4 -4
- package/src/viewer/context.ts +44 -0
- package/dist/types/viewer/Context.d.ts +0 -16
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/map",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "RUF: ArcGIS Map Component for React",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"repository": "https://github.com/adarshpastakia/react-
|
|
7
|
+
"repository": "https://github.com/adarshpastakia/react-fabric/tree/main/packages/map",
|
|
8
8
|
"source": "src/index.ts",
|
|
9
9
|
"main": "dist/cjs/index.js",
|
|
10
10
|
"module": "dist/esm/index.js",
|
|
@@ -24,8 +24,6 @@
|
|
|
24
24
|
"registry": "https://registry.npmjs.org/"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"makelink": "yarn link",
|
|
28
|
-
"removelink": "yarn unlink",
|
|
29
27
|
"prebuild": "rm -rf ./dist",
|
|
30
28
|
"build:dts": "tsc -p ./tsconfig.build.json",
|
|
31
29
|
"build:rollup": "rollup -c ../../rollup.config.mjs",
|
|
@@ -35,27 +33,23 @@
|
|
|
35
33
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
36
34
|
},
|
|
37
35
|
"dependencies": {
|
|
38
|
-
"@arcgis/core": "~
|
|
39
|
-
"@arcgis/map-components
|
|
40
|
-
"@esri/calcite-components
|
|
41
|
-
"@
|
|
42
|
-
"@react-fabric/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
36
|
+
"@arcgis/core": "~5.1.21",
|
|
37
|
+
"@arcgis/map-components": "~5.1.21",
|
|
38
|
+
"@esri/calcite-components": "~5.1.2",
|
|
39
|
+
"@react-fabric/core": "^1.0.1",
|
|
40
|
+
"@react-fabric/utilities": "^1.0.1",
|
|
41
|
+
"chroma-js": "~3.2.0",
|
|
42
|
+
"dom-to-image": "~2.6.0"
|
|
45
43
|
},
|
|
46
44
|
"peerDependencies": {
|
|
47
|
-
"i18next": "~
|
|
48
|
-
"react": "~19.
|
|
49
|
-
"react-dom": "~19.
|
|
50
|
-
"react-i18next": "~
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@types/dom-to-image": "~2.6.7",
|
|
54
|
-
"@types/highlight.js": "~10.1.0"
|
|
45
|
+
"i18next": "~26.3.6",
|
|
46
|
+
"react": "~19.3.0",
|
|
47
|
+
"react-dom": "~19.3.0",
|
|
48
|
+
"react-i18next": "~17.0.11"
|
|
55
49
|
},
|
|
56
50
|
"engines": {
|
|
57
|
-
"node": ">=
|
|
58
|
-
"npm": ">=
|
|
51
|
+
"node": ">=24.0.0",
|
|
52
|
+
"npm": ">=11.0.0"
|
|
59
53
|
},
|
|
60
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "1419a9df05b5e3850e1d2b4e896ab63df702c7e8"
|
|
61
55
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
2
|
* React Fabric
|
|
3
|
-
* @version
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
4
6
|
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
5
13
|
*
|
|
6
|
-
* The
|
|
7
|
-
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
8
16
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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.
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
22
24
|
*/
|
|
23
25
|
|
|
26
|
+
export const MAP_PACKAGE = "@react-fabric/map";
|
|
27
|
+
export const MAP_VERSION = "1.0.0";
|
|
28
|
+
|
|
24
29
|
import esriConfig from "@arcgis/core/config";
|
|
25
30
|
|
|
26
31
|
import { BasemapGallery as _BasemapGallery } from "./tools/BasemapGallery";
|
|
@@ -38,7 +43,7 @@ import { Pin as _Pin } from "./markers/Pin";
|
|
|
38
43
|
import { useHeatmapRenderer } from "./renderers/Heatmap";
|
|
39
44
|
import { useSimpleRenderer } from "./renderers/Simple";
|
|
40
45
|
|
|
41
|
-
esriConfig.assetsPath = "
|
|
46
|
+
esriConfig.assetsPath = "./assets/@arcgis";
|
|
42
47
|
export const setArcgisAssetsPath = (path: string) => {
|
|
43
48
|
esriConfig.assetsPath = path;
|
|
44
49
|
};
|
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
|
|
28
|
+
export function 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
|
|
|
@@ -48,4 +48,4 @@ export const JsonLayer = (props: __esri.GeoJSONLayerProperties) => {
|
|
|
48
48
|
}, [map, view, layer]);
|
|
49
49
|
|
|
50
50
|
return null;
|
|
51
|
-
}
|
|
51
|
+
}
|
package/src/layers/Marker.tsx
CHANGED
|
@@ -21,34 +21,25 @@
|
|
|
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
|
|
|
43
34
|
/**
|
|
44
35
|
* MarkerLayer component for displaying a layer of markers on the map.
|
|
45
36
|
*/
|
|
46
|
-
export
|
|
37
|
+
export function 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();
|
|
53
44
|
|
|
54
45
|
const layer = useMemo(
|
|
@@ -77,9 +68,5 @@ export const MarkerLayer = ({
|
|
|
77
68
|
}
|
|
78
69
|
}, [layer, map, view]);
|
|
79
70
|
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const useMarkerLayer = () => useContext(MarkerContext);
|
|
71
|
+
return <MarkerContext value={layer}>{children}</MarkerContext>;
|
|
72
|
+
}
|
package/src/markers/Fill.tsx
CHANGED
|
@@ -22,18 +22,18 @@
|
|
|
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
|
-
import { type LngLatLike,
|
|
27
|
+
import { type LngLatLike, convertToLonLat } 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.
|
|
35
35
|
*/
|
|
36
|
-
export
|
|
36
|
+
export function Fill({
|
|
37
37
|
coords,
|
|
38
38
|
style = "solid",
|
|
39
39
|
color = "#f00",
|
|
@@ -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
|
|
|
@@ -64,18 +56,16 @@ export const Fill = ({
|
|
|
64
56
|
() =>
|
|
65
57
|
new Graphic({
|
|
66
58
|
geometry: new Polygon({
|
|
67
|
-
rings: [coords.map(
|
|
59
|
+
rings: [coords.map(convertToLonLat)],
|
|
60
|
+
}),
|
|
61
|
+
symbol: new SimpleFillSymbol({
|
|
62
|
+
style,
|
|
63
|
+
color,
|
|
64
|
+
outline: {
|
|
65
|
+
color: borderColor,
|
|
66
|
+
width: borderWidth,
|
|
67
|
+
},
|
|
68
68
|
}),
|
|
69
|
-
symbol: new SimpleFillSymbol(
|
|
70
|
-
Object.assign({
|
|
71
|
-
style,
|
|
72
|
-
color,
|
|
73
|
-
outline: {
|
|
74
|
-
color: borderColor,
|
|
75
|
-
width: borderWidth,
|
|
76
|
-
},
|
|
77
|
-
} as any),
|
|
78
|
-
),
|
|
79
69
|
...props,
|
|
80
70
|
}),
|
|
81
71
|
[coords, style, color, borderColor, borderWidth, props],
|
|
@@ -83,7 +73,7 @@ export const Fill = ({
|
|
|
83
73
|
|
|
84
74
|
useEffect(() => {
|
|
85
75
|
if (layer && coords) {
|
|
86
|
-
let tmr:
|
|
76
|
+
let tmr: NodeJS.Timeout;
|
|
87
77
|
void layer.when(() => {
|
|
88
78
|
layer.add(graphic);
|
|
89
79
|
if (animate && !is3D) {
|
|
@@ -95,10 +85,10 @@ export const Fill = ({
|
|
|
95
85
|
if (sat >= 0.9) up = -0.1;
|
|
96
86
|
if (sat <= 0.1) up = 0.1;
|
|
97
87
|
sat += up;
|
|
98
|
-
symbol.color =
|
|
88
|
+
symbol.color = chroma
|
|
89
|
+
.rgb(...color)
|
|
99
90
|
.darken(sat)
|
|
100
|
-
.
|
|
101
|
-
.array();
|
|
91
|
+
.rgba();
|
|
102
92
|
requestAnimationFrame(() => {
|
|
103
93
|
graphic.symbol = symbol.clone();
|
|
104
94
|
});
|
|
@@ -111,7 +101,7 @@ export const Fill = ({
|
|
|
111
101
|
layer.remove(graphic);
|
|
112
102
|
};
|
|
113
103
|
}
|
|
114
|
-
}, [layer, graphic, animate, is3D]);
|
|
104
|
+
}, [layer, graphic, animate, is3D, coords]);
|
|
115
105
|
|
|
116
106
|
return null;
|
|
117
|
-
}
|
|
107
|
+
}
|
package/src/markers/Pin.tsx
CHANGED
|
@@ -22,15 +22,15 @@
|
|
|
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
|
-
const paths
|
|
33
|
+
const paths = {
|
|
34
34
|
marker:
|
|
35
35
|
"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z",
|
|
36
36
|
"marker-radius":
|
|
@@ -38,12 +38,12 @@ const paths: Record<Markers, string> = {
|
|
|
38
38
|
pin: "M12 14.571c0.589 0 1.165-0.067 1.714-0.201v8.772c0 0.469-0.388 0.857-0.857 0.857h-1.714c-0.469 0-0.857-0.388-0.857-0.857v-8.772c0.549 0.134 1.125 0.201 1.714 0.201zM12 0c3.79 0 6.857 3.067 6.857 6.857s-3.067 6.857-6.857 6.857-6.857-3.067-6.857-6.857 3.067-6.857 6.857-6.857zM12 3c0.241 0 0.429-0.188 0.429-0.429s-0.188-0.429-0.429-0.429c-2.598 0-4.714 2.116-4.714 4.714 0 0.241 0.188 0.429 0.429 0.429s0.429-0.188 0.429-0.429c0-2.129 1.728-3.857 3.857-3.857z",
|
|
39
39
|
"pin-radius":
|
|
40
40
|
"M12.479 20.11v-0.956c3.218 0.095 5.754 1.127 5.754 2.388 0 1.324-2.79 2.458-6.233 2.458s-6.233-1.134-6.233-2.458c0-1.261 2.536-2.294 5.753-2.388v0.956c-2.687 0.066-4.794 0.682-4.794 1.432 0 0.794 2.361 1.558 5.274 1.558s5.273-0.764 5.273-1.558c-0.001-0.75-2.107-1.364-4.794-1.432zM6.734 5.274c0-2.912 2.421-5.274 5.335-5.274s5.274 2.362 5.274 5.274c0 2.503-1.746 4.595-4.086 5.135l-1.257 12.692-1.261-12.728c-2.268-0.59-4.005-2.646-4.005-5.099zM11.999 3.862c0-0.795-0.644-1.438-1.438-1.438s-1.439 0.643-1.439 1.438c0 0.794 0.644 1.438 1.439 1.438s1.438-0.643 1.438-1.438z",
|
|
41
|
-
};
|
|
41
|
+
} as const;
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Pin graphic for displaying a pin on the map.
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export function Pin({
|
|
47
47
|
coords,
|
|
48
48
|
style = "circle",
|
|
49
49
|
size = 18,
|
|
@@ -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
|
|
|
@@ -80,17 +73,17 @@ export const Pin = ({
|
|
|
80
73
|
symbol: new SimpleMarkerSymbol(
|
|
81
74
|
Object.assign(
|
|
82
75
|
{
|
|
83
|
-
style,
|
|
76
|
+
style: style as never,
|
|
84
77
|
color,
|
|
85
78
|
size,
|
|
86
79
|
outline: {
|
|
87
80
|
color: borderColor,
|
|
88
81
|
width: borderWidth,
|
|
89
82
|
},
|
|
90
|
-
}
|
|
91
|
-
style && style
|
|
83
|
+
},
|
|
84
|
+
style && style in paths
|
|
92
85
|
? {
|
|
93
|
-
path:
|
|
86
|
+
path: paths[style as never],
|
|
94
87
|
style: "path",
|
|
95
88
|
}
|
|
96
89
|
: {},
|
|
@@ -104,7 +97,7 @@ export const Pin = ({
|
|
|
104
97
|
|
|
105
98
|
useEffect(() => {
|
|
106
99
|
if (layer && coords) {
|
|
107
|
-
let tmr:
|
|
100
|
+
let tmr: NodeJS.Timeout;
|
|
108
101
|
void layer.when(() => {
|
|
109
102
|
layer.add(graphic);
|
|
110
103
|
const symbol = graphic.symbol as SimpleMarkerSymbol;
|
|
@@ -129,7 +122,7 @@ export const Pin = ({
|
|
|
129
122
|
layer.remove(graphic);
|
|
130
123
|
};
|
|
131
124
|
}
|
|
132
|
-
}, [layer, graphic, animate, is3D]);
|
|
125
|
+
}, [layer, graphic, animate, is3D, coords]);
|
|
133
126
|
|
|
134
127
|
return null;
|
|
135
|
-
}
|
|
128
|
+
}
|
|
@@ -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 type GraphicsLayer from "@arcgis/core/layers/GraphicsLayer";
|
|
25
|
+
import { createContext, use } from "react";
|
|
26
|
+
|
|
27
|
+
export const MarkerContext = createContext<GraphicsLayer>(null as unknown as GraphicsLayer);
|
|
28
|
+
|
|
29
|
+
export const useMarkerLayer = () => use(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,26 +39,26 @@ 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
|
-
export
|
|
46
|
+
export function useHeatmapRenderer(props?: Props) {
|
|
47
47
|
const renderer = useMemo(() => {
|
|
48
48
|
let colorHigh = "#FFE600FF";
|
|
49
49
|
let colorMid = "#FF8C00FF";
|
|
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
|
|
|
@@ -96,4 +92,4 @@ export const useHeatmapRenderer = (props?: Props) => {
|
|
|
96
92
|
});
|
|
97
93
|
}, [props]);
|
|
98
94
|
return renderer;
|
|
99
|
-
}
|
|
95
|
+
}
|
|
@@ -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,26 +39,26 @@ 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
|
-
export
|
|
46
|
+
export function useHeatmapRenderer(props?: Props) {
|
|
47
47
|
const renderer = useMemo(() => {
|
|
48
48
|
let colorHigh = "#FFE600FF";
|
|
49
49
|
let colorMid = "#FF8C00FF";
|
|
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
|
|
|
@@ -96,4 +92,4 @@ export const useHeatmapRenderer = (props?: Props) => {
|
|
|
96
92
|
});
|
|
97
93
|
}, [props]);
|
|
98
94
|
return renderer;
|
|
99
|
-
}
|
|
95
|
+
}
|
package/src/renderers/Simple.tsx
CHANGED
|
@@ -57,13 +57,13 @@ export interface Props {
|
|
|
57
57
|
colorStops?: Array<{ value: number; color: string }>;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export
|
|
60
|
+
export function useSimpleRenderer(props?: Props) {
|
|
61
61
|
const renderer = useMemo(() => {
|
|
62
62
|
const vizVars = [];
|
|
63
|
-
const styleProps
|
|
63
|
+
const styleProps = { style: props?.style ?? "circle", path: undefined };
|
|
64
64
|
if (props?.path) {
|
|
65
|
-
styleProps.style = "path";
|
|
66
|
-
styleProps.path = props.path;
|
|
65
|
+
styleProps.style = "path" as never;
|
|
66
|
+
styleProps.path = props.path as never;
|
|
67
67
|
}
|
|
68
68
|
if (props?.sizeStops && props.sizeField) {
|
|
69
69
|
vizVars.push({
|
|
@@ -90,8 +90,8 @@ export const useSimpleRenderer = (props?: Props) => {
|
|
|
90
90
|
width: props?.borderWidth ?? 1,
|
|
91
91
|
},
|
|
92
92
|
},
|
|
93
|
-
visualVariables: vizVars,
|
|
93
|
+
visualVariables: vizVars as never,
|
|
94
94
|
});
|
|
95
95
|
}, [props]);
|
|
96
96
|
return renderer;
|
|
97
|
-
}
|
|
97
|
+
}
|