@react-fabric/map 1.0.0-beta.63 → 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 +3 -3
- package/dist/cjs/layers/Marker.js +3 -3
- package/dist/cjs/markers/Fill.js +10 -9
- package/dist/cjs/markers/Pin.js +7 -7
- package/dist/cjs/markers/context.js +1 -1
- package/dist/cjs/renderers/Heatmap.js +2 -2
- package/dist/cjs/renderers/Simple.js +5 -4
- package/dist/cjs/tools/BasemapGallery.js +6 -7
- package/dist/cjs/tools/Home.js +17 -18
- package/dist/cjs/tools/LayerList.js +4 -5
- package/dist/cjs/tools/ScaleBar.js +3 -4
- package/dist/cjs/tools/Zoom.js +3 -4
- package/dist/cjs/viewer/Provider.js +9 -13
- package/dist/cjs/viewer/Viewer.js +2 -2
- package/dist/cjs/viewer/context.js +1 -1
- package/dist/esm/index.js +23 -19
- package/dist/esm/layers/Json.js +3 -3
- package/dist/esm/layers/Marker.js +3 -3
- package/dist/esm/markers/Fill.js +11 -10
- package/dist/esm/markers/Pin.js +7 -7
- package/dist/esm/markers/context.js +2 -2
- package/dist/esm/renderers/Heatmap.js +2 -2
- package/dist/esm/renderers/Simple.js +5 -4
- package/dist/esm/tools/BasemapGallery.js +6 -7
- package/dist/esm/tools/Home.js +17 -18
- package/dist/esm/tools/LayerList.js +4 -5
- package/dist/esm/tools/ScaleBar.js +3 -4
- package/dist/esm/tools/Zoom.js +3 -4
- package/dist/esm/viewer/Provider.js +9 -13
- package/dist/esm/viewer/Viewer.js +3 -3
- package/dist/esm/viewer/context.js +2 -2
- package/dist/types/index.d.ts +48 -63
- package/dist/types/layers/Json.d.ts +1 -1
- package/dist/types/layers/Marker.d.ts +2 -2
- package/dist/types/markers/Fill.d.ts +2 -2
- package/dist/types/markers/Pin.d.ts +2 -2
- package/dist/types/markers/context.d.ts +1 -1
- package/dist/types/renderers/Cluster.d.ts +1 -1
- package/dist/types/renderers/Heatmap.d.ts +1 -1
- 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 +1 -1
- package/dist/types/viewer/Viewer.d.ts +1 -1
- package/dist/types/viewer/context.d.ts +10 -17
- package/package.json +14 -20
- package/src/index.ts +23 -18
- package/src/layers/Json.tsx +2 -2
- package/src/layers/Marker.tsx +4 -4
- package/src/markers/Fill.tsx +17 -18
- package/src/markers/Pin.tsx +11 -11
- package/src/markers/context.ts +3 -3
- package/src/renderers/Cluster.tsx +2 -2
- package/src/renderers/Heatmap.tsx +2 -2
- package/src/renderers/Simple.tsx +6 -6
- package/src/tools/BasemapGallery.tsx +10 -9
- package/src/tools/Home.tsx +24 -21
- package/src/tools/LayerList.tsx +7 -13
- package/src/tools/ScaleBar.tsx +5 -4
- package/src/tools/Zoom.tsx +5 -4
- package/src/viewer/Provider.tsx +14 -13
- package/src/viewer/Viewer.tsx +3 -3
- package/src/viewer/context.ts +11 -9
|
@@ -43,7 +43,7 @@ export interface Props {
|
|
|
43
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";
|
|
@@ -92,4 +92,4 @@ export const useHeatmapRenderer = (props?: Props) => {
|
|
|
92
92
|
});
|
|
93
93
|
}, [props]);
|
|
94
94
|
return renderer;
|
|
95
|
-
}
|
|
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 as
|
|
93
|
+
visualVariables: vizVars as never,
|
|
94
94
|
});
|
|
95
95
|
}, [props]);
|
|
96
96
|
return renderer;
|
|
97
|
-
}
|
|
97
|
+
}
|
|
@@ -21,21 +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 { ArcgisBasemapGallery, ArcgisBasemapLayerList, ArcgisExpand } from "@arcgis/map-components-react";
|
|
28
29
|
import "@arcgis/map-components/components/arcgis-basemap-gallery";
|
|
29
30
|
import "@arcgis/map-components/components/arcgis-basemap-layer-list";
|
|
30
31
|
import "@arcgis/map-components/components/arcgis-expand";
|
|
31
32
|
import { useMap } from "../viewer/context";
|
|
32
33
|
|
|
33
|
-
export
|
|
34
|
+
export function BasemapGallery() {
|
|
34
35
|
const { basemaps, map } = useMap();
|
|
35
36
|
return (
|
|
36
37
|
<>
|
|
37
|
-
<
|
|
38
|
-
<
|
|
38
|
+
<arcgis-expand className="mb-2" expandIcon="basemap" collapseIcon="x" mode="floating" slot="top-right" autoCollapse>
|
|
39
|
+
<arcgis-basemap-gallery
|
|
39
40
|
source={
|
|
40
41
|
new LocalBasemapsSource({
|
|
41
42
|
basemaps: basemaps.map(
|
|
@@ -62,12 +63,12 @@ export const BasemapGallery = () => {
|
|
|
62
63
|
})
|
|
63
64
|
}
|
|
64
65
|
/>
|
|
65
|
-
</
|
|
66
|
+
</arcgis-expand>
|
|
66
67
|
{(map?.basemap?.baseLayers.length ?? 1) > 1 && (
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
</
|
|
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>
|
|
70
71
|
)}
|
|
71
72
|
</>
|
|
72
73
|
);
|
|
73
|
-
}
|
|
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
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,9 +103,9 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
|
100
103
|
|
|
101
104
|
return (
|
|
102
105
|
!disableDrag && (
|
|
103
|
-
<
|
|
106
|
+
<div slot="top-left" className="mb-2 flex flex-col divide-y divide-tint-100">
|
|
104
107
|
{enableHistory && (
|
|
105
|
-
<
|
|
108
|
+
<calcite-button
|
|
106
109
|
appearance="solid"
|
|
107
110
|
kind="neutral"
|
|
108
111
|
iconStart="arrow-left"
|
|
@@ -110,9 +113,9 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
|
110
113
|
onClick={() => navigate(activeIndex - 1)}
|
|
111
114
|
/>
|
|
112
115
|
)}
|
|
113
|
-
<
|
|
116
|
+
<calcite-button appearance="solid" kind="neutral" iconStart="home" onClick={() => gotoHome()} />
|
|
114
117
|
{enableHistory && (
|
|
115
|
-
<
|
|
118
|
+
<calcite-button
|
|
116
119
|
appearance="solid"
|
|
117
120
|
kind="neutral"
|
|
118
121
|
iconStart="arrow-right"
|
|
@@ -120,7 +123,7 @@ export const Home = ({ enableHistory }: { enableHistory?: boolean }) => {
|
|
|
120
123
|
onClick={() => navigate(activeIndex + 1)}
|
|
121
124
|
/>
|
|
122
125
|
)}
|
|
123
|
-
</
|
|
126
|
+
</div>
|
|
124
127
|
)
|
|
125
128
|
);
|
|
126
|
-
}
|
|
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
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
|
+
}
|
package/src/viewer/Provider.tsx
CHANGED
|
@@ -21,6 +21,9 @@
|
|
|
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";
|
|
@@ -28,18 +31,16 @@ import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer";
|
|
|
28
31
|
import type Map from "@arcgis/core/Map";
|
|
29
32
|
import type MapView from "@arcgis/core/views/MapView";
|
|
30
33
|
import type SceneView from "@arcgis/core/views/SceneView";
|
|
31
|
-
import { ArcgisMap, ArcgisScene } from "@arcgis/map-components-react";
|
|
32
34
|
import "@arcgis/map-components/components/arcgis-map";
|
|
33
35
|
import "@arcgis/map-components/components/arcgis-popup";
|
|
34
36
|
import "@arcgis/map-components/components/arcgis-scene";
|
|
35
|
-
import { CalciteButton } from "@esri/calcite-components-react";
|
|
36
37
|
import { getLatitudeLongitude } from "@react-fabric/utilities";
|
|
37
38
|
import { useEffect, useMemo, useState } from "react";
|
|
38
39
|
import { BASEMAPS, DEFAULT_VIEWPOINT } from "../constants";
|
|
39
40
|
import { type MapViewerProps } from "../types";
|
|
40
41
|
import { MapContext } from "./context";
|
|
41
42
|
|
|
42
|
-
export
|
|
43
|
+
export function MapProvider({
|
|
43
44
|
children,
|
|
44
45
|
onClick,
|
|
45
46
|
basemaps = BASEMAPS,
|
|
@@ -48,7 +49,7 @@ export const MapProvider = ({
|
|
|
48
49
|
enable3D = false,
|
|
49
50
|
disableDrag = false,
|
|
50
51
|
disableZoom = false,
|
|
51
|
-
}: MapViewerProps)
|
|
52
|
+
}: MapViewerProps) {
|
|
52
53
|
const [map, setMap] = useState<Map | null>(null);
|
|
53
54
|
const [view, setView] = useState<MapView | SceneView>();
|
|
54
55
|
const [is3D, setIs3D] = useState(false);
|
|
@@ -67,7 +68,7 @@ export const MapProvider = ({
|
|
|
67
68
|
useEffect(() => {
|
|
68
69
|
if (view && onClick) {
|
|
69
70
|
const handleClick = view.on("click", (event) => {
|
|
70
|
-
event.button === 0
|
|
71
|
+
if (event.button === 0)
|
|
71
72
|
onClick({
|
|
72
73
|
latitude: event.mapPoint.latitude ?? 0,
|
|
73
74
|
longitude: event.mapPoint.longitude ?? 0,
|
|
@@ -79,10 +80,10 @@ export const MapProvider = ({
|
|
|
79
80
|
}
|
|
80
81
|
}, [view, onClick]);
|
|
81
82
|
|
|
82
|
-
const E =
|
|
83
|
+
const E = enable3D && is3D ? "arcgis-scene" : "arcgis-map";
|
|
83
84
|
|
|
84
85
|
return (
|
|
85
|
-
<MapContext
|
|
86
|
+
<MapContext
|
|
86
87
|
value={{
|
|
87
88
|
map,
|
|
88
89
|
view,
|
|
@@ -95,9 +96,9 @@ export const MapProvider = ({
|
|
|
95
96
|
}}
|
|
96
97
|
>
|
|
97
98
|
<E
|
|
98
|
-
|
|
99
|
-
e.target.map
|
|
100
|
-
e.target.view
|
|
99
|
+
onarcgisViewReadyChange={(e) => {
|
|
100
|
+
if (e.target.map) setMap(e.target.map);
|
|
101
|
+
if (e.target.view) setView(e.target.view);
|
|
101
102
|
}}
|
|
102
103
|
className="area-content overflow-hidden"
|
|
103
104
|
basemap={
|
|
@@ -129,7 +130,7 @@ export const MapProvider = ({
|
|
|
129
130
|
}
|
|
130
131
|
>
|
|
131
132
|
{enable3D && (
|
|
132
|
-
<
|
|
133
|
+
<calcite-button
|
|
133
134
|
appearance="solid"
|
|
134
135
|
kind="neutral"
|
|
135
136
|
slot="top-right"
|
|
@@ -140,6 +141,6 @@ export const MapProvider = ({
|
|
|
140
141
|
)}
|
|
141
142
|
{children}
|
|
142
143
|
</E>
|
|
143
|
-
</MapContext
|
|
144
|
+
</MapContext>
|
|
144
145
|
);
|
|
145
|
-
}
|
|
146
|
+
}
|
package/src/viewer/Viewer.tsx
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
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
28
|
import { MapProvider } from "./Provider";
|
|
@@ -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
|
};
|
package/src/viewer/context.ts
CHANGED
|
@@ -21,14 +21,14 @@
|
|
|
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 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,
|
|
29
|
-
import { FabricBaseMap } from "../types";
|
|
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
30
|
|
|
31
|
-
|
|
31
|
+
interface ContextType {
|
|
32
32
|
map?: Map | null;
|
|
33
33
|
view?: MapView | SceneView;
|
|
34
34
|
disableDrag?: boolean;
|
|
@@ -37,6 +37,8 @@ export const MapContext = createContext<{
|
|
|
37
37
|
center: LngLatLike;
|
|
38
38
|
zoom: number;
|
|
39
39
|
is3D: boolean;
|
|
40
|
-
}
|
|
40
|
+
}
|
|
41
41
|
|
|
42
|
-
export const
|
|
42
|
+
export const MapContext = createContext<ContextType>({} as ContextType);
|
|
43
|
+
|
|
44
|
+
export const useMap = () => use(MapContext);
|