@dxos/react-ui-geo 0.8.3 → 0.8.4-main.05e74ebcff
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/LICENSE +102 -5
- package/data/airports.ts +1 -1
- package/data/cities.ts +1 -1
- package/data/countries-110m.ts +1 -1
- package/data/countries-dots-3.ts +1 -1
- package/data/countries-dots-4.ts +1 -1
- package/dist/lib/browser/{countries-110m-WI4PCLDF.mjs → countries-110m-RE5RNRQG.mjs} +2 -2
- package/dist/lib/browser/countries-110m-RE5RNRQG.mjs.map +7 -0
- package/dist/lib/browser/data.mjs +4 -3
- package/dist/lib/browser/data.mjs.map +4 -4
- package/dist/lib/browser/index.mjs +396 -466
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +19 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/{countries-110m-DQ4XRC4B.mjs → countries-110m-4EDBXSFJ.mjs} +2 -2
- package/dist/lib/node-esm/countries-110m-4EDBXSFJ.mjs.map +7 -0
- package/dist/lib/node-esm/data.mjs +5 -3
- package/dist/lib/node-esm/data.mjs.map +4 -4
- package/dist/lib/node-esm/index.mjs +396 -465
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +21 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/data/airports.d.ts +4 -4
- package/dist/types/data/airports.d.ts.map +1 -1
- package/dist/types/data/cities.d.ts.map +1 -1
- package/dist/types/data/countries-110m.d.ts.map +1 -1
- package/dist/types/data/countries-dots-3.d.ts.map +1 -1
- package/dist/types/data/countries-dots-4.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts +6 -4
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +27 -9
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.d.ts +42 -18
- package/dist/types/src/components/Map/Map.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.stories.d.ts +14 -8
- package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/context.d.ts +6 -8
- package/dist/types/src/hooks/context.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrag.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobeZoomHandler.d.ts +2 -2
- package/dist/types/src/hooks/useGlobeZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useMapZoomHandler.d.ts +2 -2
- package/dist/types/src/hooks/useMapZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useSpinner.d.ts +1 -1
- package/dist/types/src/hooks/useSpinner.d.ts.map +1 -1
- package/dist/types/src/hooks/useTour.d.ts +4 -3
- package/dist/types/src/hooks/useTour.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +12 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +2 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util/debug.d.ts.map +1 -1
- package/dist/types/src/util/inertia.d.ts.map +1 -1
- package/dist/types/src/util/path.d.ts +5 -8
- package/dist/types/src/util/path.d.ts.map +1 -1
- package/dist/types/src/util/render.d.ts +4 -4
- package/dist/types/src/util/render.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -35
- package/src/components/Globe/Globe.stories.tsx +85 -38
- package/src/components/Globe/Globe.tsx +124 -81
- package/src/components/Map/Map.stories.tsx +27 -15
- package/src/components/Map/Map.tsx +220 -94
- package/src/components/Toolbar/Controls.tsx +14 -20
- package/src/components/index.ts +0 -2
- package/src/hooks/context.tsx +11 -34
- package/src/hooks/useGlobeZoomHandler.ts +9 -3
- package/src/hooks/useMapZoomHandler.ts +1 -1
- package/src/hooks/useSpinner.ts +1 -1
- package/src/hooks/useTour.ts +10 -8
- package/src/index.ts +1 -2
- package/src/translations.ts +20 -0
- package/src/types.ts +3 -1
- package/src/util/inertia.ts +1 -1
- package/src/util/path.ts +5 -6
- package/src/util/render.ts +4 -3
- package/dist/lib/browser/chunk-ENCWOTYX.mjs +0 -9
- package/dist/lib/browser/chunk-ENCWOTYX.mjs.map +0 -7
- package/dist/lib/browser/countries-110m-WI4PCLDF.mjs.map +0 -7
- package/dist/lib/node/chunk-LAICG6L2.cjs +0 -40
- package/dist/lib/node/chunk-LAICG6L2.cjs.map +0 -7
- package/dist/lib/node/countries-110m-KQ5WAB2O.cjs +0 -37877
- package/dist/lib/node/countries-110m-KQ5WAB2O.cjs.map +0 -7
- package/dist/lib/node/data.cjs +0 -28
- package/dist/lib/node/data.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -1187
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node-esm/chunk-PIIEDZEU.mjs +0 -11
- package/dist/lib/node-esm/chunk-PIIEDZEU.mjs.map +0 -7
- package/dist/lib/node-esm/countries-110m-DQ4XRC4B.mjs.map +0 -7
- package/dist/types/src/components/types.d.ts +0 -15
- package/dist/types/src/components/types.d.ts.map +0 -1
- package/src/components/types.ts +0 -19
|
@@ -1,55 +1,25 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
loadTopology
|
|
4
|
-
} from "./chunk-PIIEDZEU.mjs";
|
|
5
2
|
|
|
6
|
-
//
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import React3, { forwardRef, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo2, useRef, useState as useState3 } from "react";
|
|
3
|
+
// src/components/Globe/Globe.tsx
|
|
4
|
+
import { easeLinear, easeSinOut, geoMercator, geoOrthographic, geoPath as geoPath2, geoTransverseMercator, interpolateNumber, transition } from "d3";
|
|
5
|
+
import React2, { forwardRef, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo2, useRef, useState as useState3 } from "react";
|
|
10
6
|
import { useResizeDetector } from "react-resize-detector";
|
|
11
|
-
import { useDynamicRef, useThemeContext } from "@dxos/react-ui";
|
|
12
|
-
import { mx } from "@dxos/
|
|
7
|
+
import { useComposedRefs, useControlledState, useDynamicRef, useThemeContext } from "@dxos/react-ui";
|
|
8
|
+
import { composable, composableProps, mx } from "@dxos/ui-theme";
|
|
13
9
|
|
|
14
|
-
//
|
|
15
|
-
import {
|
|
16
|
-
import React, { createContext, useContext } from "react";
|
|
10
|
+
// src/hooks/context.tsx
|
|
11
|
+
import { createContext, useContext } from "react";
|
|
17
12
|
import { raise } from "@dxos/debug";
|
|
18
|
-
import { useControlledState } from "@dxos/react-ui";
|
|
19
13
|
var GlobeContext = /* @__PURE__ */ createContext(void 0);
|
|
20
|
-
var GlobeContextProvider = ({ children, size, center: _center, scale: _scale, translation: _translation, rotation: _rotation }) => {
|
|
21
|
-
var _effect = _useSignals();
|
|
22
|
-
try {
|
|
23
|
-
const [center, setCenter] = useControlledState(_center);
|
|
24
|
-
const [scale, setScale] = useControlledState(_scale);
|
|
25
|
-
const [translation, setTranslation] = useControlledState(_translation);
|
|
26
|
-
const [rotation, setRotation] = useControlledState(_rotation);
|
|
27
|
-
return /* @__PURE__ */ React.createElement(GlobeContext.Provider, {
|
|
28
|
-
value: {
|
|
29
|
-
size,
|
|
30
|
-
center,
|
|
31
|
-
scale,
|
|
32
|
-
translation,
|
|
33
|
-
rotation,
|
|
34
|
-
setCenter,
|
|
35
|
-
setScale,
|
|
36
|
-
setTranslation,
|
|
37
|
-
setRotation
|
|
38
|
-
}
|
|
39
|
-
}, children);
|
|
40
|
-
} finally {
|
|
41
|
-
_effect.f();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
14
|
var useGlobeContext = () => {
|
|
45
15
|
return useContext(GlobeContext) ?? raise(new Error("Missing GlobeContext"));
|
|
46
16
|
};
|
|
47
17
|
|
|
48
|
-
//
|
|
18
|
+
// src/hooks/useDrag.ts
|
|
49
19
|
import { select as select2 } from "d3";
|
|
50
20
|
import { useEffect } from "react";
|
|
51
21
|
|
|
52
|
-
//
|
|
22
|
+
// src/util/debug.ts
|
|
53
23
|
var debug = false;
|
|
54
24
|
var timer = (cb) => {
|
|
55
25
|
const start = Date.now();
|
|
@@ -64,8 +34,8 @@ var timer = (cb) => {
|
|
|
64
34
|
return data;
|
|
65
35
|
};
|
|
66
36
|
|
|
67
|
-
//
|
|
68
|
-
import {
|
|
37
|
+
// src/util/inertia.ts
|
|
38
|
+
import { drag, select, timer as timer2 } from "d3";
|
|
69
39
|
import versor from "versor";
|
|
70
40
|
var restrictAxis = (axis) => (original, current) => current.map((d, i) => axis[i] ? d : original[i]);
|
|
71
41
|
var geoInertiaDrag = (target, render, projection, options) => {
|
|
@@ -239,7 +209,7 @@ function inertiaHelper(opt) {
|
|
|
239
209
|
return inertia;
|
|
240
210
|
}
|
|
241
211
|
|
|
242
|
-
//
|
|
212
|
+
// src/util/path.ts
|
|
243
213
|
import { geoCircle as d3GeoCircle } from "d3";
|
|
244
214
|
var positionToRotation = ([lng, lat], tilt = 0) => [
|
|
245
215
|
-lng,
|
|
@@ -292,7 +262,7 @@ var getDistance = (point1, point2) => {
|
|
|
292
262
|
return Math.sqrt(dx * dx + dy * dy);
|
|
293
263
|
};
|
|
294
264
|
|
|
295
|
-
//
|
|
265
|
+
// src/util/render.ts
|
|
296
266
|
import { geoGraticule } from "d3";
|
|
297
267
|
import { feature, mesh } from "topojson-client";
|
|
298
268
|
var createLayers = (topology, features, styles) => {
|
|
@@ -391,7 +361,7 @@ var renderLayers = (generator, layers = [], scale, styles) => {
|
|
|
391
361
|
return context;
|
|
392
362
|
};
|
|
393
363
|
|
|
394
|
-
//
|
|
364
|
+
// src/hooks/useDrag.ts
|
|
395
365
|
var useDrag = (controller, options = {}) => {
|
|
396
366
|
useEffect(() => {
|
|
397
367
|
const canvas = controller?.canvas;
|
|
@@ -426,8 +396,9 @@ var useDrag = (controller, options = {}) => {
|
|
|
426
396
|
};
|
|
427
397
|
var cancelDrag = (node) => node.on(".drag", null);
|
|
428
398
|
|
|
429
|
-
//
|
|
399
|
+
// src/hooks/useGlobeZoomHandler.ts
|
|
430
400
|
import { useCallback } from "react";
|
|
401
|
+
var ZOOM_FACTOR = 0.1;
|
|
431
402
|
var useGlobeZoomHandler = (controller) => {
|
|
432
403
|
return useCallback((event) => {
|
|
433
404
|
if (!controller) {
|
|
@@ -435,11 +406,15 @@ var useGlobeZoomHandler = (controller) => {
|
|
|
435
406
|
}
|
|
436
407
|
switch (event) {
|
|
437
408
|
case "zoom-in": {
|
|
438
|
-
controller.
|
|
409
|
+
controller.setZoom((zoom) => {
|
|
410
|
+
return zoom * (1 + ZOOM_FACTOR);
|
|
411
|
+
});
|
|
439
412
|
break;
|
|
440
413
|
}
|
|
441
414
|
case "zoom-out": {
|
|
442
|
-
controller.
|
|
415
|
+
controller.setZoom((zoom) => {
|
|
416
|
+
return zoom * (1 - ZOOM_FACTOR);
|
|
417
|
+
});
|
|
443
418
|
break;
|
|
444
419
|
}
|
|
445
420
|
}
|
|
@@ -448,7 +423,7 @@ var useGlobeZoomHandler = (controller) => {
|
|
|
448
423
|
]);
|
|
449
424
|
};
|
|
450
425
|
|
|
451
|
-
//
|
|
426
|
+
// src/hooks/useMapZoomHandler.ts
|
|
452
427
|
import { useCallback as useCallback2 } from "react";
|
|
453
428
|
var useMapZoomHandler = (controller) => {
|
|
454
429
|
return useCallback2((event) => {
|
|
@@ -470,7 +445,7 @@ var useMapZoomHandler = (controller) => {
|
|
|
470
445
|
]);
|
|
471
446
|
};
|
|
472
447
|
|
|
473
|
-
//
|
|
448
|
+
// src/hooks/useSpinner.ts
|
|
474
449
|
import { timer as d3Timer } from "d3";
|
|
475
450
|
import { useEffect as useEffect2, useState } from "react";
|
|
476
451
|
var useSpinner = (controller, options = {}) => {
|
|
@@ -523,9 +498,9 @@ var useSpinner = (controller, options = {}) => {
|
|
|
523
498
|
];
|
|
524
499
|
};
|
|
525
500
|
|
|
526
|
-
//
|
|
527
|
-
import {
|
|
528
|
-
import { useEffect as useEffect3, useState as useState2
|
|
501
|
+
// src/hooks/useTour.ts
|
|
502
|
+
import { selection as d3Selection, geoDistance, geoInterpolate, geoPath } from "d3";
|
|
503
|
+
import { useEffect as useEffect3, useMemo, useState as useState2 } from "react";
|
|
529
504
|
import versor2 from "versor";
|
|
530
505
|
var TRANSITION_NAME = "globe-tour";
|
|
531
506
|
var defaultDuration = 1500;
|
|
@@ -572,7 +547,7 @@ var useTour = (controller, points, options = {}) => {
|
|
|
572
547
|
{
|
|
573
548
|
context.beginPath();
|
|
574
549
|
context.strokeStyle = options?.styles?.arc?.strokeStyle ?? "yellow";
|
|
575
|
-
context.lineWidth = (options?.styles?.arc?.lineWidth ?? 1.5) * (controller?.
|
|
550
|
+
context.lineWidth = (options?.styles?.arc?.lineWidth ?? 1.5) * (controller?.zoom ?? 1);
|
|
576
551
|
context.setLineDash(options?.styles?.arc?.lineDash ?? []);
|
|
577
552
|
path({
|
|
578
553
|
type: "LineString",
|
|
@@ -584,7 +559,7 @@ var useTour = (controller, points, options = {}) => {
|
|
|
584
559
|
context.stroke();
|
|
585
560
|
context.beginPath();
|
|
586
561
|
context.fillStyle = options?.styles?.cursor?.fillStyle ?? "orange";
|
|
587
|
-
path.pointRadius((options?.styles?.cursor?.pointRadius ?? 2) * (controller?.
|
|
562
|
+
path.pointRadius((options?.styles?.cursor?.pointRadius ?? 2) * (controller?.zoom ?? 1));
|
|
588
563
|
path({
|
|
589
564
|
type: "Point",
|
|
590
565
|
coordinates: ip(t22)
|
|
@@ -598,7 +573,7 @@ var useTour = (controller, points, options = {}) => {
|
|
|
598
573
|
await transition2.end();
|
|
599
574
|
last = next;
|
|
600
575
|
}
|
|
601
|
-
} catch
|
|
576
|
+
} catch {
|
|
602
577
|
} finally {
|
|
603
578
|
setRunning(false);
|
|
604
579
|
}
|
|
@@ -619,10 +594,10 @@ var useTour = (controller, points, options = {}) => {
|
|
|
619
594
|
];
|
|
620
595
|
};
|
|
621
596
|
|
|
622
|
-
//
|
|
623
|
-
import
|
|
624
|
-
import
|
|
625
|
-
import {
|
|
597
|
+
// src/components/Toolbar/Controls.tsx
|
|
598
|
+
import React from "react";
|
|
599
|
+
import { IconButton, Toolbar, useTranslation } from "@dxos/react-ui";
|
|
600
|
+
import { translationKey } from "#translations";
|
|
626
601
|
var controlPositions = {
|
|
627
602
|
topleft: "top-2 left-2",
|
|
628
603
|
topright: "top-2 right-2",
|
|
@@ -630,65 +605,45 @@ var controlPositions = {
|
|
|
630
605
|
bottomright: "bottom-2 right-2"
|
|
631
606
|
};
|
|
632
607
|
var ZoomControls = ({ classNames, onAction }) => {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
icon: "ph--minus--regular",
|
|
651
|
-
label: "zoom out",
|
|
652
|
-
iconOnly: true,
|
|
653
|
-
size: 5,
|
|
654
|
-
classNames: "px-0 aspect-square",
|
|
655
|
-
onClick: () => onAction?.("zoom-out")
|
|
656
|
-
}));
|
|
657
|
-
} finally {
|
|
658
|
-
_effect.f();
|
|
659
|
-
}
|
|
608
|
+
const { t } = useTranslation(translationKey);
|
|
609
|
+
return /* @__PURE__ */ React.createElement(Toolbar.Root, {
|
|
610
|
+
classNames: [
|
|
611
|
+
"gap-2",
|
|
612
|
+
classNames
|
|
613
|
+
]
|
|
614
|
+
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
615
|
+
icon: "ph--plus--regular",
|
|
616
|
+
iconOnly: true,
|
|
617
|
+
label: t("zoom-in-icon.button"),
|
|
618
|
+
onClick: () => onAction?.("zoom-in")
|
|
619
|
+
}), /* @__PURE__ */ React.createElement(IconButton, {
|
|
620
|
+
icon: "ph--minus--regular",
|
|
621
|
+
iconOnly: true,
|
|
622
|
+
label: t("zoom-out-icon.button"),
|
|
623
|
+
onClick: () => onAction?.("zoom-out")
|
|
624
|
+
}));
|
|
660
625
|
};
|
|
661
626
|
var ActionControls = ({ classNames, onAction }) => {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
icon: "ph--globe-hemisphere-west--regular",
|
|
680
|
-
label: "toggle",
|
|
681
|
-
iconOnly: true,
|
|
682
|
-
size: 5,
|
|
683
|
-
classNames: "px-0 aspect-square",
|
|
684
|
-
onClick: () => onAction?.("toggle")
|
|
685
|
-
}));
|
|
686
|
-
} finally {
|
|
687
|
-
_effect.f();
|
|
688
|
-
}
|
|
627
|
+
const { t } = useTranslation(translationKey);
|
|
628
|
+
return /* @__PURE__ */ React.createElement(Toolbar.Root, {
|
|
629
|
+
classNames: [
|
|
630
|
+
"gap-2",
|
|
631
|
+
classNames
|
|
632
|
+
]
|
|
633
|
+
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
634
|
+
icon: "ph--path--regular",
|
|
635
|
+
iconOnly: true,
|
|
636
|
+
label: t("start-icon.button"),
|
|
637
|
+
onClick: () => onAction?.("start")
|
|
638
|
+
}), /* @__PURE__ */ React.createElement(IconButton, {
|
|
639
|
+
icon: "ph--globe-hemisphere-west--regular",
|
|
640
|
+
iconOnly: true,
|
|
641
|
+
label: t("toggle-icon.button"),
|
|
642
|
+
onClick: () => onAction?.("toggle")
|
|
643
|
+
}));
|
|
689
644
|
};
|
|
690
645
|
|
|
691
|
-
//
|
|
646
|
+
// src/components/Globe/Globe.tsx
|
|
692
647
|
var defaultStyles = {
|
|
693
648
|
light: {
|
|
694
649
|
background: {
|
|
@@ -743,400 +698,377 @@ var getProjection = (type = "orthographic") => {
|
|
|
743
698
|
}
|
|
744
699
|
return type ?? geoOrthographic();
|
|
745
700
|
};
|
|
746
|
-
var GlobeRoot = ({
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
701
|
+
var GlobeRoot = composable(({ children, center: centerProp, zoom: zoomProp, translation: translationProp, rotation: rotationProp, ...props }, forwardedRef) => {
|
|
702
|
+
const localRef = useRef(null);
|
|
703
|
+
const composedRef = useComposedRefs(localRef, forwardedRef);
|
|
704
|
+
const { width, height } = useResizeDetector({
|
|
705
|
+
targetRef: localRef
|
|
706
|
+
});
|
|
707
|
+
const [center, setCenter] = useControlledState(centerProp);
|
|
708
|
+
const [zoom, setZoom] = useControlledState(zoomProp ?? 4);
|
|
709
|
+
const [translation, setTranslation] = useControlledState(translationProp);
|
|
710
|
+
const [rotation, setRotation] = useControlledState(rotationProp);
|
|
711
|
+
return /* @__PURE__ */ React2.createElement(GlobeContext.Provider, {
|
|
712
|
+
value: {
|
|
754
713
|
size: {
|
|
755
714
|
width,
|
|
756
715
|
height
|
|
757
716
|
},
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
setCenter,
|
|
806
|
-
setScale: (s) => {
|
|
807
|
-
if (typeof s === "function") {
|
|
808
|
-
const is = interpolateNumber(scaleRef.current, s(scaleRef.current));
|
|
809
|
-
transition().ease(zooming.current ? easeLinear : easeSinOut).duration(200).tween("scale", () => (t) => setScale(is(t))).on("end", () => {
|
|
810
|
-
zooming.current = false;
|
|
811
|
-
});
|
|
812
|
-
} else {
|
|
813
|
-
setScale(s);
|
|
814
|
-
}
|
|
815
|
-
},
|
|
816
|
-
setTranslation,
|
|
817
|
-
setRotation
|
|
818
|
-
};
|
|
819
|
-
}, [
|
|
820
|
-
canvas
|
|
821
|
-
]);
|
|
822
|
-
const generator = useMemo2(() => canvas && projection && geoPath2(projection, canvas.getContext("2d", {
|
|
823
|
-
alpha: false
|
|
824
|
-
})), [
|
|
717
|
+
center,
|
|
718
|
+
zoom,
|
|
719
|
+
translation,
|
|
720
|
+
rotation,
|
|
721
|
+
setCenter,
|
|
722
|
+
setZoom,
|
|
723
|
+
setTranslation,
|
|
724
|
+
setRotation
|
|
725
|
+
}
|
|
726
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
727
|
+
...composableProps(props, {
|
|
728
|
+
classNames: "relative dx-container"
|
|
729
|
+
}),
|
|
730
|
+
ref: composedRef
|
|
731
|
+
}, children));
|
|
732
|
+
});
|
|
733
|
+
var GlobeCanvas = /* @__PURE__ */ forwardRef(({ projection: projectionProp, topology, features, styles: stylesProp }, forwardRef3) => {
|
|
734
|
+
const { themeMode } = useThemeContext();
|
|
735
|
+
const styles = useMemo2(() => stylesProp ?? defaultStyles[themeMode], [
|
|
736
|
+
stylesProp,
|
|
737
|
+
themeMode
|
|
738
|
+
]);
|
|
739
|
+
const [canvas, setCanvas] = useState3(null);
|
|
740
|
+
const canvasRef = (canvas2) => setCanvas(canvas2);
|
|
741
|
+
const projection = useMemo2(() => getProjection(projectionProp), [
|
|
742
|
+
projectionProp
|
|
743
|
+
]);
|
|
744
|
+
const layers = useMemo2(() => {
|
|
745
|
+
return timer(() => createLayers(topology, features, styles));
|
|
746
|
+
}, [
|
|
747
|
+
topology,
|
|
748
|
+
features,
|
|
749
|
+
styles
|
|
750
|
+
]);
|
|
751
|
+
const { size, center, zoom, translation, rotation, setCenter, setZoom, setTranslation, setRotation } = useGlobeContext();
|
|
752
|
+
const zoomRef = useDynamicRef(zoom);
|
|
753
|
+
useEffect4(() => {
|
|
754
|
+
if (center) {
|
|
755
|
+
setZoom(1);
|
|
756
|
+
setRotation(positionToRotation(geoToPosition(center)));
|
|
757
|
+
}
|
|
758
|
+
}, [
|
|
759
|
+
center
|
|
760
|
+
]);
|
|
761
|
+
const zooming = useRef(false);
|
|
762
|
+
useImperativeHandle(forwardRef3, () => {
|
|
763
|
+
return {
|
|
825
764
|
canvas,
|
|
826
|
-
projection
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
projection.scale(Math.min(size.width, size.height) / 2 * scale).translate([
|
|
832
|
-
size.width / 2 + (translation?.x ?? 0),
|
|
833
|
-
size.height / 2 + (translation?.y ?? 0)
|
|
834
|
-
]).rotate(rotation ?? [
|
|
835
|
-
0,
|
|
836
|
-
0,
|
|
837
|
-
0
|
|
838
|
-
]);
|
|
839
|
-
renderLayers(generator, layers, scale, styles);
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
}, [
|
|
843
|
-
generator,
|
|
844
|
-
size,
|
|
845
|
-
scale,
|
|
765
|
+
projection,
|
|
766
|
+
center,
|
|
767
|
+
get zoom() {
|
|
768
|
+
return zoomRef.current;
|
|
769
|
+
},
|
|
846
770
|
translation,
|
|
847
771
|
rotation,
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
772
|
+
setCenter,
|
|
773
|
+
setZoom: (state) => {
|
|
774
|
+
if (typeof state === "function") {
|
|
775
|
+
const is = interpolateNumber(zoomRef.current, state(zoomRef.current));
|
|
776
|
+
transition().ease(zooming.current ? easeLinear : easeSinOut).duration(200).tween("scale", () => (t) => setZoom(is(t))).on("end", () => {
|
|
777
|
+
zooming.current = false;
|
|
778
|
+
});
|
|
779
|
+
} else {
|
|
780
|
+
setZoom(state);
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
setTranslation,
|
|
784
|
+
setRotation
|
|
785
|
+
};
|
|
786
|
+
}, [
|
|
787
|
+
canvas
|
|
788
|
+
]);
|
|
789
|
+
const generator = useMemo2(() => canvas && projection && geoPath2(projection, canvas.getContext("2d", {
|
|
790
|
+
alpha: false
|
|
791
|
+
})), [
|
|
792
|
+
canvas,
|
|
793
|
+
projection
|
|
794
|
+
]);
|
|
795
|
+
useEffect4(() => {
|
|
796
|
+
if (canvas && projection) {
|
|
797
|
+
timer(() => {
|
|
798
|
+
projection.scale(Math.min(size.width, size.height) / 2 * zoom).translate([
|
|
799
|
+
size.width / 2 + (translation?.x ?? 0),
|
|
800
|
+
size.height / 2 + (translation?.y ?? 0)
|
|
801
|
+
]).rotate(rotation ?? [
|
|
802
|
+
0,
|
|
803
|
+
0,
|
|
804
|
+
0
|
|
805
|
+
]);
|
|
806
|
+
renderLayers(generator, layers, zoom, styles);
|
|
807
|
+
});
|
|
852
808
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
809
|
+
}, [
|
|
810
|
+
generator,
|
|
811
|
+
size,
|
|
812
|
+
zoom,
|
|
813
|
+
translation,
|
|
814
|
+
rotation,
|
|
815
|
+
layers
|
|
816
|
+
]);
|
|
817
|
+
if (!size.width || !size.height) {
|
|
818
|
+
return null;
|
|
860
819
|
}
|
|
820
|
+
return /* @__PURE__ */ React2.createElement("canvas", {
|
|
821
|
+
ref: canvasRef,
|
|
822
|
+
width: size.width,
|
|
823
|
+
height: size.height
|
|
824
|
+
});
|
|
861
825
|
});
|
|
862
826
|
var GlobeDebug = ({ position = "topleft" }) => {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
rotation
|
|
875
|
-
}, null, 2)));
|
|
876
|
-
} finally {
|
|
877
|
-
_effect.f();
|
|
878
|
-
}
|
|
827
|
+
const { size, zoom, translation, rotation } = useGlobeContext();
|
|
828
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
829
|
+
className: mx("z-10 absolute w-96 p-2 overflow-hidden border border-green-700 rounded-sm", controlPositions[position])
|
|
830
|
+
}, /* @__PURE__ */ React2.createElement("pre", {
|
|
831
|
+
className: "font-mono text-xs text-green-700"
|
|
832
|
+
}, JSON.stringify({
|
|
833
|
+
size,
|
|
834
|
+
zoom,
|
|
835
|
+
translation,
|
|
836
|
+
rotation
|
|
837
|
+
}, null, 2)));
|
|
879
838
|
};
|
|
880
839
|
var GlobePanel = ({ position, classNames, children }) => {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
className: mx("z-10 absolute overflow-hidden", controlPositions[position], classNames)
|
|
885
|
-
}, children);
|
|
886
|
-
} finally {
|
|
887
|
-
_effect.f();
|
|
888
|
-
}
|
|
840
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
841
|
+
className: mx("z-10 absolute overflow-hidden", controlPositions[position], classNames)
|
|
842
|
+
}, children);
|
|
889
843
|
};
|
|
890
844
|
var CustomControl = ({ position, children }) => {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
className: mx("z-10 absolute overflow-hidden", controlPositions[position])
|
|
895
|
-
}, children);
|
|
896
|
-
} finally {
|
|
897
|
-
_effect.f();
|
|
898
|
-
}
|
|
845
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
846
|
+
className: mx("z-10 absolute overflow-hidden", controlPositions[position])
|
|
847
|
+
}, children);
|
|
899
848
|
};
|
|
849
|
+
var GlobeZoom = ({ onAction, position = "bottomleft", ...props }) => /* @__PURE__ */ React2.createElement(CustomControl, {
|
|
850
|
+
position,
|
|
851
|
+
...props
|
|
852
|
+
}, /* @__PURE__ */ React2.createElement(ZoomControls, {
|
|
853
|
+
onAction
|
|
854
|
+
}));
|
|
855
|
+
var GlobeAction = ({ onAction, position = "bottomright", ...props }) => /* @__PURE__ */ React2.createElement(CustomControl, {
|
|
856
|
+
position,
|
|
857
|
+
...props
|
|
858
|
+
}, /* @__PURE__ */ React2.createElement(ActionControls, {
|
|
859
|
+
onAction
|
|
860
|
+
}));
|
|
900
861
|
var Globe = {
|
|
901
862
|
Root: GlobeRoot,
|
|
902
863
|
Canvas: GlobeCanvas,
|
|
903
|
-
Zoom:
|
|
904
|
-
|
|
905
|
-
try {
|
|
906
|
-
return /* @__PURE__ */ React3.createElement(CustomControl, {
|
|
907
|
-
position,
|
|
908
|
-
...props
|
|
909
|
-
}, /* @__PURE__ */ React3.createElement(ZoomControls, {
|
|
910
|
-
onAction
|
|
911
|
-
}));
|
|
912
|
-
} finally {
|
|
913
|
-
_effect.f();
|
|
914
|
-
}
|
|
915
|
-
},
|
|
916
|
-
Action: ({ onAction, position = "bottomright", ...props }) => {
|
|
917
|
-
var _effect = _useSignals3();
|
|
918
|
-
try {
|
|
919
|
-
return /* @__PURE__ */ React3.createElement(CustomControl, {
|
|
920
|
-
position,
|
|
921
|
-
...props
|
|
922
|
-
}, /* @__PURE__ */ React3.createElement(ActionControls, {
|
|
923
|
-
onAction
|
|
924
|
-
}));
|
|
925
|
-
} finally {
|
|
926
|
-
_effect.f();
|
|
927
|
-
}
|
|
928
|
-
},
|
|
864
|
+
Zoom: GlobeZoom,
|
|
865
|
+
Action: GlobeAction,
|
|
929
866
|
Debug: GlobeDebug,
|
|
930
867
|
Panel: GlobePanel
|
|
931
868
|
};
|
|
932
869
|
|
|
933
|
-
//
|
|
934
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
870
|
+
// src/components/Map/Map.tsx
|
|
935
871
|
import "leaflet/dist/leaflet.css";
|
|
872
|
+
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
936
873
|
import L, { Control, DomEvent, DomUtil, latLngBounds } from "leaflet";
|
|
937
|
-
import
|
|
874
|
+
import React3, { forwardRef as forwardRef2, useEffect as useEffect5, useImperativeHandle as useImperativeHandle2, useRef as useRef2 } from "react";
|
|
938
875
|
import { createRoot } from "react-dom/client";
|
|
939
|
-
import { MapContainer, Marker, Popup, TileLayer, useMap } from "react-leaflet";
|
|
940
|
-
import { useResizeDetector as useResizeDetector2 } from "react-resize-detector";
|
|
941
|
-
import { debounce } from "@dxos/async";
|
|
876
|
+
import { MapContainer, Marker, Popup, TileLayer, useMap, useMapEvents } from "react-leaflet";
|
|
942
877
|
import { ThemeProvider, Tooltip } from "@dxos/react-ui";
|
|
943
|
-
import { defaultTx, mx as mx2 } from "@dxos/
|
|
878
|
+
import { composable as composable2, composableProps as composableProps2, defaultTx, mx as mx2 } from "@dxos/ui-theme";
|
|
944
879
|
var defaults = {
|
|
945
|
-
// TODO(burdon): Guess location.
|
|
946
880
|
center: {
|
|
947
881
|
lat: 51,
|
|
948
882
|
lng: 0
|
|
949
883
|
},
|
|
950
884
|
zoom: 4
|
|
951
885
|
};
|
|
952
|
-
var
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
886
|
+
var [MapContextProvider, useMapContext] = createContext2("Map");
|
|
887
|
+
var MapRoot = composable2(({ children, onChange, ...props }, forwardedRef) => {
|
|
888
|
+
const attention = false;
|
|
889
|
+
return /* @__PURE__ */ React3.createElement(MapContextProvider, {
|
|
890
|
+
attention,
|
|
891
|
+
onChange
|
|
892
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
893
|
+
...composableProps2(props, {
|
|
894
|
+
role: "none",
|
|
895
|
+
classNames: "dx-container grid dx-focus-ring-inset"
|
|
896
|
+
}),
|
|
897
|
+
ref: forwardedRef
|
|
898
|
+
}, children));
|
|
899
|
+
});
|
|
900
|
+
MapRoot.displayName = "Map.Root";
|
|
901
|
+
var MAP_CONTENT_NAME = "Map.Content";
|
|
902
|
+
var MapContent = /* @__PURE__ */ forwardRef2(({ classNames, scrollWheelZoom = true, doubleClickZoom = true, touchZoom = true, center, zoom, children, ...props }, forwardedRef) => {
|
|
903
|
+
const { attention } = useMapContext(MAP_CONTENT_NAME);
|
|
904
|
+
const mapRef = useRef2(null);
|
|
905
|
+
const map = mapRef.current;
|
|
906
|
+
useImperativeHandle2(forwardedRef, () => ({
|
|
907
|
+
setCenter: (center2, zoom2) => {
|
|
908
|
+
mapRef.current?.setView(center2, zoom2);
|
|
909
|
+
},
|
|
910
|
+
setZoom: (cb) => {
|
|
911
|
+
mapRef.current?.setZoom(cb(mapRef.current?.getZoom() ?? 0));
|
|
912
|
+
}
|
|
913
|
+
}), []);
|
|
914
|
+
useEffect5(() => {
|
|
915
|
+
if (!map) {
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (attention) {
|
|
919
|
+
map.scrollWheelZoom.enable();
|
|
920
|
+
} else {
|
|
921
|
+
map.scrollWheelZoom.disable();
|
|
922
|
+
}
|
|
923
|
+
}, [
|
|
924
|
+
map,
|
|
925
|
+
attention
|
|
926
|
+
]);
|
|
927
|
+
return /* @__PURE__ */ React3.createElement(MapContainer, {
|
|
928
|
+
...props,
|
|
929
|
+
className: mx2("group relative grid bg-base-surface!", classNames),
|
|
930
|
+
attributionControl: false,
|
|
931
|
+
zoomControl: false,
|
|
932
|
+
scrollWheelZoom,
|
|
933
|
+
doubleClickZoom,
|
|
934
|
+
touchZoom,
|
|
935
|
+
center: center ?? defaults.center,
|
|
936
|
+
zoom: zoom ?? defaults.zoom,
|
|
937
|
+
whenReady: () => {
|
|
938
|
+
},
|
|
939
|
+
ref: mapRef
|
|
940
|
+
}, children);
|
|
941
|
+
});
|
|
942
|
+
MapContent.displayName = "Map.Content";
|
|
943
|
+
var MAP_TILES_NAME = "Map.Tiles";
|
|
944
|
+
var MapTiles = (_props) => {
|
|
945
|
+
const ref = useRef2(null);
|
|
946
|
+
const { onChange } = useMapContext(MAP_TILES_NAME);
|
|
947
|
+
useMapEvents({
|
|
948
|
+
zoomstart: (ev) => {
|
|
949
|
+
onChange?.({
|
|
950
|
+
center: ev.target.getCenter(),
|
|
951
|
+
zoom: ev.target.getZoom()
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
const { attention } = useMapContext(MAP_TILES_NAME);
|
|
956
|
+
useEffect5(() => {
|
|
957
|
+
if (ref.current) {
|
|
958
|
+
ref.current.getContainer().dataset.attention = attention ? "1" : "0";
|
|
959
|
+
}
|
|
960
|
+
}, [
|
|
961
|
+
attention
|
|
962
|
+
]);
|
|
963
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(TileLayer, {
|
|
964
|
+
ref,
|
|
965
|
+
"data-attention": attention,
|
|
966
|
+
detectRetina: true,
|
|
967
|
+
className: 'dark:grayscale dark:invert data-[attention="0"]:!opacity-80',
|
|
968
|
+
url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
969
|
+
keepBuffer: 4
|
|
970
|
+
}));
|
|
968
971
|
};
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
972
|
+
MapTiles.displayName = MAP_TILES_NAME;
|
|
973
|
+
var MapMarkers = ({ selected, markers }) => {
|
|
974
|
+
const map = useMap();
|
|
975
|
+
useEffect5(() => {
|
|
976
|
+
if (markers.length > 0) {
|
|
977
|
+
const bounds = latLngBounds(markers.map((marker) => marker.location));
|
|
978
|
+
map.fitBounds(bounds);
|
|
979
|
+
} else {
|
|
980
|
+
map.setView(defaults.center, defaults.zoom);
|
|
981
|
+
}
|
|
982
|
+
}, [
|
|
983
|
+
markers
|
|
984
|
+
]);
|
|
985
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, markers?.map(({ id, title, location: { lat, lng } }) => {
|
|
986
|
+
return /* @__PURE__ */ React3.createElement(Marker, {
|
|
987
|
+
key: id,
|
|
988
|
+
position: {
|
|
989
|
+
lat,
|
|
990
|
+
lng
|
|
979
991
|
},
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
});
|
|
1010
|
-
}, 100);
|
|
1011
|
-
map.on("move", handler);
|
|
1012
|
-
map.on("zoom", handler);
|
|
1013
|
-
return () => {
|
|
1014
|
-
map.off("move", handler);
|
|
1015
|
-
map.off("zoom", handler);
|
|
1016
|
-
};
|
|
1017
|
-
}, [
|
|
1018
|
-
map,
|
|
1019
|
-
onChange
|
|
1020
|
-
]);
|
|
1021
|
-
useEffect5(() => {
|
|
1022
|
-
if (markers.length > 0) {
|
|
1023
|
-
const bounds = latLngBounds(markers.map((marker) => marker.location));
|
|
1024
|
-
map.fitBounds(bounds);
|
|
1025
|
-
} else {
|
|
1026
|
-
map.setView(defaults.center, defaults.zoom);
|
|
1027
|
-
}
|
|
1028
|
-
}, [
|
|
1029
|
-
markers
|
|
1030
|
-
]);
|
|
1031
|
-
return /* @__PURE__ */ React4.createElement("div", {
|
|
1032
|
-
ref,
|
|
1033
|
-
className: "flex w-full h-full overflow-hidden bg-baseSurface"
|
|
1034
|
-
}, /* @__PURE__ */ React4.createElement(TileLayer, {
|
|
1035
|
-
className: "dark:filter dark:grayscale dark:invert",
|
|
1036
|
-
url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
1037
|
-
}), markers?.map(({ id, title, location: { lat, lng } }) => {
|
|
1038
|
-
return /* @__PURE__ */ React4.createElement(Marker, {
|
|
1039
|
-
key: id,
|
|
1040
|
-
position: {
|
|
1041
|
-
lat,
|
|
1042
|
-
lng
|
|
1043
|
-
},
|
|
1044
|
-
icon: (
|
|
1045
|
-
// TODO(burdon): Create custom icon from bundled assets.
|
|
1046
|
-
new L.Icon({
|
|
1047
|
-
iconUrl: "https://dxos.network/marker-icon.png",
|
|
1048
|
-
iconRetinaUrl: "https://dxos.network/marker-icon-2x.png",
|
|
1049
|
-
shadowUrl: "https://dxos.network/marker-shadow.png",
|
|
1050
|
-
iconSize: [
|
|
1051
|
-
25,
|
|
1052
|
-
41
|
|
1053
|
-
],
|
|
1054
|
-
iconAnchor: [
|
|
1055
|
-
12,
|
|
1056
|
-
41
|
|
1057
|
-
],
|
|
1058
|
-
popupAnchor: [
|
|
1059
|
-
1,
|
|
1060
|
-
-34
|
|
1061
|
-
],
|
|
1062
|
-
shadowSize: [
|
|
1063
|
-
41,
|
|
1064
|
-
41
|
|
1065
|
-
]
|
|
1066
|
-
})
|
|
1067
|
-
)
|
|
1068
|
-
}, title && /* @__PURE__ */ React4.createElement(Popup, null, title));
|
|
1069
|
-
}));
|
|
1070
|
-
} finally {
|
|
1071
|
-
_effect.f();
|
|
1072
|
-
}
|
|
1073
|
-
});
|
|
992
|
+
icon: (
|
|
993
|
+
// TODO(burdon): Create custom icon from bundled assets.
|
|
994
|
+
// TODO(burdon): Selection state.
|
|
995
|
+
new L.Icon({
|
|
996
|
+
iconUrl: "https://dxos.network/marker-icon.png",
|
|
997
|
+
iconRetinaUrl: "https://dxos.network/marker-icon-2x.png",
|
|
998
|
+
shadowUrl: "https://dxos.network/marker-shadow.png",
|
|
999
|
+
iconSize: [
|
|
1000
|
+
25,
|
|
1001
|
+
41
|
|
1002
|
+
],
|
|
1003
|
+
iconAnchor: [
|
|
1004
|
+
12,
|
|
1005
|
+
41
|
|
1006
|
+
],
|
|
1007
|
+
popupAnchor: [
|
|
1008
|
+
1,
|
|
1009
|
+
-34
|
|
1010
|
+
],
|
|
1011
|
+
shadowSize: [
|
|
1012
|
+
41,
|
|
1013
|
+
41
|
|
1014
|
+
]
|
|
1015
|
+
})
|
|
1016
|
+
)
|
|
1017
|
+
}, title && /* @__PURE__ */ React3.createElement(Popup, null, title));
|
|
1018
|
+
}));
|
|
1019
|
+
};
|
|
1020
|
+
MapMarkers.displayName = "Map.Markers";
|
|
1074
1021
|
var CustomControl2 = ({ position, children }) => {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
control.
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
]);
|
|
1101
|
-
return null;
|
|
1102
|
-
} finally {
|
|
1103
|
-
_effect.f();
|
|
1104
|
-
}
|
|
1022
|
+
const map = useMap();
|
|
1023
|
+
useEffect5(() => {
|
|
1024
|
+
const control = new Control({
|
|
1025
|
+
position
|
|
1026
|
+
});
|
|
1027
|
+
control.onAdd = () => {
|
|
1028
|
+
const container = DomUtil.create("div", mx2("m-0!", controlPositions[position]));
|
|
1029
|
+
DomEvent.disableClickPropagation(container);
|
|
1030
|
+
DomEvent.disableScrollPropagation(container);
|
|
1031
|
+
const root = createRoot(container);
|
|
1032
|
+
root.render(/* @__PURE__ */ React3.createElement(ThemeProvider, {
|
|
1033
|
+
tx: defaultTx
|
|
1034
|
+
}, /* @__PURE__ */ React3.createElement(Tooltip.Provider, null, children)));
|
|
1035
|
+
return container;
|
|
1036
|
+
};
|
|
1037
|
+
control.addTo(map);
|
|
1038
|
+
return () => {
|
|
1039
|
+
control.remove();
|
|
1040
|
+
};
|
|
1041
|
+
}, [
|
|
1042
|
+
map,
|
|
1043
|
+
position,
|
|
1044
|
+
children
|
|
1045
|
+
]);
|
|
1046
|
+
return null;
|
|
1105
1047
|
};
|
|
1048
|
+
var MapZoom = ({ onAction, position = "bottomleft", ...props }) => /* @__PURE__ */ React3.createElement(CustomControl2, {
|
|
1049
|
+
position,
|
|
1050
|
+
...props
|
|
1051
|
+
}, /* @__PURE__ */ React3.createElement(ZoomControls, {
|
|
1052
|
+
onAction
|
|
1053
|
+
}));
|
|
1054
|
+
var MapAction = ({ onAction, position = "bottomright", ...props }) => /* @__PURE__ */ React3.createElement(CustomControl2, {
|
|
1055
|
+
position,
|
|
1056
|
+
...props
|
|
1057
|
+
}, /* @__PURE__ */ React3.createElement(ActionControls, {
|
|
1058
|
+
onAction
|
|
1059
|
+
}));
|
|
1106
1060
|
var Map = {
|
|
1107
1061
|
Root: MapRoot,
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
position,
|
|
1114
|
-
...props
|
|
1115
|
-
}, /* @__PURE__ */ React4.createElement(ZoomControls, {
|
|
1116
|
-
onAction
|
|
1117
|
-
}));
|
|
1118
|
-
} finally {
|
|
1119
|
-
_effect.f();
|
|
1120
|
-
}
|
|
1121
|
-
},
|
|
1122
|
-
Action: ({ onAction, position = "bottomright", ...props }) => {
|
|
1123
|
-
var _effect = _useSignals4();
|
|
1124
|
-
try {
|
|
1125
|
-
return /* @__PURE__ */ React4.createElement(CustomControl2, {
|
|
1126
|
-
position,
|
|
1127
|
-
...props
|
|
1128
|
-
}, /* @__PURE__ */ React4.createElement(ActionControls, {
|
|
1129
|
-
onAction
|
|
1130
|
-
}));
|
|
1131
|
-
} finally {
|
|
1132
|
-
_effect.f();
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1062
|
+
Content: MapContent,
|
|
1063
|
+
Tiles: MapTiles,
|
|
1064
|
+
Markers: MapMarkers,
|
|
1065
|
+
Zoom: MapZoom,
|
|
1066
|
+
Action: MapAction
|
|
1135
1067
|
};
|
|
1136
1068
|
export {
|
|
1137
1069
|
ActionControls,
|
|
1138
1070
|
Globe,
|
|
1139
|
-
|
|
1071
|
+
GlobeContext,
|
|
1140
1072
|
Map,
|
|
1141
1073
|
ZoomControls,
|
|
1142
1074
|
closestPoint,
|
|
@@ -1148,7 +1080,6 @@ export {
|
|
|
1148
1080
|
geoPoint,
|
|
1149
1081
|
geoToPosition,
|
|
1150
1082
|
getDistance,
|
|
1151
|
-
loadTopology,
|
|
1152
1083
|
positionToRotation,
|
|
1153
1084
|
renderLayers,
|
|
1154
1085
|
restrictAxis,
|