@react-fabric/map 1.0.0-beta.58

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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  3. package/css/styles.css +40 -0
  4. package/dist/cjs/constants/index.js +49 -0
  5. package/dist/cjs/index.js +69 -0
  6. package/dist/cjs/layers/Json.js +31 -0
  7. package/dist/cjs/layers/Marker.js +47 -0
  8. package/dist/cjs/markers/Fill.js +80 -0
  9. package/dist/cjs/markers/Pin.js +92 -0
  10. package/dist/cjs/renderers/Heatmap.js +62 -0
  11. package/dist/cjs/renderers/Simple.js +51 -0
  12. package/dist/cjs/tools/BasemapGallery.js +80 -0
  13. package/dist/cjs/tools/Home.js +134 -0
  14. package/dist/cjs/tools/LayerList.js +43 -0
  15. package/dist/cjs/tools/ScaleBar.js +36 -0
  16. package/dist/cjs/tools/Zoom.js +40 -0
  17. package/dist/cjs/viewer/Context.js +132 -0
  18. package/dist/cjs/viewer/Viewer.js +29 -0
  19. package/dist/esm/constants/index.js +48 -0
  20. package/dist/esm/index.js +68 -0
  21. package/dist/esm/layers/Json.js +31 -0
  22. package/dist/esm/layers/Marker.js +46 -0
  23. package/dist/esm/markers/Fill.js +80 -0
  24. package/dist/esm/markers/Pin.js +92 -0
  25. package/dist/esm/renderers/Heatmap.js +62 -0
  26. package/dist/esm/renderers/Simple.js +51 -0
  27. package/dist/esm/tools/BasemapGallery.js +80 -0
  28. package/dist/esm/tools/Home.js +115 -0
  29. package/dist/esm/tools/LayerList.js +43 -0
  30. package/dist/esm/tools/ScaleBar.js +36 -0
  31. package/dist/esm/tools/Zoom.js +40 -0
  32. package/dist/esm/viewer/Context.js +131 -0
  33. package/dist/esm/viewer/Viewer.js +29 -0
  34. package/dist/types/constants/index.d.ts +22 -0
  35. package/dist/types/index.d.ts +73 -0
  36. package/dist/types/layers/Json.d.ts +1 -0
  37. package/dist/types/layers/Marker.d.ts +14 -0
  38. package/dist/types/markers/Fill.d.ts +12 -0
  39. package/dist/types/markers/Pin.d.ts +16 -0
  40. package/dist/types/renderers/Cluster.d.ts +19 -0
  41. package/dist/types/renderers/Heatmap.d.ts +18 -0
  42. package/dist/types/renderers/Simple.d.ts +38 -0
  43. package/dist/types/tools/BasemapGallery.d.ts +4 -0
  44. package/dist/types/tools/Home.d.ts +4 -0
  45. package/dist/types/tools/LayerList.d.ts +3 -0
  46. package/dist/types/tools/ScaleBar.d.ts +2 -0
  47. package/dist/types/tools/Zoom.d.ts +2 -0
  48. package/dist/types/types/index.d.ts +34 -0
  49. package/dist/types/viewer/Context.d.ts +16 -0
  50. package/dist/types/viewer/Viewer.d.ts +3 -0
  51. package/package.json +61 -0
  52. package/src/constants/index.ts +44 -0
  53. package/src/index.ts +65 -0
  54. package/src/layers/Json.tsx +52 -0
  55. package/src/layers/Marker.tsx +83 -0
  56. package/src/markers/Fill.tsx +117 -0
  57. package/src/markers/Pin.tsx +136 -0
  58. package/src/renderers/Cluster.tsx +99 -0
  59. package/src/renderers/Heatmap.tsx +99 -0
  60. package/src/renderers/Simple.tsx +97 -0
  61. package/src/tools/BasemapGallery.tsx +91 -0
  62. package/src/tools/Home.tsx +134 -0
  63. package/src/tools/LayerList.tsx +41 -0
  64. package/src/tools/ScaleBar.tsx +29 -0
  65. package/src/tools/Zoom.tsx +31 -0
  66. package/src/types/index.ts +54 -0
  67. package/src/viewer/Context.tsx +160 -0
  68. package/src/viewer/Viewer.tsx +42 -0
@@ -0,0 +1,80 @@
1
+ 'use client';
2
+
3
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
5
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
6
+ import Polygon from '@arcgis/core/geometry/Polygon';
7
+ import Graphic from '@arcgis/core/Graphic';
8
+ import SimpleFillSymbol from '@arcgis/core/symbols/SimpleFillSymbol';
9
+ import { convertLatLng } from '@react-fabric/utilities';
10
+ import { useMemo, useEffect } from 'react';
11
+ import { useMarkerLayer } from '../layers/Marker.js';
12
+ import Color from 'color';
13
+ import { useMap } from '../viewer/Context.js';
14
+
15
+ var _excluded = ["coords", "style", "color", "borderWidth", "borderColor", "animate"];
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+
19
+ /**
20
+ * Fill graphic for displaying a fill polygon on the map.
21
+ */
22
+ var Fill = function Fill(_ref) {
23
+ var coords = _ref.coords,
24
+ _ref$style = _ref.style,
25
+ style = _ref$style === void 0 ? "solid" : _ref$style,
26
+ _ref$color = _ref.color,
27
+ color = _ref$color === void 0 ? "#f00" : _ref$color,
28
+ borderWidth = _ref.borderWidth,
29
+ borderColor = _ref.borderColor,
30
+ animate = _ref.animate,
31
+ props = _objectWithoutProperties(_ref, _excluded);
32
+ var layer = useMarkerLayer();
33
+ var _useMap = useMap(),
34
+ is3D = _useMap.is3D;
35
+ var graphic = useMemo(function () {
36
+ return new Graphic(_objectSpread({
37
+ geometry: new Polygon({
38
+ rings: [coords.map(convertLatLng)]
39
+ }),
40
+ symbol: new SimpleFillSymbol(Object.assign({
41
+ style: style,
42
+ color: color,
43
+ outline: {
44
+ color: borderColor,
45
+ width: borderWidth
46
+ }
47
+ }))
48
+ }, props));
49
+ }, [coords, style, color, borderColor, borderWidth, props]);
50
+ useEffect(function () {
51
+ if (layer && coords) {
52
+ var tmr = null;
53
+ layer.when(function () {
54
+ layer.add(graphic);
55
+ if (animate && !is3D) {
56
+ var up = 0.1;
57
+ var sat = 0;
58
+ var symbol = graphic.symbol;
59
+ var _color = symbol.color.toRgba();
60
+ tmr = setInterval(function () {
61
+ if (sat >= 0.9) up = -0.1;
62
+ if (sat <= 0.1) up = 0.1;
63
+ sat += up;
64
+ symbol.color = Color.rgb(_toConsumableArray(_color)).darken(sat).rgb().array();
65
+ requestAnimationFrame(function () {
66
+ graphic.symbol = symbol.clone();
67
+ });
68
+ }, 100);
69
+ }
70
+ });
71
+ return function () {
72
+ clearInterval(tmr);
73
+ layer.remove(graphic);
74
+ };
75
+ }
76
+ }, [layer, graphic, animate, is3D]);
77
+ return null;
78
+ };
79
+
80
+ export { Fill };
@@ -0,0 +1,92 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import Point from '@arcgis/core/geometry/Point';
6
+ import Graphic from '@arcgis/core/Graphic';
7
+ import SimpleMarkerSymbol from '@arcgis/core/symbols/SimpleMarkerSymbol';
8
+ import { getLatitudeLongitude } from '@react-fabric/utilities';
9
+ import { useMemo, useEffect } from 'react';
10
+ import { useMarkerLayer } from '../layers/Marker.js';
11
+ import { useMap } from '../viewer/Context.js';
12
+
13
+ var _excluded = ["coords", "style", "size", "color", "path", "borderWidth", "borderColor", "animate"];
14
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ var paths = {
17
+ marker: "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",
18
+ "marker-radius": "M12,2C15.31,2 18,4.66 18,7.95C18,12.41 12,19 12,19C12,19 6,12.41 6,7.95C6,4.66 8.69,2 12,2M12,6A2,2 0 0,0 10,8A2,2 0 0,0 12,10A2,2 0 0,0 14,8A2,2 0 0,0 12,6M20,19C20,21.21 16.42,23 12,23C7.58,23 4,21.21 4,19C4,17.71 5.22,16.56 7.11,15.83L7.75,16.74C6.67,17.19 6,17.81 6,18.5C6,19.88 8.69,21 12,21C15.31,21 18,19.88 18,18.5C18,17.81 17.33,17.19 16.25,16.74L16.89,15.83C18.78,16.56 20,17.71 20,19Z",
19
+ 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",
20
+ "pin-radius": "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"
21
+ };
22
+
23
+ /**
24
+ * Pin graphic for displaying a pin on the map.
25
+ */
26
+ var Pin = function Pin(_ref) {
27
+ var coords = _ref.coords,
28
+ _ref$style = _ref.style,
29
+ style = _ref$style === void 0 ? "circle" : _ref$style,
30
+ _ref$size = _ref.size,
31
+ size = _ref$size === void 0 ? 18 : _ref$size,
32
+ _ref$color = _ref.color,
33
+ color = _ref$color === void 0 ? "#f00" : _ref$color,
34
+ path = _ref.path,
35
+ borderWidth = _ref.borderWidth,
36
+ borderColor = _ref.borderColor,
37
+ animate = _ref.animate,
38
+ props = _objectWithoutProperties(_ref, _excluded);
39
+ var layer = useMarkerLayer();
40
+ var _useMap = useMap(),
41
+ is3D = _useMap.is3D;
42
+ var graphic = useMemo(function () {
43
+ return new Graphic(_objectSpread({
44
+ geometry: new Point(getLatitudeLongitude(coords)),
45
+ symbol: new SimpleMarkerSymbol(Object.assign({
46
+ style: style,
47
+ color: color,
48
+ size: size,
49
+ outline: {
50
+ color: borderColor,
51
+ width: borderWidth
52
+ }
53
+ }, style && style.toString() in paths ? {
54
+ path: paths[style.toString()],
55
+ style: "path"
56
+ } : {}, path ? {
57
+ path: path,
58
+ style: "path"
59
+ } : {}))
60
+ }, props));
61
+ }, [coords, style, size, color, borderColor, borderWidth, path, props]);
62
+ useEffect(function () {
63
+ if (layer && coords) {
64
+ var tmr = null;
65
+ layer.when(function () {
66
+ layer.add(graphic);
67
+ var symbol = graphic.symbol;
68
+ if (symbol.style === "path") symbol.yoffset = symbol.size / 2;
69
+ if (animate && !is3D) {
70
+ var baseSize = symbol.size;
71
+ var up = 2;
72
+ tmr = setInterval(function () {
73
+ symbol.size += up;
74
+ if (symbol.size > baseSize + 20) up = -2;
75
+ if (symbol.size <= baseSize) up = 2;
76
+ if (symbol.style === "path") symbol.yoffset = symbol.size / 2;
77
+ requestAnimationFrame(function () {
78
+ graphic.symbol = symbol.clone();
79
+ });
80
+ }, 100);
81
+ }
82
+ });
83
+ return function () {
84
+ clearInterval(tmr);
85
+ layer.remove(graphic);
86
+ };
87
+ }
88
+ }, [layer, graphic, animate, is3D]);
89
+ return null;
90
+ };
91
+
92
+ export { Pin };
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+
3
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
+ import HeatmapRenderer from '@arcgis/core/renderers/HeatmapRenderer';
5
+ import Color from 'color';
6
+ import { useMemo } from 'react';
7
+
8
+ var useHeatmapRenderer = function useHeatmapRenderer(props) {
9
+ var renderer = useMemo(function () {
10
+ var _props$colors, _props$colors2, _props$colors3, _props$minDensity, _props$maxDensity;
11
+ var colorHigh = "#FFE600FF";
12
+ var colorMid = "#FF8C00FF";
13
+ var colorLow = "#FF3300FF";
14
+ if ((props === null || props === void 0 || (_props$colors = props.colors) === null || _props$colors === void 0 ? void 0 : _props$colors.length) === 1) {
15
+ colorHigh = Color(props.colors[0]).lightness(95).toString();
16
+ colorLow = Color(props.colors[0]).lightness(25).toString();
17
+ colorMid = Color(colorHigh).mix(Color(colorLow), 0.5).toString();
18
+ }
19
+ if ((props === null || props === void 0 || (_props$colors2 = props.colors) === null || _props$colors2 === void 0 ? void 0 : _props$colors2.length) === 2) {
20
+ colorHigh = props.colors[0];
21
+ colorLow = props.colors[1];
22
+ colorMid = Color(colorHigh).mix(Color(colorLow), 0.5).toString();
23
+ }
24
+ if ((props === null || props === void 0 || (_props$colors3 = props.colors) === null || _props$colors3 === void 0 ? void 0 : _props$colors3.length) === 3) {
25
+ colorHigh = props.colors[0];
26
+ colorMid = props.colors[1];
27
+ colorLow = props.colors[2];
28
+ }
29
+ var colors = props !== null && props !== void 0 && props.colors && props.colors.length > 3 ? props.colors.map(function (color, index, arr) {
30
+ return {
31
+ ratio: (index + 1) / arr.length,
32
+ color: color
33
+ };
34
+ }) : [].concat(_toConsumableArray(Array.from({
35
+ length: 6
36
+ }, function (_, i) {
37
+ return {
38
+ ratio: (i + 1) / 12,
39
+ color: Color(colorLow).mix(Color(colorMid), i / 6).toString()
40
+ };
41
+ })), _toConsumableArray(Array.from({
42
+ length: 6
43
+ }, function (_, i) {
44
+ return {
45
+ ratio: (i + 6) / 12,
46
+ color: Color(colorMid).mix(Color(colorHigh), i / 6).toString()
47
+ };
48
+ })));
49
+ return new HeatmapRenderer({
50
+ field: props === null || props === void 0 ? void 0 : props.field,
51
+ colorStops: [{
52
+ color: "#00000000",
53
+ ratio: 0
54
+ }].concat(_toConsumableArray(colors)),
55
+ minDensity: (_props$minDensity = props === null || props === void 0 ? void 0 : props.minDensity) !== null && _props$minDensity !== void 0 ? _props$minDensity : 0,
56
+ maxDensity: (_props$maxDensity = props === null || props === void 0 ? void 0 : props.maxDensity) !== null && _props$maxDensity !== void 0 ? _props$maxDensity : 0.1
57
+ });
58
+ }, [props]);
59
+ return renderer;
60
+ };
61
+
62
+ export { useHeatmapRenderer };
@@ -0,0 +1,51 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import SimpleRenderer from '@arcgis/core/renderers/SimpleRenderer';
5
+ import { useMemo } from 'react';
6
+
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ var useSimpleRenderer = function useSimpleRenderer(props) {
10
+ var renderer = useMemo(function () {
11
+ var _props$style, _props$color, _props$size, _props$borderColor, _props$borderWidth;
12
+ var vizVars = [];
13
+ var styleProps = {
14
+ style: (_props$style = props === null || props === void 0 ? void 0 : props.style) !== null && _props$style !== void 0 ? _props$style : "circle"
15
+ };
16
+ if (props !== null && props !== void 0 && props.path) {
17
+ styleProps.style = "path";
18
+ styleProps.path = props.path;
19
+ }
20
+ if (props !== null && props !== void 0 && props.sizeStops && props.sizeField) {
21
+ vizVars.push({
22
+ type: "size",
23
+ field: props.sizeField,
24
+ stops: props.sizeStops
25
+ });
26
+ }
27
+ if (props !== null && props !== void 0 && props.colorStops && props.colorField) {
28
+ vizVars.push({
29
+ type: "color",
30
+ field: props.colorField,
31
+ stops: props.colorStops
32
+ });
33
+ }
34
+ return new SimpleRenderer({
35
+ symbol: _objectSpread(_objectSpread({
36
+ type: "simple-marker"
37
+ }, styleProps), {}, {
38
+ color: (_props$color = props === null || props === void 0 ? void 0 : props.color) !== null && _props$color !== void 0 ? _props$color : "blue",
39
+ size: (_props$size = props === null || props === void 0 ? void 0 : props.size) !== null && _props$size !== void 0 ? _props$size : 4,
40
+ outline: {
41
+ color: (_props$borderColor = props === null || props === void 0 ? void 0 : props.borderColor) !== null && _props$borderColor !== void 0 ? _props$borderColor : "white",
42
+ width: (_props$borderWidth = props === null || props === void 0 ? void 0 : props.borderWidth) !== null && _props$borderWidth !== void 0 ? _props$borderWidth : 1
43
+ }
44
+ }),
45
+ visualVariables: vizVars
46
+ });
47
+ }, [props]);
48
+ return renderer;
49
+ };
50
+
51
+ export { useSimpleRenderer };
@@ -0,0 +1,80 @@
1
+ 'use client';
2
+
3
+ import Basemap from '@arcgis/core/Basemap';
4
+ import VectorTileLayer from '@arcgis/core/layers/VectorTileLayer';
5
+ import LocalBasemapsSource from '@arcgis/core/widgets/BasemapGallery/support/LocalBasemapsSource';
6
+ import { ArcgisExpand, ArcgisBasemapGallery, ArcgisBasemapLayerList } from '@arcgis/map-components-react';
7
+ import '@arcgis/map-components/components/arcgis-basemap-gallery';
8
+ import '@arcgis/map-components/components/arcgis-basemap-layer-list';
9
+ import '@arcgis/map-components/components/arcgis-expand';
10
+ import { useMap } from '../viewer/Context.js';
11
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
12
+
13
+ /*
14
+ * React Fabric
15
+ * @version: 1.0.0
16
+ *
17
+ *
18
+ * The MIT License (MIT)
19
+ * Copyright (c) 2025 Adarsh Pastakia
20
+ *
21
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
22
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
23
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
24
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
25
+ * subject to the following conditions:
26
+ *
27
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
28
+ * portions of the Software.
29
+ *
30
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
31
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
32
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
33
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
+ */
35
+
36
+ var BasemapGallery = function BasemapGallery() {
37
+ var _map$basemap$baseLaye, _map$basemap;
38
+ var _useMap = useMap(),
39
+ basemaps = _useMap.basemaps,
40
+ map = _useMap.map;
41
+ return /*#__PURE__*/jsxs(Fragment, {
42
+ children: [/*#__PURE__*/jsx(ArcgisExpand, {
43
+ className: "mb-2",
44
+ expandIcon: "basemap",
45
+ collapseIcon: "x",
46
+ mode: "floating",
47
+ slot: "top-right",
48
+ autoCollapse: true,
49
+ children: /*#__PURE__*/jsx(ArcgisBasemapGallery, {
50
+ source: new LocalBasemapsSource({
51
+ basemaps: basemaps.map(function (map) {
52
+ return new Basemap({
53
+ title: map.title,
54
+ thumbnailUrl: map.thumbnail,
55
+ baseLayers: map.layers.map(function (layer) {
56
+ return new VectorTileLayer("url" in layer ? {
57
+ url: layer.url
58
+ } : {
59
+ portalItem: {
60
+ id: layer.portalId
61
+ }
62
+ });
63
+ })
64
+ });
65
+ })
66
+ })
67
+ })
68
+ }), ((_map$basemap$baseLaye = map === null || map === void 0 || (_map$basemap = map.basemap) === null || _map$basemap === void 0 ? void 0 : _map$basemap.baseLayers.length) !== null && _map$basemap$baseLaye !== void 0 ? _map$basemap$baseLaye : 1) > 1 && /*#__PURE__*/jsx(ArcgisExpand, {
69
+ className: "mb-2",
70
+ expandIcon: "layer-map",
71
+ collapseIcon: "x",
72
+ mode: "floating",
73
+ slot: "top-right",
74
+ autoCollapse: true,
75
+ children: /*#__PURE__*/jsx(ArcgisBasemapLayerList, {})
76
+ })]
77
+ });
78
+ };
79
+
80
+ export { BasemapGallery };
@@ -0,0 +1,115 @@
1
+ 'use client';
2
+
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import * as reactiveUtils from '@arcgis/core/core/reactiveUtils';
5
+ import Point from '@arcgis/core/geometry/Point';
6
+ import Viewpoint from '@arcgis/core/Viewpoint';
7
+ import { ArcgisPlacement } from '@arcgis/map-components-react';
8
+ import '@arcgis/map-components/components/arcgis-placement';
9
+ import { CalciteButton } from '@esri/calcite-components-react';
10
+ import { debounce, getLatitudeLongitude } from '@react-fabric/utilities';
11
+ import { useRef, useState, useEffect, useCallback } from 'react';
12
+ import { useMap } from '../viewer/Context.js';
13
+ import { jsxs, jsx } from 'react/jsx-runtime';
14
+
15
+ var Home = function Home(_ref) {
16
+ var enableHistory = _ref.enableHistory;
17
+ var _useMap = useMap(),
18
+ map = _useMap.map,
19
+ view = _useMap.view,
20
+ disableDrag = _useMap.disableDrag,
21
+ center = _useMap.center,
22
+ zoom = _useMap.zoom;
23
+ var isNavigatingHistory = useRef(false);
24
+ var currentIndex = useRef(0);
25
+ var _useState = useState([]),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ history = _useState2[0],
28
+ setHistory = _useState2[1];
29
+ var _useState3 = useState(0),
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ activeIndex = _useState4[0],
32
+ setActiveIndex = _useState4[1];
33
+ useEffect(function () {
34
+ currentIndex.current = activeIndex;
35
+ }, [activeIndex]);
36
+ useEffect(function () {
37
+ if (enableHistory && !disableDrag && view) {
38
+ var addHistory = debounce(function (viewpoint) {
39
+ if (!isNavigatingHistory.current) {
40
+ setHistory(function (h) {
41
+ // Keep max 25 history entries
42
+ var newHistory = h.slice(0, currentIndex.current + 1).slice(-24);
43
+ // Add new viewpoint to history
44
+ newHistory.push(viewpoint.clone());
45
+ setActiveIndex(newHistory.length - 1);
46
+ return newHistory;
47
+ });
48
+ }
49
+ isNavigatingHistory.current = false;
50
+ });
51
+ var watcher = reactiveUtils.watch(function () {
52
+ return view.viewpoint;
53
+ }, addHistory);
54
+ return function () {
55
+ watcher.remove();
56
+ };
57
+ }
58
+ }, [disableDrag, enableHistory, view]);
59
+ var navigate = useCallback(function (idx) {
60
+ if (history.length > 0 && history[idx] && view) {
61
+ isNavigatingHistory.current = true;
62
+ view.goTo(history[idx]);
63
+ setActiveIndex(idx);
64
+ }
65
+ }, [history]);
66
+ var gotoHome = useCallback(function () {
67
+ if (view) {
68
+ var _extent, _view$tileInfo;
69
+ var extent;
70
+ map === null || map === void 0 || map.layers.forEach(function (layer) {
71
+ if (layer.visible && layer.fullExtent) {
72
+ if (extent) {
73
+ extent = extent.union(layer.fullExtent);
74
+ } else {
75
+ extent = layer.fullExtent;
76
+ }
77
+ }
78
+ });
79
+ view.goTo((_extent = extent) !== null && _extent !== void 0 ? _extent : new Viewpoint({
80
+ scale: (_view$tileInfo = view.tileInfo) === null || _view$tileInfo === void 0 ? void 0 : _view$tileInfo.zoomToScale(zoom),
81
+ targetGeometry: new Point(getLatitudeLongitude(center))
82
+ }));
83
+ }
84
+ }, [center, zoom, view, map]);
85
+ return !disableDrag && /*#__PURE__*/jsxs(ArcgisPlacement, {
86
+ slot: "top-left",
87
+ className: "mb-2 flex flex-col divide-y divide-tint-100",
88
+ children: [enableHistory && /*#__PURE__*/jsx(CalciteButton, {
89
+ appearance: "solid",
90
+ kind: "neutral",
91
+ iconStart: "arrow-left",
92
+ disabled: activeIndex <= 0,
93
+ onClick: function onClick() {
94
+ return navigate(activeIndex - 1);
95
+ }
96
+ }), /*#__PURE__*/jsx(CalciteButton, {
97
+ appearance: "solid",
98
+ kind: "neutral",
99
+ iconStart: "home",
100
+ onClick: function onClick() {
101
+ return gotoHome();
102
+ }
103
+ }), enableHistory && /*#__PURE__*/jsx(CalciteButton, {
104
+ appearance: "solid",
105
+ kind: "neutral",
106
+ iconStart: "arrow-right",
107
+ disabled: activeIndex >= history.length - 1,
108
+ onClick: function onClick() {
109
+ return navigate(activeIndex + 1);
110
+ }
111
+ })]
112
+ });
113
+ };
114
+
115
+ export { Home };
@@ -0,0 +1,43 @@
1
+ 'use client';
2
+
3
+ import { ArcgisExpand, ArcgisLayerList } from '@arcgis/map-components-react';
4
+ import '@arcgis/map-components/components/arcgis-expand';
5
+ import '@arcgis/map-components/components/arcgis-layer-list';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ /*
9
+ * React Fabric
10
+ * @version: 1.0.0
11
+ *
12
+ *
13
+ * The MIT License (MIT)
14
+ * Copyright (c) 2025 Adarsh Pastakia
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
17
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
18
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
19
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
20
+ * subject to the following conditions:
21
+ *
22
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
23
+ * portions of the Software.
24
+ *
25
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
26
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
+ */
30
+
31
+ var LayerList = function LayerList() {
32
+ return /*#__PURE__*/jsx(ArcgisExpand, {
33
+ expandIcon: "layers",
34
+ className: "mb-2",
35
+ collapseIcon: "x",
36
+ mode: "floating",
37
+ slot: "top-right",
38
+ autoCollapse: true,
39
+ children: /*#__PURE__*/jsx(ArcgisLayerList, {})
40
+ });
41
+ };
42
+
43
+ export { LayerList };
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+
3
+ import { ArcgisScaleBar } from '@arcgis/map-components-react';
4
+ import '@arcgis/map-components/components/arcgis-scale-bar';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ /*
8
+ * React Fabric
9
+ * @version: 1.0.0
10
+ *
11
+ *
12
+ * The MIT License (MIT)
13
+ * Copyright (c) 2025 Adarsh Pastakia
14
+ *
15
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
16
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
17
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
18
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
19
+ * subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
22
+ * portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
25
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ */
29
+
30
+ var ScaleBar = function ScaleBar() {
31
+ return /*#__PURE__*/jsx(ArcgisScaleBar, {
32
+ slot: "bottom-left"
33
+ });
34
+ };
35
+
36
+ export { ScaleBar };
@@ -0,0 +1,40 @@
1
+ 'use client';
2
+
3
+ import { ArcgisZoom } from '@arcgis/map-components-react';
4
+ import '@arcgis/map-components/components/arcgis-zoom';
5
+ import { useMap } from '../viewer/Context.js';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ /*
9
+ * React Fabric
10
+ * @version: 1.0.0
11
+ *
12
+ *
13
+ * The MIT License (MIT)
14
+ * Copyright (c) 2025 Adarsh Pastakia
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
17
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
18
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
19
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
20
+ * subject to the following conditions:
21
+ *
22
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
23
+ * portions of the Software.
24
+ *
25
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
26
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
+ */
30
+
31
+ var Zoom = function Zoom() {
32
+ var _useMap = useMap(),
33
+ disableZoom = _useMap.disableZoom;
34
+ return !disableZoom && /*#__PURE__*/jsx(ArcgisZoom, {
35
+ slot: "top-left",
36
+ className: "mb-2"
37
+ });
38
+ };
39
+
40
+ export { Zoom };