@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
|
@@ -21,32 +21,22 @@
|
|
|
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
|
+
/// <reference types="@arcgis/map-components/types/react" />
|
|
25
|
+
|
|
24
26
|
import Basemap from "@arcgis/core/Basemap";
|
|
25
27
|
import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
|
|
26
28
|
import LocalBasemapsSource from "@arcgis/core/widgets/BasemapGallery/support/LocalBasemapsSource";
|
|
27
|
-
import {
|
|
28
|
-
ArcgisBasemapGallery,
|
|
29
|
-
ArcgisBasemapLayerList,
|
|
30
|
-
ArcgisExpand,
|
|
31
|
-
} from "@arcgis/map-components-react";
|
|
32
29
|
import "@arcgis/map-components/components/arcgis-basemap-gallery";
|
|
33
30
|
import "@arcgis/map-components/components/arcgis-basemap-layer-list";
|
|
34
31
|
import "@arcgis/map-components/components/arcgis-expand";
|
|
35
|
-
import { useMap } from "../viewer/
|
|
32
|
+
import { useMap } from "../viewer/context";
|
|
36
33
|
|
|
37
|
-
export
|
|
34
|
+
export function BasemapGallery() {
|
|
38
35
|
const { basemaps, map } = useMap();
|
|
39
36
|
return (
|
|
40
37
|
<>
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
expandIcon="basemap"
|
|
44
|
-
collapseIcon="x"
|
|
45
|
-
mode="floating"
|
|
46
|
-
slot="top-right"
|
|
47
|
-
autoCollapse
|
|
48
|
-
>
|
|
49
|
-
<ArcgisBasemapGallery
|
|
38
|
+
<arcgis-expand className="mb-2" expandIcon="basemap" collapseIcon="x" mode="floating" slot="top-right" autoCollapse>
|
|
39
|
+
<arcgis-basemap-gallery
|
|
50
40
|
source={
|
|
51
41
|
new LocalBasemapsSource({
|
|
52
42
|
basemaps: basemaps.map(
|
|
@@ -73,19 +63,12 @@ export const BasemapGallery = () => {
|
|
|
73
63
|
})
|
|
74
64
|
}
|
|
75
65
|
/>
|
|
76
|
-
</
|
|
66
|
+
</arcgis-expand>
|
|
77
67
|
{(map?.basemap?.baseLayers.length ?? 1) > 1 && (
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
collapseIcon="x"
|
|
82
|
-
mode="floating"
|
|
83
|
-
slot="top-right"
|
|
84
|
-
autoCollapse
|
|
85
|
-
>
|
|
86
|
-
<ArcgisBasemapLayerList />
|
|
87
|
-
</ArcgisExpand>
|
|
68
|
+
<arcgis-expand className="mb-2" expandIcon="layer-map" collapseIcon="x" mode="floating" slot="top-right" autoCollapse>
|
|
69
|
+
<arcgis-basemap-layer-list />
|
|
70
|
+
</arcgis-expand>
|
|
88
71
|
)}
|
|
89
72
|
</>
|
|
90
73
|
);
|
|
91
|
-
}
|
|
74
|
+
}
|
package/src/tools/Home.tsx
CHANGED
|
@@ -21,42 +21,44 @@
|
|
|
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
|
+
/// <reference types="@arcgis/map-components/types/react" />
|
|
25
|
+
/// <reference types="@esri/calcite-components/types/react" />
|
|
26
|
+
|
|
24
27
|
import * as reactiveUtils from "@arcgis/core/core/reactiveUtils";
|
|
28
|
+
import type Extent from "@arcgis/core/geometry/Extent";
|
|
25
29
|
import Point from "@arcgis/core/geometry/Point";
|
|
26
30
|
import Viewpoint from "@arcgis/core/Viewpoint";
|
|
27
|
-
import
|
|
28
|
-
import "@arcgis/map-components/components/arcgis-placement";
|
|
29
|
-
import { CalciteButton } from "@esri/calcite-components-react";
|
|
31
|
+
import "@esri/calcite-components/components/calcite-button";
|
|
30
32
|
import { debounce, getLatitudeLongitude } from "@react-fabric/utilities";
|
|
31
33
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
32
|
-
import { useMap } from "../viewer/
|
|
34
|
+
import { useMap } from "../viewer/context";
|
|
33
35
|
|
|
34
|
-
export
|
|
36
|
+
export function Home({ enableHistory }: { enableHistory?: boolean }) {
|
|
35
37
|
const { map, view, disableDrag, center, zoom } = useMap();
|
|
36
38
|
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const [history, setHistory] = useState<
|
|
39
|
+
const isNavigatingHistoryRef = useRef(false);
|
|
40
|
+
const currentIndexRef = useRef(0);
|
|
41
|
+
const [history, setHistory] = useState<Viewpoint[]>([]);
|
|
40
42
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
41
43
|
|
|
42
44
|
useEffect(() => {
|
|
43
|
-
|
|
45
|
+
currentIndexRef.current = activeIndex;
|
|
44
46
|
}, [activeIndex]);
|
|
45
47
|
|
|
46
48
|
useEffect(() => {
|
|
47
49
|
if (enableHistory && !disableDrag && view) {
|
|
48
|
-
const addHistory = debounce((viewpoint) => {
|
|
49
|
-
if (!
|
|
50
|
+
const addHistory = debounce((viewpoint: Viewpoint) => {
|
|
51
|
+
if (!isNavigatingHistoryRef.current) {
|
|
50
52
|
setHistory((h) => {
|
|
51
53
|
// Keep max 25 history entries
|
|
52
|
-
const newHistory = h.slice(0,
|
|
54
|
+
const newHistory = h.slice(0, currentIndexRef.current + 1).slice(-24);
|
|
53
55
|
// Add new viewpoint to history
|
|
54
56
|
newHistory.push(viewpoint.clone());
|
|
55
57
|
setActiveIndex(newHistory.length - 1);
|
|
56
58
|
return newHistory;
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
|
-
|
|
61
|
+
isNavigatingHistoryRef.current = false;
|
|
60
62
|
});
|
|
61
63
|
const watcher = reactiveUtils.watch(() => view.viewpoint, addHistory);
|
|
62
64
|
return () => {
|
|
@@ -68,19 +70,20 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
|
68
70
|
const navigate = useCallback(
|
|
69
71
|
(idx: number) => {
|
|
70
72
|
if (history.length > 0 && history[idx] && view) {
|
|
71
|
-
|
|
73
|
+
isNavigatingHistoryRef.current = true;
|
|
72
74
|
void view.goTo(history[idx]);
|
|
73
75
|
setActiveIndex(idx);
|
|
74
76
|
}
|
|
75
77
|
},
|
|
76
|
-
[history],
|
|
78
|
+
[history, view],
|
|
77
79
|
);
|
|
78
80
|
|
|
79
81
|
const gotoHome = useCallback(() => {
|
|
80
82
|
if (view) {
|
|
81
|
-
let extent:
|
|
83
|
+
let extent: Extent | undefined = undefined;
|
|
82
84
|
map?.layers.forEach((layer) => {
|
|
83
85
|
if (layer.visible && layer.fullExtent) {
|
|
86
|
+
console.log(layer.type, layer.fullExtent);
|
|
84
87
|
if (extent) {
|
|
85
88
|
extent = extent.union(layer.fullExtent);
|
|
86
89
|
} else {
|
|
@@ -100,12 +103,9 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
|
100
103
|
|
|
101
104
|
return (
|
|
102
105
|
!disableDrag && (
|
|
103
|
-
<
|
|
104
|
-
slot="top-left"
|
|
105
|
-
className="mb-2 flex flex-col divide-y divide-tint-100"
|
|
106
|
-
>
|
|
106
|
+
<div slot="top-left" className="mb-2 flex flex-col divide-y divide-tint-100">
|
|
107
107
|
{enableHistory && (
|
|
108
|
-
<
|
|
108
|
+
<calcite-button
|
|
109
109
|
appearance="solid"
|
|
110
110
|
kind="neutral"
|
|
111
111
|
iconStart="arrow-left"
|
|
@@ -113,14 +113,9 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
|
113
113
|
onClick={() => navigate(activeIndex - 1)}
|
|
114
114
|
/>
|
|
115
115
|
)}
|
|
116
|
-
<
|
|
117
|
-
appearance="solid"
|
|
118
|
-
kind="neutral"
|
|
119
|
-
iconStart="home"
|
|
120
|
-
onClick={() => gotoHome()}
|
|
121
|
-
/>
|
|
116
|
+
<calcite-button appearance="solid" kind="neutral" iconStart="home" onClick={() => gotoHome()} />
|
|
122
117
|
{enableHistory && (
|
|
123
|
-
<
|
|
118
|
+
<calcite-button
|
|
124
119
|
appearance="solid"
|
|
125
120
|
kind="neutral"
|
|
126
121
|
iconStart="arrow-right"
|
|
@@ -128,7 +123,7 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
|
128
123
|
onClick={() => navigate(activeIndex + 1)}
|
|
129
124
|
/>
|
|
130
125
|
)}
|
|
131
|
-
</
|
|
126
|
+
</div>
|
|
132
127
|
)
|
|
133
128
|
);
|
|
134
|
-
}
|
|
129
|
+
}
|
package/src/tools/LayerList.tsx
CHANGED
|
@@ -21,21 +21,15 @@
|
|
|
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
|
-
|
|
24
|
+
/// <reference types="@arcgis/map-components/types/react" />
|
|
25
|
+
|
|
25
26
|
import "@arcgis/map-components/components/arcgis-expand";
|
|
26
27
|
import "@arcgis/map-components/components/arcgis-layer-list";
|
|
27
28
|
|
|
28
|
-
export
|
|
29
|
+
export function LayerList() {
|
|
29
30
|
return (
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
collapseIcon="x"
|
|
34
|
-
mode="floating"
|
|
35
|
-
slot="top-right"
|
|
36
|
-
autoCollapse
|
|
37
|
-
>
|
|
38
|
-
<ArcgisLayerList />
|
|
39
|
-
</ArcgisExpand>
|
|
31
|
+
<arcgis-expand expandIcon="layers" className="mb-2" collapseIcon="x" mode="floating" slot="top-right" autoCollapse>
|
|
32
|
+
<arcgis-layer-list />
|
|
33
|
+
</arcgis-expand>
|
|
40
34
|
);
|
|
41
|
-
}
|
|
35
|
+
}
|
package/src/tools/ScaleBar.tsx
CHANGED
|
@@ -21,9 +21,10 @@
|
|
|
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
|
-
|
|
24
|
+
/// <reference types="@arcgis/map-components/types/react" />
|
|
25
|
+
|
|
25
26
|
import "@arcgis/map-components/components/arcgis-scale-bar";
|
|
26
27
|
|
|
27
|
-
export
|
|
28
|
-
return <
|
|
29
|
-
}
|
|
28
|
+
export function ScaleBar() {
|
|
29
|
+
return <arcgis-scale-bar slot="bottom-left" />;
|
|
30
|
+
}
|
package/src/tools/Zoom.tsx
CHANGED
|
@@ -21,11 +21,12 @@
|
|
|
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
|
-
|
|
24
|
+
/// <reference types="@arcgis/map-components/types/react" />
|
|
25
|
+
|
|
25
26
|
import "@arcgis/map-components/components/arcgis-zoom";
|
|
26
|
-
import { useMap } from "../viewer/
|
|
27
|
+
import { useMap } from "../viewer/context";
|
|
27
28
|
|
|
28
|
-
export
|
|
29
|
+
export function Zoom() {
|
|
29
30
|
const { disableZoom } = useMap();
|
|
30
|
-
return !disableZoom && <
|
|
31
|
-
}
|
|
31
|
+
return !disableZoom && <arcgis-zoom slot="top-left" className="mb-2" />;
|
|
32
|
+
}
|
|
@@ -21,32 +21,26 @@
|
|
|
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
|
+
/// <reference types="@arcgis/map-components/types/react" />
|
|
25
|
+
/// <reference types="@esri/calcite-components/types/react" />
|
|
26
|
+
|
|
24
27
|
import Basemap from "@arcgis/core/Basemap";
|
|
25
28
|
import Point from "@arcgis/core/geometry/Point";
|
|
26
29
|
import SpatialReference from "@arcgis/core/geometry/SpatialReference";
|
|
27
30
|
import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
|
|
28
|
-
import
|
|
31
|
+
import type Map from "@arcgis/core/Map";
|
|
32
|
+
import type MapView from "@arcgis/core/views/MapView";
|
|
33
|
+
import type SceneView from "@arcgis/core/views/SceneView";
|
|
29
34
|
import "@arcgis/map-components/components/arcgis-map";
|
|
30
35
|
import "@arcgis/map-components/components/arcgis-popup";
|
|
31
36
|
import "@arcgis/map-components/components/arcgis-scene";
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
|
37
|
+
import { getLatitudeLongitude } from "@react-fabric/utilities";
|
|
38
|
+
import { useEffect, useMemo, useState } from "react";
|
|
35
39
|
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);
|
|
40
|
+
import { type MapViewerProps } from "../types";
|
|
41
|
+
import { MapContext } from "./context";
|
|
48
42
|
|
|
49
|
-
export
|
|
43
|
+
export function MapProvider({
|
|
50
44
|
children,
|
|
51
45
|
onClick,
|
|
52
46
|
basemaps = BASEMAPS,
|
|
@@ -55,15 +49,12 @@ export const MapProvider = ({
|
|
|
55
49
|
enable3D = false,
|
|
56
50
|
disableDrag = false,
|
|
57
51
|
disableZoom = false,
|
|
58
|
-
}: MapViewerProps)
|
|
59
|
-
const [map, setMap] = useState<
|
|
60
|
-
const [view, setView] = useState<
|
|
52
|
+
}: MapViewerProps) {
|
|
53
|
+
const [map, setMap] = useState<Map | null>(null);
|
|
54
|
+
const [view, setView] = useState<MapView | SceneView>();
|
|
61
55
|
const [is3D, setIs3D] = useState(false);
|
|
62
56
|
|
|
63
|
-
const defaultBaseMap = useMemo(
|
|
64
|
-
() => basemaps.find((b) => b.default) ?? basemaps[0],
|
|
65
|
-
[basemaps],
|
|
66
|
-
);
|
|
57
|
+
const defaultBaseMap = useMemo(() => basemaps.find((b) => b.default) ?? basemaps[0], [basemaps]);
|
|
67
58
|
|
|
68
59
|
useEffect(() => {
|
|
69
60
|
view?.navigation.set("actionMap", {
|
|
@@ -76,8 +67,8 @@ export const MapProvider = ({
|
|
|
76
67
|
|
|
77
68
|
useEffect(() => {
|
|
78
69
|
if (view && onClick) {
|
|
79
|
-
const handleClick = view.on("click", (event
|
|
80
|
-
event.button === 0
|
|
70
|
+
const handleClick = view.on("click", (event) => {
|
|
71
|
+
if (event.button === 0)
|
|
81
72
|
onClick({
|
|
82
73
|
latitude: event.mapPoint.latitude ?? 0,
|
|
83
74
|
longitude: event.mapPoint.longitude ?? 0,
|
|
@@ -89,13 +80,10 @@ export const MapProvider = ({
|
|
|
89
80
|
}
|
|
90
81
|
}, [view, onClick]);
|
|
91
82
|
|
|
92
|
-
const E =
|
|
93
|
-
() => (enable3D && is3D ? ArcgisScene : ArcgisMap),
|
|
94
|
-
[is3D, enable3D],
|
|
95
|
-
);
|
|
83
|
+
const E = enable3D && is3D ? "arcgis-scene" : "arcgis-map";
|
|
96
84
|
|
|
97
85
|
return (
|
|
98
|
-
<
|
|
86
|
+
<MapContext
|
|
99
87
|
value={{
|
|
100
88
|
map,
|
|
101
89
|
view,
|
|
@@ -108,9 +96,9 @@ export const MapProvider = ({
|
|
|
108
96
|
}}
|
|
109
97
|
>
|
|
110
98
|
<E
|
|
111
|
-
|
|
112
|
-
e.target.map
|
|
113
|
-
e.target.view
|
|
99
|
+
onarcgisViewReadyChange={(e) => {
|
|
100
|
+
if (e.target.map) setMap(e.target.map);
|
|
101
|
+
if (e.target.view) setView(e.target.view);
|
|
114
102
|
}}
|
|
115
103
|
className="area-content overflow-hidden"
|
|
116
104
|
basemap={
|
|
@@ -142,7 +130,7 @@ export const MapProvider = ({
|
|
|
142
130
|
}
|
|
143
131
|
>
|
|
144
132
|
{enable3D && (
|
|
145
|
-
<
|
|
133
|
+
<calcite-button
|
|
146
134
|
appearance="solid"
|
|
147
135
|
kind="neutral"
|
|
148
136
|
slot="top-right"
|
|
@@ -153,8 +141,6 @@ export const MapProvider = ({
|
|
|
153
141
|
)}
|
|
154
142
|
{children}
|
|
155
143
|
</E>
|
|
156
|
-
</
|
|
144
|
+
</MapContext>
|
|
157
145
|
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export const useMap = () => useContext(Context);
|
|
146
|
+
}
|
package/src/viewer/Viewer.tsx
CHANGED
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import "@arcgis/core/assets/esri/themes/light/main.css";
|
|
25
|
-
import {
|
|
25
|
+
import { Layout, 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();
|
|
@@ -35,8 +35,8 @@ export const MapViewer = ({ children, ...props }: MapViewerProps) => {
|
|
|
35
35
|
}, [isDark]);
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
|
-
<
|
|
38
|
+
<Layout className="relative">
|
|
39
39
|
<MapProvider {...props}>{children}</MapProvider>
|
|
40
|
-
</
|
|
40
|
+
</Layout>
|
|
41
41
|
);
|
|
42
42
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
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 Map from "@arcgis/core/Map";
|
|
25
|
+
import type MapView from "@arcgis/core/views/MapView";
|
|
26
|
+
import type SceneView from "@arcgis/core/views/SceneView";
|
|
27
|
+
import type { LngLatLike } from "@react-fabric/utilities";
|
|
28
|
+
import { createContext, use } from "react";
|
|
29
|
+
import type { FabricBaseMap } from "../types";
|
|
30
|
+
|
|
31
|
+
interface ContextType {
|
|
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
|
+
}
|
|
41
|
+
|
|
42
|
+
export const MapContext = createContext<ContextType>({} as ContextType);
|
|
43
|
+
|
|
44
|
+
export const useMap = () => use(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
|
-
};
|