@react-fabric/map 1.0.0-beta.62 → 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
package/src/tools/Home.tsx
CHANGED
|
@@ -29,7 +29,7 @@ import "@arcgis/map-components/components/arcgis-placement";
|
|
|
29
29
|
import { CalciteButton } from "@esri/calcite-components-react";
|
|
30
30
|
import { debounce, getLatitudeLongitude } from "@react-fabric/utilities";
|
|
31
31
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
32
|
-
import { useMap } from "../viewer/
|
|
32
|
+
import { useMap } from "../viewer/context";
|
|
33
33
|
|
|
34
34
|
export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
35
35
|
const { map, view, disableDrag, center, zoom } = useMap();
|
|
@@ -100,10 +100,7 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
|
100
100
|
|
|
101
101
|
return (
|
|
102
102
|
!disableDrag && (
|
|
103
|
-
<ArcgisPlacement
|
|
104
|
-
slot="top-left"
|
|
105
|
-
className="mb-2 flex flex-col divide-y divide-tint-100"
|
|
106
|
-
>
|
|
103
|
+
<ArcgisPlacement slot="top-left" className="mb-2 flex flex-col divide-y divide-tint-100">
|
|
107
104
|
{enableHistory && (
|
|
108
105
|
<CalciteButton
|
|
109
106
|
appearance="solid"
|
|
@@ -113,12 +110,7 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
|
113
110
|
onClick={() => navigate(activeIndex - 1)}
|
|
114
111
|
/>
|
|
115
112
|
)}
|
|
116
|
-
<CalciteButton
|
|
117
|
-
appearance="solid"
|
|
118
|
-
kind="neutral"
|
|
119
|
-
iconStart="home"
|
|
120
|
-
onClick={() => gotoHome()}
|
|
121
|
-
/>
|
|
113
|
+
<CalciteButton appearance="solid" kind="neutral" iconStart="home" onClick={() => gotoHome()} />
|
|
122
114
|
{enableHistory && (
|
|
123
115
|
<CalciteButton
|
|
124
116
|
appearance="solid"
|
package/src/tools/Zoom.tsx
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { ArcgisZoom } from "@arcgis/map-components-react";
|
|
25
25
|
import "@arcgis/map-components/components/arcgis-zoom";
|
|
26
|
-
import { useMap } from "../viewer/
|
|
26
|
+
import { useMap } from "../viewer/context";
|
|
27
27
|
|
|
28
28
|
export const Zoom = () => {
|
|
29
29
|
const { disableZoom } = useMap();
|
|
@@ -25,26 +25,19 @@ import Basemap from "@arcgis/core/Basemap";
|
|
|
25
25
|
import Point from "@arcgis/core/geometry/Point";
|
|
26
26
|
import SpatialReference from "@arcgis/core/geometry/SpatialReference";
|
|
27
27
|
import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
|
|
28
|
+
import type Map from "@arcgis/core/Map";
|
|
29
|
+
import type MapView from "@arcgis/core/views/MapView";
|
|
30
|
+
import type SceneView from "@arcgis/core/views/SceneView";
|
|
28
31
|
import { ArcgisMap, ArcgisScene } from "@arcgis/map-components-react";
|
|
29
32
|
import "@arcgis/map-components/components/arcgis-map";
|
|
30
33
|
import "@arcgis/map-components/components/arcgis-popup";
|
|
31
34
|
import "@arcgis/map-components/components/arcgis-scene";
|
|
32
35
|
import { CalciteButton } from "@esri/calcite-components-react";
|
|
33
|
-
import { getLatitudeLongitude
|
|
34
|
-
import {
|
|
36
|
+
import { getLatitudeLongitude } from "@react-fabric/utilities";
|
|
37
|
+
import { useEffect, useMemo, useState } from "react";
|
|
35
38
|
import { BASEMAPS, DEFAULT_VIEWPOINT } from "../constants";
|
|
36
|
-
import { type
|
|
37
|
-
|
|
38
|
-
const Context = createContext<{
|
|
39
|
-
map?: __esri.Map | null;
|
|
40
|
-
view?: __esri.MapView | __esri.SceneView;
|
|
41
|
-
disableDrag?: boolean;
|
|
42
|
-
disableZoom?: boolean;
|
|
43
|
-
basemaps: FabricBaseMap[];
|
|
44
|
-
center: LngLatLike;
|
|
45
|
-
zoom: number;
|
|
46
|
-
is3D: boolean;
|
|
47
|
-
}>({} as any);
|
|
39
|
+
import { type MapViewerProps } from "../types";
|
|
40
|
+
import { MapContext } from "./context";
|
|
48
41
|
|
|
49
42
|
export const MapProvider = ({
|
|
50
43
|
children,
|
|
@@ -56,14 +49,11 @@ export const MapProvider = ({
|
|
|
56
49
|
disableDrag = false,
|
|
57
50
|
disableZoom = false,
|
|
58
51
|
}: MapViewerProps) => {
|
|
59
|
-
const [map, setMap] = useState<
|
|
60
|
-
const [view, setView] = useState<
|
|
52
|
+
const [map, setMap] = useState<Map | null>(null);
|
|
53
|
+
const [view, setView] = useState<MapView | SceneView>();
|
|
61
54
|
const [is3D, setIs3D] = useState(false);
|
|
62
55
|
|
|
63
|
-
const defaultBaseMap = useMemo(
|
|
64
|
-
() => basemaps.find((b) => b.default) ?? basemaps[0],
|
|
65
|
-
[basemaps],
|
|
66
|
-
);
|
|
56
|
+
const defaultBaseMap = useMemo(() => basemaps.find((b) => b.default) ?? basemaps[0], [basemaps]);
|
|
67
57
|
|
|
68
58
|
useEffect(() => {
|
|
69
59
|
view?.navigation.set("actionMap", {
|
|
@@ -76,7 +66,7 @@ export const MapProvider = ({
|
|
|
76
66
|
|
|
77
67
|
useEffect(() => {
|
|
78
68
|
if (view && onClick) {
|
|
79
|
-
const handleClick = view.on("click", (event
|
|
69
|
+
const handleClick = view.on("click", (event) => {
|
|
80
70
|
event.button === 0 &&
|
|
81
71
|
onClick({
|
|
82
72
|
latitude: event.mapPoint.latitude ?? 0,
|
|
@@ -89,13 +79,10 @@ export const MapProvider = ({
|
|
|
89
79
|
}
|
|
90
80
|
}, [view, onClick]);
|
|
91
81
|
|
|
92
|
-
const E = useMemo(
|
|
93
|
-
() => (enable3D && is3D ? ArcgisScene : ArcgisMap),
|
|
94
|
-
[is3D, enable3D],
|
|
95
|
-
);
|
|
82
|
+
const E = useMemo(() => (enable3D && is3D ? ArcgisScene : ArcgisMap), [is3D, enable3D]);
|
|
96
83
|
|
|
97
84
|
return (
|
|
98
|
-
<
|
|
85
|
+
<MapContext.Provider
|
|
99
86
|
value={{
|
|
100
87
|
map,
|
|
101
88
|
view,
|
|
@@ -153,8 +140,6 @@ export const MapProvider = ({
|
|
|
153
140
|
)}
|
|
154
141
|
{children}
|
|
155
142
|
</E>
|
|
156
|
-
</
|
|
143
|
+
</MapContext.Provider>
|
|
157
144
|
);
|
|
158
145
|
};
|
|
159
|
-
|
|
160
|
-
export const useMap = () => useContext(Context);
|
package/src/viewer/Viewer.tsx
CHANGED
|
@@ -25,7 +25,7 @@ import "@arcgis/core/assets/esri/themes/light/main.css";
|
|
|
25
25
|
import { Section, useIsDark } from "@react-fabric/core";
|
|
26
26
|
import { useEffect } from "react";
|
|
27
27
|
import { type MapViewerProps } from "../types";
|
|
28
|
-
import { MapProvider } from "./
|
|
28
|
+
import { MapProvider } from "./Provider";
|
|
29
29
|
|
|
30
30
|
export const MapViewer = ({ children, ...props }: MapViewerProps) => {
|
|
31
31
|
const isDark = useIsDark();
|
|
@@ -0,0 +1,42 @@
|
|
|
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 Map from "@arcgis/core/Map";
|
|
25
|
+
import MapView from "@arcgis/core/views/MapView";
|
|
26
|
+
import SceneView from "@arcgis/core/views/SceneView";
|
|
27
|
+
import { LngLatLike } from "@react-fabric/utilities";
|
|
28
|
+
import { createContext, useContext } from "react";
|
|
29
|
+
import { FabricBaseMap } from "../types";
|
|
30
|
+
|
|
31
|
+
export const MapContext = createContext<{
|
|
32
|
+
map?: Map | null;
|
|
33
|
+
view?: MapView | SceneView;
|
|
34
|
+
disableDrag?: boolean;
|
|
35
|
+
disableZoom?: boolean;
|
|
36
|
+
basemaps: FabricBaseMap[];
|
|
37
|
+
center: LngLatLike;
|
|
38
|
+
zoom: number;
|
|
39
|
+
is3D: boolean;
|
|
40
|
+
}>({} as any);
|
|
41
|
+
|
|
42
|
+
export const useMap = () => useContext(MapContext);
|
|
@@ -1,16 +0,0 @@
|
|
|
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 LngLatLike } from "@react-fabric/utilities";
|
|
5
|
-
import { type FabricBaseMap, type MapViewerProps } from "../types";
|
|
6
|
-
export declare const MapProvider: ({ children, onClick, basemaps, center, zoom, enable3D, disableDrag, disableZoom, }: MapViewerProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export declare const useMap: () => {
|
|
8
|
-
map?: __esri.Map | null;
|
|
9
|
-
view?: __esri.MapView | __esri.SceneView;
|
|
10
|
-
disableDrag?: boolean;
|
|
11
|
-
disableZoom?: boolean;
|
|
12
|
-
basemaps: FabricBaseMap[];
|
|
13
|
-
center: LngLatLike;
|
|
14
|
-
zoom: number;
|
|
15
|
-
is3D: boolean;
|
|
16
|
-
};
|