@classic-homes/maps-react 0.2.4 → 0.2.6
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/index.cjs +497 -375
- package/dist/index.d.cts +128 -15
- package/dist/index.d.ts +128 -15
- package/dist/index.js +475 -372
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React26 = require('react');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
5
|
var tailwindMerge = require('tailwind-merge');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
35
35
|
return Object.freeze(n);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var React26__namespace = /*#__PURE__*/_interopNamespace(React26);
|
|
39
39
|
var maplibregl__default = /*#__PURE__*/_interopDefault(maplibregl);
|
|
40
40
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
41
41
|
|
|
@@ -43,7 +43,7 @@ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
|
43
43
|
function cn(...inputs) {
|
|
44
44
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
45
45
|
}
|
|
46
|
-
var MapSkeleton =
|
|
46
|
+
var MapSkeleton = React26__namespace.forwardRef(
|
|
47
47
|
({ height = 400, className, ...props }, ref) => {
|
|
48
48
|
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
49
49
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -97,7 +97,7 @@ var MapSkeleton = React25__namespace.forwardRef(
|
|
|
97
97
|
}
|
|
98
98
|
);
|
|
99
99
|
MapSkeleton.displayName = "MapSkeleton";
|
|
100
|
-
var MapError =
|
|
100
|
+
var MapError = React26__namespace.forwardRef(
|
|
101
101
|
({ message = "Failed to load map", height = 400, onRetry, className, ...props }, ref) => {
|
|
102
102
|
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
103
103
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -153,7 +153,7 @@ var MapError = React25__namespace.forwardRef(
|
|
|
153
153
|
}
|
|
154
154
|
);
|
|
155
155
|
MapError.displayName = "MapError";
|
|
156
|
-
var MapEmpty =
|
|
156
|
+
var MapEmpty = React26__namespace.forwardRef(
|
|
157
157
|
({ message = "No map data to display", height = 400, className, ...props }, ref) => {
|
|
158
158
|
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
159
159
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -196,7 +196,7 @@ var MapEmpty = React25__namespace.forwardRef(
|
|
|
196
196
|
}
|
|
197
197
|
);
|
|
198
198
|
MapEmpty.displayName = "MapEmpty";
|
|
199
|
-
var MapContainer =
|
|
199
|
+
var MapContainer = React26__namespace.forwardRef(
|
|
200
200
|
({
|
|
201
201
|
title,
|
|
202
202
|
description,
|
|
@@ -245,8 +245,8 @@ var MapContainer = React25__namespace.forwardRef(
|
|
|
245
245
|
);
|
|
246
246
|
MapContainer.displayName = "MapContainer";
|
|
247
247
|
function useMapTheme(preference = "auto") {
|
|
248
|
-
const [isDark, setIsDark] =
|
|
249
|
-
const updateTheme =
|
|
248
|
+
const [isDark, setIsDark] = React26.useState(false);
|
|
249
|
+
const updateTheme = React26.useCallback(() => {
|
|
250
250
|
if (preference !== "auto") {
|
|
251
251
|
setIsDark(preference === "dark");
|
|
252
252
|
return;
|
|
@@ -256,7 +256,7 @@ function useMapTheme(preference = "auto") {
|
|
|
256
256
|
setIsDark(hasDarkClass);
|
|
257
257
|
}
|
|
258
258
|
}, [preference]);
|
|
259
|
-
|
|
259
|
+
React26.useEffect(() => {
|
|
260
260
|
updateTheme();
|
|
261
261
|
if (preference !== "auto" || typeof document === "undefined") return;
|
|
262
262
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -281,13 +281,14 @@ function useMapTheme(preference = "auto") {
|
|
|
281
281
|
return {
|
|
282
282
|
themeName: isDark ? mapsCore.THEME_DARK : mapsCore.THEME_LIGHT,
|
|
283
283
|
theme: isDark ? mapsCore.darkTheme : mapsCore.lightTheme,
|
|
284
|
-
style
|
|
284
|
+
// Use the default MapTiler basemap style (works well for both light and dark modes)
|
|
285
|
+
style: mapsCore.DEFAULT_BASEMAP.style,
|
|
285
286
|
isDark
|
|
286
287
|
};
|
|
287
288
|
}
|
|
288
289
|
function useReducedMotion() {
|
|
289
|
-
const [prefersReducedMotion2, setPrefersReducedMotion] =
|
|
290
|
-
|
|
290
|
+
const [prefersReducedMotion2, setPrefersReducedMotion] = React26.useState(false);
|
|
291
|
+
React26.useEffect(() => {
|
|
291
292
|
if (typeof window === "undefined") return;
|
|
292
293
|
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
293
294
|
setPrefersReducedMotion(mediaQuery.matches);
|
|
@@ -301,9 +302,9 @@ function useReducedMotion() {
|
|
|
301
302
|
}, []);
|
|
302
303
|
return prefersReducedMotion2;
|
|
303
304
|
}
|
|
304
|
-
var MapContext =
|
|
305
|
+
var MapContext = React26__namespace.createContext(null);
|
|
305
306
|
function useMap() {
|
|
306
|
-
const context =
|
|
307
|
+
const context = React26__namespace.useContext(MapContext);
|
|
307
308
|
if (!context) {
|
|
308
309
|
throw new Error("useMap must be used within a Map component");
|
|
309
310
|
}
|
|
@@ -313,7 +314,7 @@ function useMapInstance() {
|
|
|
313
314
|
const { map, loaded } = useMap();
|
|
314
315
|
return loaded ? map : null;
|
|
315
316
|
}
|
|
316
|
-
var Map2 =
|
|
317
|
+
var Map2 = React26__namespace.forwardRef(
|
|
317
318
|
({
|
|
318
319
|
// Base props
|
|
319
320
|
title,
|
|
@@ -367,108 +368,56 @@ var Map2 = React25__namespace.forwardRef(
|
|
|
367
368
|
onZoom,
|
|
368
369
|
onError
|
|
369
370
|
}, ref) => {
|
|
370
|
-
const containerRef =
|
|
371
|
-
const mapRef =
|
|
372
|
-
const [mapLoaded, setMapLoaded] =
|
|
373
|
-
const [mapError, setMapError] =
|
|
374
|
-
const [styleVersion, setStyleVersion] =
|
|
375
|
-
const activeStyleOverrideRef =
|
|
371
|
+
const containerRef = React26__namespace.useRef(null);
|
|
372
|
+
const mapRef = React26__namespace.useRef(null);
|
|
373
|
+
const [mapLoaded, setMapLoaded] = React26__namespace.useState(false);
|
|
374
|
+
const [mapError, setMapError] = React26__namespace.useState(null);
|
|
375
|
+
const [styleVersion, setStyleVersion] = React26__namespace.useState(0);
|
|
376
|
+
const activeStyleOverrideRef = React26__namespace.useRef(
|
|
376
377
|
null
|
|
377
378
|
);
|
|
378
|
-
const
|
|
379
|
+
const positioningCoordinatorRef = React26__namespace.useRef(null);
|
|
380
|
+
if (!positioningCoordinatorRef.current) {
|
|
381
|
+
positioningCoordinatorRef.current = mapsCore.createPositioningCoordinator();
|
|
382
|
+
}
|
|
383
|
+
const positioningCoordinator = positioningCoordinatorRef.current;
|
|
384
|
+
const setMapStyle = React26__namespace.useCallback((style) => {
|
|
379
385
|
activeStyleOverrideRef.current = style;
|
|
380
386
|
mapRef.current?.setStyle(style);
|
|
381
387
|
}, []);
|
|
382
|
-
const customControlRegistryRef = React25__namespace.useRef({
|
|
383
|
-
"top-left": [],
|
|
384
|
-
"top-right": [],
|
|
385
|
-
"bottom-left": [],
|
|
386
|
-
"bottom-right": []
|
|
387
|
-
});
|
|
388
|
-
const [, forceUpdate] = React25__namespace.useReducer((x) => x + 1, 0);
|
|
389
388
|
const prefersReducedMotion2 = useReducedMotion();
|
|
390
389
|
const { style: themeStyle } = useMapTheme(themePref);
|
|
391
|
-
const onLoadRef =
|
|
390
|
+
const onLoadRef = React26__namespace.useRef(onLoad);
|
|
392
391
|
onLoadRef.current = onLoad;
|
|
393
|
-
const onErrorRef =
|
|
392
|
+
const onErrorRef = React26__namespace.useRef(onError);
|
|
394
393
|
onErrorRef.current = onError;
|
|
395
394
|
const mapStyle = customStyle || themeStyle;
|
|
396
|
-
const controlOffsets = React25__namespace.useMemo(() => {
|
|
397
|
-
const offsets = {
|
|
398
|
-
"top-left": 0,
|
|
399
|
-
"top-right": 0,
|
|
400
|
-
"bottom-left": 0,
|
|
401
|
-
"bottom-right": 0
|
|
402
|
-
};
|
|
403
|
-
if (navigationControl) {
|
|
404
|
-
offsets[navigationControlPosition] += 100;
|
|
405
|
-
}
|
|
406
|
-
if (scaleControl) {
|
|
407
|
-
offsets[scaleControlPosition] += 28;
|
|
408
|
-
}
|
|
409
|
-
if (fullscreenControl) {
|
|
410
|
-
offsets[fullscreenControlPosition] += 38;
|
|
411
|
-
}
|
|
412
|
-
if (geolocateControl) {
|
|
413
|
-
offsets[geolocateControlPosition] += 38;
|
|
414
|
-
}
|
|
415
|
-
if (attributionControl) {
|
|
416
|
-
offsets["bottom-right"] += 32;
|
|
417
|
-
}
|
|
418
|
-
return offsets;
|
|
419
|
-
}, [
|
|
420
|
-
navigationControl,
|
|
421
|
-
navigationControlPosition,
|
|
422
|
-
scaleControl,
|
|
423
|
-
scaleControlPosition,
|
|
424
|
-
fullscreenControl,
|
|
425
|
-
fullscreenControlPosition,
|
|
426
|
-
geolocateControl,
|
|
427
|
-
geolocateControlPosition,
|
|
428
|
-
attributionControl
|
|
429
|
-
]);
|
|
430
|
-
const registerControl = React25__namespace.useCallback(
|
|
431
|
-
(id, position, height2) => {
|
|
432
|
-
const registry = customControlRegistryRef.current;
|
|
433
|
-
const positionControls = registry[position] || [];
|
|
434
|
-
const existingIndex = positionControls.findIndex((c) => c.id === id);
|
|
435
|
-
if (existingIndex >= 0) {
|
|
436
|
-
positionControls[existingIndex].height = height2;
|
|
437
|
-
} else {
|
|
438
|
-
positionControls.push({ id, height: height2 });
|
|
439
|
-
forceUpdate();
|
|
440
|
-
}
|
|
441
|
-
registry[position] = positionControls;
|
|
442
|
-
let offset = 0;
|
|
443
|
-
for (const control of positionControls) {
|
|
444
|
-
if (control.id === id) break;
|
|
445
|
-
offset += control.height + 8;
|
|
446
|
-
}
|
|
447
|
-
return offset;
|
|
448
|
-
},
|
|
449
|
-
[]
|
|
450
|
-
);
|
|
451
|
-
const unregisterControl = React25__namespace.useCallback((id, position) => {
|
|
452
|
-
const registry = customControlRegistryRef.current;
|
|
453
|
-
const positionControls = registry[position] || [];
|
|
454
|
-
registry[position] = positionControls.filter((c) => c.id !== id);
|
|
455
|
-
forceUpdate();
|
|
456
|
-
}, []);
|
|
457
|
-
const getCustomControlOffset = React25__namespace.useCallback((id, position) => {
|
|
458
|
-
const registry = customControlRegistryRef.current;
|
|
459
|
-
const positionControls = registry[position] || [];
|
|
460
|
-
let offset = 0;
|
|
461
|
-
for (const control of positionControls) {
|
|
462
|
-
if (control.id === id) break;
|
|
463
|
-
offset += control.height + 8;
|
|
464
|
-
}
|
|
465
|
-
return offset;
|
|
466
|
-
}, []);
|
|
467
395
|
const accessibleDescription = description || mapsCore.generateMapDescription(title, {
|
|
468
396
|
center,
|
|
469
397
|
zoom
|
|
470
398
|
});
|
|
471
|
-
|
|
399
|
+
React26__namespace.useEffect(() => {
|
|
400
|
+
if (!containerRef.current || !positioningCoordinator) return;
|
|
401
|
+
const updateDimensions = () => {
|
|
402
|
+
if (!containerRef.current) return;
|
|
403
|
+
positioningCoordinator.setMapDimensions({
|
|
404
|
+
width: containerRef.current.offsetWidth,
|
|
405
|
+
height: containerRef.current.offsetHeight
|
|
406
|
+
});
|
|
407
|
+
};
|
|
408
|
+
updateDimensions();
|
|
409
|
+
const resizeObserver = new ResizeObserver(updateDimensions);
|
|
410
|
+
resizeObserver.observe(containerRef.current);
|
|
411
|
+
return () => {
|
|
412
|
+
resizeObserver.disconnect();
|
|
413
|
+
};
|
|
414
|
+
}, [positioningCoordinator]);
|
|
415
|
+
React26__namespace.useEffect(() => {
|
|
416
|
+
return () => {
|
|
417
|
+
positioningCoordinator.destroy();
|
|
418
|
+
};
|
|
419
|
+
}, [positioningCoordinator]);
|
|
420
|
+
React26__namespace.useEffect(() => {
|
|
472
421
|
if (!containerRef.current || mapRef.current) return;
|
|
473
422
|
try {
|
|
474
423
|
const map = new maplibregl__default.default.Map({
|
|
@@ -503,12 +452,45 @@ var Map2 = React25__namespace.forwardRef(
|
|
|
503
452
|
}),
|
|
504
453
|
navigationControlPosition
|
|
505
454
|
);
|
|
455
|
+
positioningCoordinator.register({
|
|
456
|
+
id: "maplibre-navigation-control",
|
|
457
|
+
type: "navigation",
|
|
458
|
+
isBuiltIn: true,
|
|
459
|
+
dimensions: { width: 29, height: 91 },
|
|
460
|
+
position: {
|
|
461
|
+
primary: navigationControlPosition
|
|
462
|
+
},
|
|
463
|
+
priority: "critical",
|
|
464
|
+
zLayer: "base"
|
|
465
|
+
});
|
|
506
466
|
}
|
|
507
467
|
if (scaleControl) {
|
|
508
468
|
map.addControl(new maplibregl__default.default.ScaleControl({ unit: "metric" }), scaleControlPosition);
|
|
469
|
+
positioningCoordinator.register({
|
|
470
|
+
id: "maplibre-scale-control",
|
|
471
|
+
type: "scale",
|
|
472
|
+
isBuiltIn: true,
|
|
473
|
+
dimensions: { width: 100, height: 20 },
|
|
474
|
+
position: {
|
|
475
|
+
primary: scaleControlPosition
|
|
476
|
+
},
|
|
477
|
+
priority: "critical",
|
|
478
|
+
zLayer: "base"
|
|
479
|
+
});
|
|
509
480
|
}
|
|
510
481
|
if (fullscreenControl) {
|
|
511
482
|
map.addControl(new maplibregl__default.default.FullscreenControl(), fullscreenControlPosition);
|
|
483
|
+
positioningCoordinator.register({
|
|
484
|
+
id: "maplibre-fullscreen-control",
|
|
485
|
+
type: "custom",
|
|
486
|
+
isBuiltIn: true,
|
|
487
|
+
dimensions: { width: 29, height: 29 },
|
|
488
|
+
position: {
|
|
489
|
+
primary: fullscreenControlPosition
|
|
490
|
+
},
|
|
491
|
+
priority: "critical",
|
|
492
|
+
zLayer: "base"
|
|
493
|
+
});
|
|
512
494
|
}
|
|
513
495
|
if (geolocateControl) {
|
|
514
496
|
map.addControl(
|
|
@@ -518,6 +500,17 @@ var Map2 = React25__namespace.forwardRef(
|
|
|
518
500
|
}),
|
|
519
501
|
geolocateControlPosition
|
|
520
502
|
);
|
|
503
|
+
positioningCoordinator.register({
|
|
504
|
+
id: "maplibre-geolocate-control",
|
|
505
|
+
type: "custom",
|
|
506
|
+
isBuiltIn: true,
|
|
507
|
+
dimensions: { width: 29, height: 29 },
|
|
508
|
+
position: {
|
|
509
|
+
primary: geolocateControlPosition
|
|
510
|
+
},
|
|
511
|
+
priority: "critical",
|
|
512
|
+
zLayer: "base"
|
|
513
|
+
});
|
|
521
514
|
}
|
|
522
515
|
map.on("load", () => {
|
|
523
516
|
setMapLoaded(true);
|
|
@@ -548,8 +541,8 @@ var Map2 = React25__namespace.forwardRef(
|
|
|
548
541
|
onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
|
|
549
542
|
}
|
|
550
543
|
}, []);
|
|
551
|
-
const styleInitialized =
|
|
552
|
-
|
|
544
|
+
const styleInitialized = React26__namespace.useRef(false);
|
|
545
|
+
React26__namespace.useEffect(() => {
|
|
553
546
|
if (!mapRef.current || !mapLoaded) return;
|
|
554
547
|
if (!styleInitialized.current) {
|
|
555
548
|
styleInitialized.current = true;
|
|
@@ -558,12 +551,12 @@ var Map2 = React25__namespace.forwardRef(
|
|
|
558
551
|
if (activeStyleOverrideRef.current) return;
|
|
559
552
|
mapRef.current.setStyle(mapStyle);
|
|
560
553
|
}, [mapStyle, mapLoaded]);
|
|
561
|
-
|
|
554
|
+
React26__namespace.useEffect(() => {
|
|
562
555
|
if (customStyle) {
|
|
563
556
|
activeStyleOverrideRef.current = null;
|
|
564
557
|
}
|
|
565
558
|
}, [customStyle]);
|
|
566
|
-
|
|
559
|
+
React26__namespace.useEffect(() => {
|
|
567
560
|
const map = mapRef.current;
|
|
568
561
|
if (!map || !mapLoaded) return;
|
|
569
562
|
const createEventParams = (e) => ({
|
|
@@ -680,12 +673,9 @@ var Map2 = React25__namespace.forwardRef(
|
|
|
680
673
|
value: {
|
|
681
674
|
map: mapRef.current,
|
|
682
675
|
loaded: mapLoaded,
|
|
683
|
-
controlOffsets,
|
|
684
|
-
registerControl,
|
|
685
|
-
unregisterControl,
|
|
686
|
-
getCustomControlOffset,
|
|
687
676
|
styleVersion,
|
|
688
|
-
setMapStyle
|
|
677
|
+
setMapStyle,
|
|
678
|
+
positioningCoordinator
|
|
689
679
|
},
|
|
690
680
|
children: [
|
|
691
681
|
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "absolute inset-0" }),
|
|
@@ -718,9 +708,9 @@ var Source = ({
|
|
|
718
708
|
children
|
|
719
709
|
}) => {
|
|
720
710
|
const { map, loaded, styleVersion } = useMap();
|
|
721
|
-
const
|
|
722
|
-
const
|
|
723
|
-
const fitBoundsParamsRef =
|
|
711
|
+
const initialFitDone = React26__namespace.useRef(false);
|
|
712
|
+
const lastStyleVersionRef = React26__namespace.useRef(styleVersion);
|
|
713
|
+
const fitBoundsParamsRef = React26__namespace.useRef({
|
|
724
714
|
shouldFitBounds,
|
|
725
715
|
data,
|
|
726
716
|
fitBoundsPadding,
|
|
@@ -736,7 +726,7 @@ var Source = ({
|
|
|
736
726
|
fitBoundsAnimate,
|
|
737
727
|
type
|
|
738
728
|
};
|
|
739
|
-
const performFitBounds =
|
|
729
|
+
const performFitBounds = React26__namespace.useCallback(
|
|
740
730
|
(cancelledRef) => {
|
|
741
731
|
const params = fitBoundsParamsRef.current;
|
|
742
732
|
if (cancelledRef.current || !params.shouldFitBounds || initialFitDone.current) return;
|
|
@@ -780,10 +770,13 @@ var Source = ({
|
|
|
780
770
|
},
|
|
781
771
|
[map]
|
|
782
772
|
);
|
|
783
|
-
|
|
784
|
-
if (!map || !loaded
|
|
773
|
+
React26__namespace.useEffect(() => {
|
|
774
|
+
if (!map || !loaded) return;
|
|
775
|
+
if (styleVersion !== lastStyleVersionRef.current) {
|
|
776
|
+
lastStyleVersionRef.current = styleVersion;
|
|
777
|
+
initialFitDone.current = false;
|
|
778
|
+
}
|
|
785
779
|
if (map.getSource(id)) {
|
|
786
|
-
sourceAdded.current = true;
|
|
787
780
|
return;
|
|
788
781
|
}
|
|
789
782
|
try {
|
|
@@ -870,7 +863,6 @@ var Source = ({
|
|
|
870
863
|
};
|
|
871
864
|
map.once("idle", handleIdle);
|
|
872
865
|
map.addSource(id, sourceConfig);
|
|
873
|
-
sourceAdded.current = true;
|
|
874
866
|
const source = map.getSource(id);
|
|
875
867
|
if (source && map.isSourceLoaded(id)) {
|
|
876
868
|
map.off("sourcedata", handleSourceData);
|
|
@@ -888,7 +880,7 @@ var Source = ({
|
|
|
888
880
|
};
|
|
889
881
|
return () => {
|
|
890
882
|
cleanupListeners();
|
|
891
|
-
if (map
|
|
883
|
+
if (map) {
|
|
892
884
|
try {
|
|
893
885
|
const style = map.getStyle();
|
|
894
886
|
if (style?.layers) {
|
|
@@ -905,7 +897,6 @@ var Source = ({
|
|
|
905
897
|
}
|
|
906
898
|
} catch {
|
|
907
899
|
}
|
|
908
|
-
sourceAdded.current = false;
|
|
909
900
|
}
|
|
910
901
|
};
|
|
911
902
|
} catch (err) {
|
|
@@ -930,8 +921,8 @@ var Source = ({
|
|
|
930
921
|
styleVersion
|
|
931
922
|
// re-add source after basemap style changes
|
|
932
923
|
]);
|
|
933
|
-
|
|
934
|
-
if (!map || !loaded ||
|
|
924
|
+
React26__namespace.useEffect(() => {
|
|
925
|
+
if (!map || !loaded || type !== "geojson") return;
|
|
935
926
|
const source = map.getSource(id);
|
|
936
927
|
if (!source) return;
|
|
937
928
|
let cancelled = false;
|
|
@@ -962,7 +953,7 @@ var Source = ({
|
|
|
962
953
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
963
954
|
};
|
|
964
955
|
Source.displayName = "Source";
|
|
965
|
-
var Marker =
|
|
956
|
+
var Marker = React26__namespace.forwardRef(
|
|
966
957
|
({
|
|
967
958
|
id,
|
|
968
959
|
coordinates,
|
|
@@ -978,27 +969,27 @@ var Marker = React25__namespace.forwardRef(
|
|
|
978
969
|
children
|
|
979
970
|
}, ref) => {
|
|
980
971
|
const { map, loaded } = useMap();
|
|
981
|
-
const markerRef =
|
|
982
|
-
const elementRef =
|
|
983
|
-
const originalLngLatRef =
|
|
984
|
-
const clickHandlerRef =
|
|
985
|
-
const [mounted, setMounted] =
|
|
986
|
-
const onClickRef =
|
|
972
|
+
const markerRef = React26__namespace.useRef(null);
|
|
973
|
+
const elementRef = React26__namespace.useRef(null);
|
|
974
|
+
const originalLngLatRef = React26__namespace.useRef();
|
|
975
|
+
const clickHandlerRef = React26__namespace.useRef(null);
|
|
976
|
+
const [mounted, setMounted] = React26__namespace.useState(false);
|
|
977
|
+
const onClickRef = React26__namespace.useRef(onClick);
|
|
987
978
|
onClickRef.current = onClick;
|
|
988
|
-
const onDragRef =
|
|
979
|
+
const onDragRef = React26__namespace.useRef(onDrag);
|
|
989
980
|
onDragRef.current = onDrag;
|
|
990
|
-
const onDragEndRef =
|
|
981
|
+
const onDragEndRef = React26__namespace.useRef(onDragEnd);
|
|
991
982
|
onDragEndRef.current = onDragEnd;
|
|
992
|
-
|
|
983
|
+
React26__namespace.useEffect(() => {
|
|
993
984
|
setMounted(true);
|
|
994
985
|
return () => setMounted(false);
|
|
995
986
|
}, []);
|
|
996
|
-
|
|
987
|
+
React26__namespace.useEffect(() => {
|
|
997
988
|
if (children && !elementRef.current) {
|
|
998
989
|
elementRef.current = document.createElement("div");
|
|
999
990
|
}
|
|
1000
991
|
}, [children]);
|
|
1001
|
-
|
|
992
|
+
React26__namespace.useEffect(() => {
|
|
1002
993
|
if (!map || !loaded || !mounted) return;
|
|
1003
994
|
if (markerRef.current) return;
|
|
1004
995
|
const markerOptions = {
|
|
@@ -1082,17 +1073,17 @@ var Marker = React25__namespace.forwardRef(
|
|
|
1082
1073
|
}
|
|
1083
1074
|
};
|
|
1084
1075
|
}, [map, loaded, mounted]);
|
|
1085
|
-
|
|
1076
|
+
React26__namespace.useEffect(() => {
|
|
1086
1077
|
if (markerRef.current) {
|
|
1087
1078
|
markerRef.current.setLngLat(coordinates);
|
|
1088
1079
|
}
|
|
1089
1080
|
}, [coordinates]);
|
|
1090
|
-
|
|
1081
|
+
React26__namespace.useEffect(() => {
|
|
1091
1082
|
if (markerRef.current) {
|
|
1092
1083
|
markerRef.current.setDraggable(draggable);
|
|
1093
1084
|
}
|
|
1094
1085
|
}, [draggable]);
|
|
1095
|
-
|
|
1086
|
+
React26__namespace.useEffect(() => {
|
|
1096
1087
|
if (markerRef.current && rotation !== void 0) {
|
|
1097
1088
|
markerRef.current.setRotation(rotation);
|
|
1098
1089
|
}
|
|
@@ -1138,7 +1129,7 @@ function panToFitPopup(map, popup, padding) {
|
|
|
1138
1129
|
});
|
|
1139
1130
|
}
|
|
1140
1131
|
}
|
|
1141
|
-
var Popup =
|
|
1132
|
+
var Popup = React26__namespace.forwardRef(
|
|
1142
1133
|
({
|
|
1143
1134
|
coordinates,
|
|
1144
1135
|
closeButton = true,
|
|
@@ -1156,25 +1147,25 @@ var Popup = React25__namespace.forwardRef(
|
|
|
1156
1147
|
children
|
|
1157
1148
|
}, ref) => {
|
|
1158
1149
|
const { map, loaded } = useMap();
|
|
1159
|
-
const popupRef =
|
|
1160
|
-
const onOpenRef =
|
|
1150
|
+
const popupRef = React26__namespace.useRef(null);
|
|
1151
|
+
const onOpenRef = React26__namespace.useRef(onOpen);
|
|
1161
1152
|
onOpenRef.current = onOpen;
|
|
1162
|
-
const onCloseRef =
|
|
1153
|
+
const onCloseRef = React26__namespace.useRef(onClose);
|
|
1163
1154
|
onCloseRef.current = onClose;
|
|
1164
|
-
const coordinatesRef =
|
|
1155
|
+
const coordinatesRef = React26__namespace.useRef(coordinates);
|
|
1165
1156
|
coordinatesRef.current = coordinates;
|
|
1166
|
-
const containerRef =
|
|
1157
|
+
const containerRef = React26__namespace.useRef(null);
|
|
1167
1158
|
if (!containerRef.current && typeof document !== "undefined") {
|
|
1168
1159
|
containerRef.current = document.createElement("div");
|
|
1169
1160
|
containerRef.current.className = "maplibregl-popup-content-wrapper";
|
|
1170
1161
|
}
|
|
1171
|
-
const [contentReady, setContentReady] =
|
|
1172
|
-
const contentCallbackRef =
|
|
1162
|
+
const [contentReady, setContentReady] = React26__namespace.useState(false);
|
|
1163
|
+
const contentCallbackRef = React26__namespace.useCallback((node) => {
|
|
1173
1164
|
if (node && containerRef.current) {
|
|
1174
1165
|
setContentReady(true);
|
|
1175
1166
|
}
|
|
1176
1167
|
}, []);
|
|
1177
|
-
|
|
1168
|
+
React26__namespace.useEffect(() => {
|
|
1178
1169
|
if (!map || !loaded || !containerRef.current) return;
|
|
1179
1170
|
const popup = new maplibregl__default.default.Popup({
|
|
1180
1171
|
closeButton,
|
|
@@ -1214,7 +1205,7 @@ var Popup = React25__namespace.forwardRef(
|
|
|
1214
1205
|
maxWidth,
|
|
1215
1206
|
focusAfterOpen
|
|
1216
1207
|
]);
|
|
1217
|
-
|
|
1208
|
+
React26__namespace.useEffect(() => {
|
|
1218
1209
|
if (!popupRef.current || !ref) return;
|
|
1219
1210
|
if (typeof ref === "function") {
|
|
1220
1211
|
ref(popupRef.current);
|
|
@@ -1222,12 +1213,12 @@ var Popup = React25__namespace.forwardRef(
|
|
|
1222
1213
|
ref.current = popupRef.current;
|
|
1223
1214
|
}
|
|
1224
1215
|
}, [ref]);
|
|
1225
|
-
|
|
1216
|
+
React26__namespace.useEffect(() => {
|
|
1226
1217
|
if (popupRef.current) {
|
|
1227
1218
|
popupRef.current.setLngLat(coordinates);
|
|
1228
1219
|
}
|
|
1229
1220
|
}, [coordinates]);
|
|
1230
|
-
|
|
1221
|
+
React26__namespace.useEffect(() => {
|
|
1231
1222
|
if (!map || !popupRef.current || !contentReady) return;
|
|
1232
1223
|
let rafHandle;
|
|
1233
1224
|
if (open) {
|
|
@@ -1256,7 +1247,7 @@ var Popup = React25__namespace.forwardRef(
|
|
|
1256
1247
|
}
|
|
1257
1248
|
);
|
|
1258
1249
|
Popup.displayName = "Popup";
|
|
1259
|
-
var PopupCard =
|
|
1250
|
+
var PopupCard = React26__namespace.forwardRef(
|
|
1260
1251
|
({ className, children, ...props }, ref) => {
|
|
1261
1252
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("bg-popover text-popover-foreground", className), ...props, children });
|
|
1262
1253
|
}
|
|
@@ -1276,7 +1267,7 @@ var badgeVariants = classVarianceAuthority.cva("text-xs px-1.5 py-0.5 rounded fo
|
|
|
1276
1267
|
badgeVariant: "secondary"
|
|
1277
1268
|
}
|
|
1278
1269
|
});
|
|
1279
|
-
var PopupHeader =
|
|
1270
|
+
var PopupHeader = React26__namespace.forwardRef(
|
|
1280
1271
|
({ className, title, badge, badgeVariant, ...props }, ref) => {
|
|
1281
1272
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1282
1273
|
"div",
|
|
@@ -1296,13 +1287,13 @@ var PopupHeader = React25__namespace.forwardRef(
|
|
|
1296
1287
|
}
|
|
1297
1288
|
);
|
|
1298
1289
|
PopupHeader.displayName = "PopupHeader";
|
|
1299
|
-
var PopupContent =
|
|
1290
|
+
var PopupContent = React26__namespace.forwardRef(
|
|
1300
1291
|
({ className, children, ...props }, ref) => {
|
|
1301
1292
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("px-4 py-3 text-sm", className), ...props, children });
|
|
1302
1293
|
}
|
|
1303
1294
|
);
|
|
1304
1295
|
PopupContent.displayName = "PopupContent";
|
|
1305
|
-
var PopupFooter =
|
|
1296
|
+
var PopupFooter = React26__namespace.forwardRef(
|
|
1306
1297
|
({ className, children, ...props }, ref) => {
|
|
1307
1298
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1308
1299
|
"div",
|
|
@@ -1337,14 +1328,14 @@ function useLayer({
|
|
|
1337
1328
|
hoverThrottleMs = 0
|
|
1338
1329
|
}) {
|
|
1339
1330
|
const { map, loaded, styleVersion } = useMap();
|
|
1340
|
-
const [layerAdded, setLayerAdded] =
|
|
1341
|
-
const hoveredFeatureId =
|
|
1342
|
-
const lastHoverCallTime =
|
|
1343
|
-
const lastMousePosition =
|
|
1344
|
-
|
|
1331
|
+
const [layerAdded, setLayerAdded] = React26__namespace.useState(false);
|
|
1332
|
+
const hoveredFeatureId = React26__namespace.useRef(null);
|
|
1333
|
+
const lastHoverCallTime = React26__namespace.useRef(0);
|
|
1334
|
+
const lastMousePosition = React26__namespace.useRef(null);
|
|
1335
|
+
React26__namespace.useEffect(() => {
|
|
1345
1336
|
hoveredFeatureId.current = null;
|
|
1346
1337
|
}, [styleVersion]);
|
|
1347
|
-
|
|
1338
|
+
React26__namespace.useEffect(() => {
|
|
1348
1339
|
if (!map || !loaded) return;
|
|
1349
1340
|
if (!map.getSource(source)) {
|
|
1350
1341
|
let timeoutId = null;
|
|
@@ -1415,24 +1406,24 @@ function useLayer({
|
|
|
1415
1406
|
}
|
|
1416
1407
|
};
|
|
1417
1408
|
}, [map, loaded, id, source, sourceLayer, type, beforeId, styleVersion]);
|
|
1418
|
-
|
|
1409
|
+
React26__namespace.useEffect(() => {
|
|
1419
1410
|
if (!map || !layerAdded) return;
|
|
1420
1411
|
if (!map.getLayer(id)) return;
|
|
1421
1412
|
map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
|
|
1422
1413
|
}, [map, id, visible, layerAdded]);
|
|
1423
|
-
|
|
1414
|
+
React26__namespace.useEffect(() => {
|
|
1424
1415
|
if (!map || !layerAdded) return;
|
|
1425
1416
|
if (!map.getLayer(id)) return;
|
|
1426
1417
|
Object.entries(paint).forEach(([key, value]) => {
|
|
1427
1418
|
map.setPaintProperty(id, key, value);
|
|
1428
1419
|
});
|
|
1429
1420
|
}, [map, id, paint, layerAdded]);
|
|
1430
|
-
|
|
1421
|
+
React26__namespace.useEffect(() => {
|
|
1431
1422
|
if (!map || !layerAdded || !filter) return;
|
|
1432
1423
|
if (!map.getLayer(id)) return;
|
|
1433
1424
|
map.setFilter(id, filter);
|
|
1434
1425
|
}, [map, id, filter, layerAdded]);
|
|
1435
|
-
|
|
1426
|
+
React26__namespace.useEffect(() => {
|
|
1436
1427
|
if (!map || !layerAdded) return;
|
|
1437
1428
|
const createFeatureParams = (e) => {
|
|
1438
1429
|
const feature = e.features?.[0];
|
|
@@ -1568,7 +1559,7 @@ var FillLayer = ({
|
|
|
1568
1559
|
fillTranslate,
|
|
1569
1560
|
fillAntialias
|
|
1570
1561
|
}) => {
|
|
1571
|
-
const paint =
|
|
1562
|
+
const paint = React26__namespace.useMemo(() => {
|
|
1572
1563
|
const p = {};
|
|
1573
1564
|
if (fillColor !== void 0) p["fill-color"] = fillColor;
|
|
1574
1565
|
if (fillOpacity !== void 0) p["fill-opacity"] = fillOpacity;
|
|
@@ -1589,7 +1580,7 @@ var FillLayer = ({
|
|
|
1589
1580
|
fillAntialias,
|
|
1590
1581
|
opacity
|
|
1591
1582
|
]);
|
|
1592
|
-
const layout =
|
|
1583
|
+
const layout = React26__namespace.useMemo(() => ({}), []);
|
|
1593
1584
|
useLayer({
|
|
1594
1585
|
id,
|
|
1595
1586
|
source,
|
|
@@ -1633,7 +1624,7 @@ var LineLayer = ({
|
|
|
1633
1624
|
lineOffset,
|
|
1634
1625
|
lineGradient
|
|
1635
1626
|
}) => {
|
|
1636
|
-
const paint =
|
|
1627
|
+
const paint = React26__namespace.useMemo(() => {
|
|
1637
1628
|
const p = {};
|
|
1638
1629
|
if (lineColor !== void 0) p["line-color"] = lineColor;
|
|
1639
1630
|
if (lineWidth !== void 0) p["line-width"] = lineWidth;
|
|
@@ -1658,7 +1649,7 @@ var LineLayer = ({
|
|
|
1658
1649
|
lineGradient,
|
|
1659
1650
|
opacity
|
|
1660
1651
|
]);
|
|
1661
|
-
const layout =
|
|
1652
|
+
const layout = React26__namespace.useMemo(() => {
|
|
1662
1653
|
const l = {};
|
|
1663
1654
|
if (lineCap !== void 0) l["line-cap"] = lineCap;
|
|
1664
1655
|
if (lineJoin !== void 0) l["line-join"] = lineJoin;
|
|
@@ -1707,7 +1698,7 @@ var CircleLayer = ({
|
|
|
1707
1698
|
circlePitchScale,
|
|
1708
1699
|
circleTranslate
|
|
1709
1700
|
}) => {
|
|
1710
|
-
const paint =
|
|
1701
|
+
const paint = React26__namespace.useMemo(() => {
|
|
1711
1702
|
const p = {};
|
|
1712
1703
|
if (circleRadius !== void 0) p["circle-radius"] = circleRadius;
|
|
1713
1704
|
if (circleColor !== void 0) p["circle-color"] = circleColor;
|
|
@@ -1736,7 +1727,7 @@ var CircleLayer = ({
|
|
|
1736
1727
|
circleTranslate,
|
|
1737
1728
|
opacity
|
|
1738
1729
|
]);
|
|
1739
|
-
const layout =
|
|
1730
|
+
const layout = React26__namespace.useMemo(() => ({}), []);
|
|
1740
1731
|
useLayer({
|
|
1741
1732
|
id,
|
|
1742
1733
|
source,
|
|
@@ -1796,7 +1787,7 @@ var SymbolLayer = ({
|
|
|
1796
1787
|
symbolSpacing,
|
|
1797
1788
|
symbolSortKey
|
|
1798
1789
|
}) => {
|
|
1799
|
-
const paint =
|
|
1790
|
+
const paint = React26__namespace.useMemo(() => {
|
|
1800
1791
|
const p = {};
|
|
1801
1792
|
if (iconOpacity !== void 0) p["icon-opacity"] = iconOpacity;
|
|
1802
1793
|
if (iconColor !== void 0) p["icon-color"] = iconColor;
|
|
@@ -1817,7 +1808,7 @@ var SymbolLayer = ({
|
|
|
1817
1808
|
textHaloColor,
|
|
1818
1809
|
textHaloWidth
|
|
1819
1810
|
]);
|
|
1820
|
-
const layout =
|
|
1811
|
+
const layout = React26__namespace.useMemo(() => {
|
|
1821
1812
|
const l = {};
|
|
1822
1813
|
if (iconImage !== void 0) l["icon-image"] = iconImage;
|
|
1823
1814
|
if (iconSize !== void 0) l["icon-size"] = iconSize;
|
|
@@ -1898,7 +1889,7 @@ var FillExtrusionLayer = ({
|
|
|
1898
1889
|
fillExtrusionTranslate,
|
|
1899
1890
|
fillExtrusionVerticalGradient
|
|
1900
1891
|
}) => {
|
|
1901
|
-
const paint =
|
|
1892
|
+
const paint = React26__namespace.useMemo(() => {
|
|
1902
1893
|
const p = {};
|
|
1903
1894
|
if (fillExtrusionHeight !== void 0) p["fill-extrusion-height"] = fillExtrusionHeight;
|
|
1904
1895
|
if (fillExtrusionBase !== void 0) p["fill-extrusion-base"] = fillExtrusionBase;
|
|
@@ -1924,7 +1915,7 @@ var FillExtrusionLayer = ({
|
|
|
1924
1915
|
fillExtrusionVerticalGradient,
|
|
1925
1916
|
opacity
|
|
1926
1917
|
]);
|
|
1927
|
-
const layout =
|
|
1918
|
+
const layout = React26__namespace.useMemo(() => ({}), []);
|
|
1928
1919
|
useLayer({
|
|
1929
1920
|
id,
|
|
1930
1921
|
source,
|
|
@@ -1963,7 +1954,7 @@ var HeatmapLayer = ({
|
|
|
1963
1954
|
heatmapRadius,
|
|
1964
1955
|
heatmapOpacity
|
|
1965
1956
|
}) => {
|
|
1966
|
-
const paint =
|
|
1957
|
+
const paint = React26__namespace.useMemo(() => {
|
|
1967
1958
|
const p = {};
|
|
1968
1959
|
if (heatmapIntensity !== void 0) p["heatmap-intensity"] = heatmapIntensity;
|
|
1969
1960
|
if (heatmapWeight !== void 0) p["heatmap-weight"] = heatmapWeight;
|
|
@@ -1975,7 +1966,7 @@ var HeatmapLayer = ({
|
|
|
1975
1966
|
}
|
|
1976
1967
|
return p;
|
|
1977
1968
|
}, [heatmapIntensity, heatmapWeight, heatmapColor, heatmapRadius, heatmapOpacity, opacity]);
|
|
1978
|
-
const layout =
|
|
1969
|
+
const layout = React26__namespace.useMemo(() => ({}), []);
|
|
1979
1970
|
useLayer({
|
|
1980
1971
|
id,
|
|
1981
1972
|
source,
|
|
@@ -1995,6 +1986,127 @@ var HeatmapLayer = ({
|
|
|
1995
1986
|
return null;
|
|
1996
1987
|
};
|
|
1997
1988
|
HeatmapLayer.displayName = "HeatmapLayer";
|
|
1989
|
+
function useControlPosition(ref, options) {
|
|
1990
|
+
const {
|
|
1991
|
+
id,
|
|
1992
|
+
type,
|
|
1993
|
+
position,
|
|
1994
|
+
fallbacks,
|
|
1995
|
+
priority = "normal",
|
|
1996
|
+
zLayer = "interactive",
|
|
1997
|
+
hasExpandedState = false,
|
|
1998
|
+
isBuiltIn = false
|
|
1999
|
+
} = options;
|
|
2000
|
+
const { positioningCoordinator } = useMap();
|
|
2001
|
+
const [offset, setOffset] = React26__namespace.useState(null);
|
|
2002
|
+
React26__namespace.useEffect(() => {
|
|
2003
|
+
if (!ref.current || !positioningCoordinator) return;
|
|
2004
|
+
const element = ref.current;
|
|
2005
|
+
const initialOffset = positioningCoordinator.register({
|
|
2006
|
+
id,
|
|
2007
|
+
type,
|
|
2008
|
+
isBuiltIn,
|
|
2009
|
+
dimensions: {
|
|
2010
|
+
width: element.offsetWidth || 200,
|
|
2011
|
+
height: element.offsetHeight || 100
|
|
2012
|
+
},
|
|
2013
|
+
position: {
|
|
2014
|
+
primary: position,
|
|
2015
|
+
fallbacks
|
|
2016
|
+
},
|
|
2017
|
+
priority,
|
|
2018
|
+
zLayer,
|
|
2019
|
+
hasExpandedState,
|
|
2020
|
+
isExpanded: false
|
|
2021
|
+
});
|
|
2022
|
+
setOffset(initialOffset);
|
|
2023
|
+
const unsubscribe = positioningCoordinator.subscribe((event) => {
|
|
2024
|
+
const newOffset = event.offsets.get(id);
|
|
2025
|
+
if (newOffset) {
|
|
2026
|
+
setOffset(newOffset);
|
|
2027
|
+
}
|
|
2028
|
+
});
|
|
2029
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
2030
|
+
if (!element) return;
|
|
2031
|
+
positioningCoordinator.update(id, {
|
|
2032
|
+
dimensions: {
|
|
2033
|
+
width: element.offsetWidth,
|
|
2034
|
+
height: element.offsetHeight
|
|
2035
|
+
}
|
|
2036
|
+
});
|
|
2037
|
+
});
|
|
2038
|
+
resizeObserver.observe(element);
|
|
2039
|
+
return () => {
|
|
2040
|
+
resizeObserver.disconnect();
|
|
2041
|
+
unsubscribe();
|
|
2042
|
+
positioningCoordinator.unregister(id);
|
|
2043
|
+
};
|
|
2044
|
+
}, [
|
|
2045
|
+
id,
|
|
2046
|
+
type,
|
|
2047
|
+
position,
|
|
2048
|
+
fallbacks,
|
|
2049
|
+
priority,
|
|
2050
|
+
zLayer,
|
|
2051
|
+
hasExpandedState,
|
|
2052
|
+
isBuiltIn,
|
|
2053
|
+
positioningCoordinator,
|
|
2054
|
+
ref
|
|
2055
|
+
]);
|
|
2056
|
+
React26__namespace.useEffect(() => {
|
|
2057
|
+
if (!positioningCoordinator) return;
|
|
2058
|
+
positioningCoordinator.update(id, {
|
|
2059
|
+
position: {
|
|
2060
|
+
primary: position,
|
|
2061
|
+
fallbacks
|
|
2062
|
+
},
|
|
2063
|
+
priority,
|
|
2064
|
+
zLayer
|
|
2065
|
+
});
|
|
2066
|
+
}, [id, position, fallbacks, priority, zLayer, positioningCoordinator]);
|
|
2067
|
+
const setExpanded = React26__namespace.useCallback(
|
|
2068
|
+
(isExpanded) => {
|
|
2069
|
+
if (positioningCoordinator) {
|
|
2070
|
+
positioningCoordinator.setExpanded(id, isExpanded);
|
|
2071
|
+
}
|
|
2072
|
+
},
|
|
2073
|
+
[id, positioningCoordinator]
|
|
2074
|
+
);
|
|
2075
|
+
const style = React26__namespace.useMemo(() => {
|
|
2076
|
+
if (!offset) {
|
|
2077
|
+
return {
|
|
2078
|
+
position: "absolute",
|
|
2079
|
+
visibility: "hidden"
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
const resolvedPosition = offset.position;
|
|
2083
|
+
const isLeftPosition = resolvedPosition.includes("left") || resolvedPosition.includes("center");
|
|
2084
|
+
const isCenterHorizontal = resolvedPosition.includes("center");
|
|
2085
|
+
const baseStyle = {
|
|
2086
|
+
position: "absolute",
|
|
2087
|
+
zIndex: offset.zIndex
|
|
2088
|
+
};
|
|
2089
|
+
if (isCenterHorizontal) {
|
|
2090
|
+
baseStyle.left = offset.x;
|
|
2091
|
+
} else if (isLeftPosition) {
|
|
2092
|
+
baseStyle.left = offset.x;
|
|
2093
|
+
} else {
|
|
2094
|
+
baseStyle.right = offset.x;
|
|
2095
|
+
}
|
|
2096
|
+
if (resolvedPosition.startsWith("bottom")) {
|
|
2097
|
+
baseStyle.bottom = offset.y;
|
|
2098
|
+
} else {
|
|
2099
|
+
baseStyle.top = offset.y;
|
|
2100
|
+
}
|
|
2101
|
+
return baseStyle;
|
|
2102
|
+
}, [offset]);
|
|
2103
|
+
return {
|
|
2104
|
+
offset,
|
|
2105
|
+
setExpanded,
|
|
2106
|
+
style,
|
|
2107
|
+
visible: offset?.visible ?? false
|
|
2108
|
+
};
|
|
2109
|
+
}
|
|
1998
2110
|
var legendIdCounter = 0;
|
|
1999
2111
|
var Legend = ({
|
|
2000
2112
|
title,
|
|
@@ -2009,30 +2121,17 @@ var Legend = ({
|
|
|
2009
2121
|
class: className,
|
|
2010
2122
|
onItemClick
|
|
2011
2123
|
}) => {
|
|
2012
|
-
const
|
|
2013
|
-
const
|
|
2014
|
-
const
|
|
2015
|
-
const
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
setCustomControlOffset(offset);
|
|
2024
|
-
};
|
|
2025
|
-
updatePosition();
|
|
2026
|
-
const observer = new ResizeObserver(updatePosition);
|
|
2027
|
-
observer.observe(legendRef.current);
|
|
2028
|
-
return () => {
|
|
2029
|
-
observer.disconnect();
|
|
2030
|
-
unregisterControl?.(legendIdRef.current, position);
|
|
2031
|
-
};
|
|
2032
|
-
}, [position, registerControl, unregisterControl]);
|
|
2033
|
-
const verticalOffsetStyle = React25__namespace.useMemo(() => {
|
|
2034
|
-
return mapsCore.computeVerticalOffsetStyle(position, customControlOffset);
|
|
2035
|
-
}, [customControlOffset, position]);
|
|
2124
|
+
const [isCollapsed, setIsCollapsed] = React26__namespace.useState(initialCollapsed);
|
|
2125
|
+
const legendRef = React26__namespace.useRef(null);
|
|
2126
|
+
const legendIdRef = React26__namespace.useRef(`legend-${++legendIdCounter}`);
|
|
2127
|
+
const { style, visible } = useControlPosition(legendRef, {
|
|
2128
|
+
id: legendIdRef.current,
|
|
2129
|
+
type: "legend",
|
|
2130
|
+
position,
|
|
2131
|
+
priority: "normal",
|
|
2132
|
+
zLayer: "interactive",
|
|
2133
|
+
hasExpandedState: collapsible
|
|
2134
|
+
});
|
|
2036
2135
|
const handleItemClick = (item, index) => {
|
|
2037
2136
|
if (onItemClick) {
|
|
2038
2137
|
onItemClick(item, index);
|
|
@@ -2043,26 +2142,22 @@ var Legend = ({
|
|
|
2043
2142
|
setIsCollapsed(!isCollapsed);
|
|
2044
2143
|
}
|
|
2045
2144
|
};
|
|
2046
|
-
const gradientStyle =
|
|
2145
|
+
const gradientStyle = React26__namespace.useMemo(() => {
|
|
2047
2146
|
if (type !== "gradient" || gradient.length === 0) return "";
|
|
2048
2147
|
const stops = gradient.map((stop) => `${stop.color} ${stop.position * 100}%`).join(", ");
|
|
2049
2148
|
return `linear-gradient(to right, ${stops})`;
|
|
2050
2149
|
}, [type, gradient]);
|
|
2051
|
-
const hasControlsAtPosition = (controlOffsets?.[position] ?? 0) > 0;
|
|
2052
|
-
const computedPositionClasses = React25__namespace.useMemo(() => {
|
|
2053
|
-
return mapsCore.computePositionClasses(position, hasControlsAtPosition);
|
|
2054
|
-
}, [position, hasControlsAtPosition]);
|
|
2055
2150
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2056
2151
|
"div",
|
|
2057
2152
|
{
|
|
2058
2153
|
ref: legendRef,
|
|
2059
2154
|
className: cn(
|
|
2060
|
-
"absolute
|
|
2155
|
+
"absolute bg-card rounded-lg shadow-lg border border-black dark:border-gray-400",
|
|
2061
2156
|
"text-sm min-w-[140px] max-w-[280px]",
|
|
2062
|
-
|
|
2157
|
+
!visible && "invisible",
|
|
2063
2158
|
className
|
|
2064
2159
|
),
|
|
2065
|
-
style
|
|
2160
|
+
style,
|
|
2066
2161
|
children: [
|
|
2067
2162
|
(title || collapsible) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2068
2163
|
"button",
|
|
@@ -2148,45 +2243,31 @@ var LegendGroup = ({
|
|
|
2148
2243
|
allowCollapseAll = false,
|
|
2149
2244
|
class: className
|
|
2150
2245
|
}) => {
|
|
2151
|
-
const
|
|
2152
|
-
const
|
|
2153
|
-
const groupIdRef = React25__namespace.useRef(`legend-group-${++legendGroupIdCounter}`);
|
|
2154
|
-
const [customControlOffset, setCustomControlOffset] = React25__namespace.useState(0);
|
|
2246
|
+
const containerRef = React26__namespace.useRef(null);
|
|
2247
|
+
const groupIdRef = React26__namespace.useRef(`legend-group-${++legendGroupIdCounter}`);
|
|
2155
2248
|
const getInitialExpanded = () => {
|
|
2156
2249
|
if (controlledExpanded !== void 0) return controlledExpanded;
|
|
2157
2250
|
if (defaultExpanded) return defaultExpanded;
|
|
2158
2251
|
return legends[0]?.id || null;
|
|
2159
2252
|
};
|
|
2160
|
-
const [internalExpanded, setInternalExpanded] =
|
|
2253
|
+
const [internalExpanded, setInternalExpanded] = React26__namespace.useState(getInitialExpanded);
|
|
2161
2254
|
const expandedId = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
|
|
2255
|
+
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2256
|
+
id: groupIdRef.current,
|
|
2257
|
+
type: "legend-group",
|
|
2258
|
+
position,
|
|
2259
|
+
priority: "normal",
|
|
2260
|
+
zLayer: "interactive",
|
|
2261
|
+
hasExpandedState: true
|
|
2262
|
+
});
|
|
2162
2263
|
const handleToggle = (id) => {
|
|
2163
2264
|
const newExpanded = expandedId === id ? allowCollapseAll ? null : id : id;
|
|
2164
2265
|
if (controlledExpanded === void 0) {
|
|
2165
2266
|
setInternalExpanded(newExpanded);
|
|
2166
2267
|
}
|
|
2268
|
+
setExpanded(newExpanded !== null);
|
|
2167
2269
|
onExpandedChange?.(newExpanded);
|
|
2168
2270
|
};
|
|
2169
|
-
React25__namespace.useEffect(() => {
|
|
2170
|
-
if (!containerRef.current || !registerControl) return;
|
|
2171
|
-
const timeoutId = setTimeout(() => {
|
|
2172
|
-
if (containerRef.current) {
|
|
2173
|
-
const height = containerRef.current.offsetHeight;
|
|
2174
|
-
const offset = registerControl(groupIdRef.current, position, height);
|
|
2175
|
-
setCustomControlOffset(offset);
|
|
2176
|
-
}
|
|
2177
|
-
}, 50);
|
|
2178
|
-
return () => {
|
|
2179
|
-
clearTimeout(timeoutId);
|
|
2180
|
-
unregisterControl?.(groupIdRef.current, position);
|
|
2181
|
-
};
|
|
2182
|
-
}, [position, expandedId, registerControl, unregisterControl]);
|
|
2183
|
-
const verticalOffsetStyle = React25__namespace.useMemo(() => {
|
|
2184
|
-
return mapsCore.computeVerticalOffsetStyle(position, customControlOffset);
|
|
2185
|
-
}, [customControlOffset, position]);
|
|
2186
|
-
const hasControlsAtPosition = (controlOffsets?.[position] ?? 0) > 0;
|
|
2187
|
-
const computedPositionClasses = React25__namespace.useMemo(() => {
|
|
2188
|
-
return mapsCore.computePositionClasses(position, hasControlsAtPosition);
|
|
2189
|
-
}, [position, hasControlsAtPosition]);
|
|
2190
2271
|
const getGradientStyle = (legend) => {
|
|
2191
2272
|
if (legend.type !== "gradient" || !legend.gradient?.length) return "";
|
|
2192
2273
|
const stops = legend.gradient.map((stop) => `${stop.color} ${stop.position * 100}%`).join(", ");
|
|
@@ -2200,12 +2281,12 @@ var LegendGroup = ({
|
|
|
2200
2281
|
{
|
|
2201
2282
|
ref: containerRef,
|
|
2202
2283
|
className: cn(
|
|
2203
|
-
"absolute
|
|
2284
|
+
"absolute bg-card rounded-lg shadow-lg border border-black dark:border-gray-400",
|
|
2204
2285
|
"text-sm min-w-[160px] max-w-[280px]",
|
|
2205
|
-
|
|
2286
|
+
!visible && "invisible",
|
|
2206
2287
|
className
|
|
2207
2288
|
),
|
|
2208
|
-
style
|
|
2289
|
+
style,
|
|
2209
2290
|
children: legends.map((legend, legendIndex) => {
|
|
2210
2291
|
const isExpanded = expandedId === legend.id;
|
|
2211
2292
|
const isFirst = legendIndex === 0;
|
|
@@ -2306,6 +2387,7 @@ var LegendGroup = ({
|
|
|
2306
2387
|
};
|
|
2307
2388
|
LegendGroup.displayName = "LegendGroup";
|
|
2308
2389
|
var coordDisplayIdCounter = 0;
|
|
2390
|
+
var NAV_CONTROL_WIDTH = 29;
|
|
2309
2391
|
var CoordinateDisplay = ({
|
|
2310
2392
|
position = "bottom-right",
|
|
2311
2393
|
format = "decimal",
|
|
@@ -2314,33 +2396,40 @@ var CoordinateDisplay = ({
|
|
|
2314
2396
|
showBearing = false,
|
|
2315
2397
|
class: className
|
|
2316
2398
|
}) => {
|
|
2317
|
-
const { map, loaded
|
|
2318
|
-
const [cursorLngLat, setCursorLngLat] =
|
|
2319
|
-
const [currentZoom, setCurrentZoom] =
|
|
2320
|
-
const [currentBearing, setCurrentBearing] =
|
|
2321
|
-
const
|
|
2322
|
-
const
|
|
2323
|
-
const
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2399
|
+
const { map, loaded } = useMap();
|
|
2400
|
+
const [cursorLngLat, setCursorLngLat] = React26__namespace.useState(null);
|
|
2401
|
+
const [currentZoom, setCurrentZoom] = React26__namespace.useState(0);
|
|
2402
|
+
const [currentBearing, setCurrentBearing] = React26__namespace.useState(0);
|
|
2403
|
+
const controlRef = React26__namespace.useRef(null);
|
|
2404
|
+
const controlIdRef = React26__namespace.useRef(`coord-display-${++coordDisplayIdCounter}`);
|
|
2405
|
+
const { style, visible } = useControlPosition(controlRef, {
|
|
2406
|
+
id: controlIdRef.current,
|
|
2407
|
+
type: "coordinate-display",
|
|
2408
|
+
position,
|
|
2409
|
+
priority: "critical",
|
|
2410
|
+
zLayer: "base"
|
|
2411
|
+
});
|
|
2412
|
+
const adjustedStyle = React26__namespace.useMemo(() => {
|
|
2413
|
+
if (!style) return style;
|
|
2414
|
+
if (position === "top-right") {
|
|
2415
|
+
const rightOffset = NAV_CONTROL_WIDTH + mapsCore.STACK_GAP + mapsCore.EDGE_MARGIN;
|
|
2416
|
+
return {
|
|
2417
|
+
...style,
|
|
2418
|
+
top: mapsCore.EDGE_MARGIN,
|
|
2419
|
+
right: rightOffset
|
|
2420
|
+
};
|
|
2421
|
+
}
|
|
2422
|
+
if (position === "bottom-right") {
|
|
2423
|
+
const ATTRIBUTION_HEIGHT = 32;
|
|
2424
|
+
const bottomOffset = mapsCore.EDGE_MARGIN + ATTRIBUTION_HEIGHT;
|
|
2425
|
+
return {
|
|
2426
|
+
...style,
|
|
2427
|
+
bottom: bottomOffset
|
|
2428
|
+
};
|
|
2429
|
+
}
|
|
2430
|
+
return style;
|
|
2431
|
+
}, [position, style]);
|
|
2432
|
+
const formatCoord = React26__namespace.useCallback(
|
|
2344
2433
|
(lngLat) => {
|
|
2345
2434
|
return mapsCore.formatCoordinates(lngLat, precision, format);
|
|
2346
2435
|
},
|
|
@@ -2353,11 +2442,7 @@ var CoordinateDisplay = ({
|
|
|
2353
2442
|
const normalized = (bearing % 360 + 360) % 360;
|
|
2354
2443
|
return `${normalized.toFixed(0)}\xB0`;
|
|
2355
2444
|
};
|
|
2356
|
-
|
|
2357
|
-
const computedPositionClasses = React25__namespace.useMemo(() => {
|
|
2358
|
-
return mapsCore.computePositionClasses(position, hasControlsAtPosition);
|
|
2359
|
-
}, [position, hasControlsAtPosition]);
|
|
2360
|
-
React25__namespace.useEffect(() => {
|
|
2445
|
+
React26__namespace.useEffect(() => {
|
|
2361
2446
|
if (!map || !loaded) return;
|
|
2362
2447
|
setCurrentZoom(map.getZoom());
|
|
2363
2448
|
setCurrentBearing(map.getBearing());
|
|
@@ -2384,14 +2469,14 @@ var CoordinateDisplay = ({
|
|
|
2384
2469
|
{
|
|
2385
2470
|
ref: controlRef,
|
|
2386
2471
|
className: cn(
|
|
2387
|
-
"absolute
|
|
2472
|
+
"absolute bg-card rounded px-2 py-1",
|
|
2388
2473
|
"text-xs font-mono text-muted-foreground",
|
|
2389
2474
|
"border border-black dark:border-gray-400 shadow-sm",
|
|
2390
2475
|
"flex items-center gap-3",
|
|
2391
|
-
|
|
2476
|
+
!visible && "invisible",
|
|
2392
2477
|
className
|
|
2393
2478
|
),
|
|
2394
|
-
style:
|
|
2479
|
+
style: adjustedStyle,
|
|
2395
2480
|
children: [
|
|
2396
2481
|
cursorLngLat ? /* @__PURE__ */ jsxRuntime.jsx("span", { title: "Cursor coordinates", children: formatCoord(cursorLngLat) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60", children: "Move cursor over map" }),
|
|
2397
2482
|
showZoom && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -2423,17 +2508,16 @@ var BasemapSwitcher = ({
|
|
|
2423
2508
|
position = "bottom-right",
|
|
2424
2509
|
class: className
|
|
2425
2510
|
}) => {
|
|
2426
|
-
const {
|
|
2427
|
-
const [isOpen, setIsOpen] =
|
|
2428
|
-
const [internalActiveId, setInternalActiveId] =
|
|
2511
|
+
const { setMapStyle } = useMap();
|
|
2512
|
+
const [isOpen, setIsOpen] = React26__namespace.useState(false);
|
|
2513
|
+
const [internalActiveId, setInternalActiveId] = React26__namespace.useState(
|
|
2429
2514
|
defaultBasemapId
|
|
2430
2515
|
);
|
|
2431
|
-
const
|
|
2432
|
-
const
|
|
2433
|
-
const
|
|
2434
|
-
const switcherIdRef = React25__namespace.useRef(`basemap-switcher-${++switcherIdCounter}`);
|
|
2516
|
+
const containerRef = React26__namespace.useRef(null);
|
|
2517
|
+
const panelRef = React26__namespace.useRef(null);
|
|
2518
|
+
const switcherIdRef = React26__namespace.useRef(`basemap-switcher-${++switcherIdCounter}`);
|
|
2435
2519
|
const sourceBasemaps = basemaps ?? mapsCore.FREE_BASEMAPS;
|
|
2436
|
-
const availableBasemaps =
|
|
2520
|
+
const availableBasemaps = React26__namespace.useMemo(() => {
|
|
2437
2521
|
const available = mapsCore.getAvailableBasemaps(sourceBasemaps, apiKeys);
|
|
2438
2522
|
if (extraBasemaps?.length) {
|
|
2439
2523
|
return [...available, ...mapsCore.getAvailableBasemaps(extraBasemaps, apiKeys)];
|
|
@@ -2441,66 +2525,59 @@ var BasemapSwitcher = ({
|
|
|
2441
2525
|
return available;
|
|
2442
2526
|
}, [sourceBasemaps, extraBasemaps, apiKeys]);
|
|
2443
2527
|
const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
const observer = new ResizeObserver(updatePosition);
|
|
2454
|
-
observer.observe(containerRef.current);
|
|
2455
|
-
return () => {
|
|
2456
|
-
observer.disconnect();
|
|
2457
|
-
unregisterControl?.(switcherIdRef.current, position);
|
|
2458
|
-
};
|
|
2459
|
-
}, [position, registerControl, unregisterControl]);
|
|
2460
|
-
React25__namespace.useEffect(() => {
|
|
2528
|
+
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2529
|
+
id: switcherIdRef.current,
|
|
2530
|
+
type: "basemap-switcher",
|
|
2531
|
+
position,
|
|
2532
|
+
priority: "normal",
|
|
2533
|
+
zLayer: "interactive",
|
|
2534
|
+
hasExpandedState: true
|
|
2535
|
+
});
|
|
2536
|
+
React26__namespace.useEffect(() => {
|
|
2461
2537
|
if (!isOpen) return;
|
|
2462
2538
|
const handleMouseDown = (e) => {
|
|
2463
2539
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
2464
2540
|
setIsOpen(false);
|
|
2541
|
+
setExpanded(false);
|
|
2465
2542
|
}
|
|
2466
2543
|
};
|
|
2467
2544
|
document.addEventListener("mousedown", handleMouseDown);
|
|
2468
2545
|
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
2469
|
-
}, [isOpen]);
|
|
2470
|
-
|
|
2546
|
+
}, [isOpen, setExpanded]);
|
|
2547
|
+
React26__namespace.useEffect(() => {
|
|
2471
2548
|
if (!isOpen) return;
|
|
2472
2549
|
const handleKeyDown = (e) => {
|
|
2473
2550
|
if (e.key === "Escape") {
|
|
2474
2551
|
setIsOpen(false);
|
|
2552
|
+
setExpanded(false);
|
|
2475
2553
|
}
|
|
2476
2554
|
};
|
|
2477
2555
|
document.addEventListener("keydown", handleKeyDown);
|
|
2478
2556
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
2479
|
-
}, [isOpen]);
|
|
2557
|
+
}, [isOpen, setExpanded]);
|
|
2480
2558
|
const handleSelect = (basemap) => {
|
|
2481
|
-
const
|
|
2482
|
-
if (!
|
|
2559
|
+
const resolvedStyle = mapsCore.resolveBasemapStyle(basemap, apiKeys);
|
|
2560
|
+
if (!resolvedStyle) return;
|
|
2483
2561
|
if (!activeBasemapId) {
|
|
2484
2562
|
setInternalActiveId(basemap.id);
|
|
2485
2563
|
}
|
|
2486
|
-
setMapStyle?.(
|
|
2564
|
+
setMapStyle?.(resolvedStyle);
|
|
2487
2565
|
onBasemapChange?.(basemap);
|
|
2488
2566
|
setIsOpen(false);
|
|
2567
|
+
setExpanded(false);
|
|
2568
|
+
};
|
|
2569
|
+
const handleToggle = () => {
|
|
2570
|
+
const newState = !isOpen;
|
|
2571
|
+
setIsOpen(newState);
|
|
2572
|
+
setExpanded(newState);
|
|
2489
2573
|
};
|
|
2490
|
-
const verticalOffsetStyle = React25__namespace.useMemo(() => {
|
|
2491
|
-
return mapsCore.computeVerticalOffsetStyle(position, customControlOffset);
|
|
2492
|
-
}, [customControlOffset, position]);
|
|
2493
|
-
const hasControlsAtPosition = (controlOffsets?.[position] ?? 0) > 0;
|
|
2494
|
-
const computedPositionClasses = React25__namespace.useMemo(() => {
|
|
2495
|
-
return mapsCore.computePositionClasses(position, hasControlsAtPosition);
|
|
2496
|
-
}, [position, hasControlsAtPosition]);
|
|
2497
2574
|
const isTop = position.startsWith("top");
|
|
2498
2575
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2499
2576
|
"div",
|
|
2500
2577
|
{
|
|
2501
2578
|
ref: containerRef,
|
|
2502
|
-
className: cn("absolute
|
|
2503
|
-
style
|
|
2579
|
+
className: cn("absolute", !visible && "invisible", className),
|
|
2580
|
+
style,
|
|
2504
2581
|
children: [
|
|
2505
2582
|
isOpen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2506
2583
|
"div",
|
|
@@ -2575,7 +2652,7 @@ var BasemapSwitcher = ({
|
|
|
2575
2652
|
"hover:bg-muted transition-colors cursor-pointer",
|
|
2576
2653
|
"text-foreground"
|
|
2577
2654
|
),
|
|
2578
|
-
onClick:
|
|
2655
|
+
onClick: handleToggle,
|
|
2579
2656
|
"aria-label": "Switch basemap",
|
|
2580
2657
|
"aria-expanded": isOpen,
|
|
2581
2658
|
"aria-haspopup": "true",
|
|
@@ -2618,22 +2695,28 @@ var LayerManager = ({
|
|
|
2618
2695
|
onLayerChange,
|
|
2619
2696
|
class: className
|
|
2620
2697
|
}) => {
|
|
2621
|
-
const { controlOffsets, registerControl, unregisterControl } = useMap();
|
|
2622
2698
|
const { isDark } = useMapTheme();
|
|
2623
|
-
const [isOpen, setIsOpen] =
|
|
2624
|
-
const [layerStates, setLayerStates] =
|
|
2699
|
+
const [isOpen, setIsOpen] = React26__namespace.useState(false);
|
|
2700
|
+
const [layerStates, setLayerStates] = React26__namespace.useState(
|
|
2625
2701
|
() => mapsCore.createInitialLayerStates(layers, initialActiveLayers)
|
|
2626
2702
|
);
|
|
2627
|
-
const [searchQuery, setSearchQuery] =
|
|
2628
|
-
const [activeCategory, setActiveCategory] =
|
|
2629
|
-
const [
|
|
2630
|
-
const [
|
|
2631
|
-
const [
|
|
2632
|
-
const
|
|
2633
|
-
const
|
|
2634
|
-
const
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2703
|
+
const [searchQuery, setSearchQuery] = React26__namespace.useState("");
|
|
2704
|
+
const [activeCategory, setActiveCategory] = React26__namespace.useState("all");
|
|
2705
|
+
const [expandedOpacity, setExpandedOpacity] = React26__namespace.useState(null);
|
|
2706
|
+
const [draggedId, setDraggedId] = React26__namespace.useState(null);
|
|
2707
|
+
const [dragOver, setDragOver] = React26__namespace.useState(null);
|
|
2708
|
+
const containerRef = React26__namespace.useRef(null);
|
|
2709
|
+
const managerIdRef = React26__namespace.useRef(`layer-manager-${++managerIdCounter}`);
|
|
2710
|
+
const lastLayerIdsRef = React26__namespace.useRef(new Set(layers.map((l) => l.id)));
|
|
2711
|
+
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2712
|
+
id: managerIdRef.current,
|
|
2713
|
+
type: "layer-manager",
|
|
2714
|
+
position,
|
|
2715
|
+
priority: "high",
|
|
2716
|
+
zLayer: "interactive",
|
|
2717
|
+
hasExpandedState: true
|
|
2718
|
+
});
|
|
2719
|
+
React26__namespace.useEffect(() => {
|
|
2637
2720
|
const currentLayerIds = new Set(layers.map((l) => l.id));
|
|
2638
2721
|
const hasNewLayers = layers.some((l) => !lastLayerIdsRef.current.has(l.id));
|
|
2639
2722
|
const hasRemovedLayers = Array.from(lastLayerIdsRef.current).some(
|
|
@@ -2664,8 +2747,8 @@ var LayerManager = ({
|
|
|
2664
2747
|
lastLayerIdsRef.current = currentLayerIds;
|
|
2665
2748
|
}
|
|
2666
2749
|
}, [layers, initialActiveLayers]);
|
|
2667
|
-
const categories =
|
|
2668
|
-
const filteredLayers =
|
|
2750
|
+
const categories = React26__namespace.useMemo(() => mapsCore.getLayerCategories(layers), [layers]);
|
|
2751
|
+
const filteredLayers = React26__namespace.useMemo(() => {
|
|
2669
2752
|
let result = layers;
|
|
2670
2753
|
if (searchQuery) {
|
|
2671
2754
|
result = mapsCore.searchLayers(result, searchQuery);
|
|
@@ -2679,47 +2762,33 @@ var LayerManager = ({
|
|
|
2679
2762
|
return orderA - orderB;
|
|
2680
2763
|
});
|
|
2681
2764
|
}, [layers, searchQuery, activeCategory, layerStates]);
|
|
2682
|
-
const layerGroups =
|
|
2765
|
+
const layerGroups = React26__namespace.useMemo(
|
|
2683
2766
|
() => showCategories ? mapsCore.groupLayersByCategory(filteredLayers) : null,
|
|
2684
2767
|
[filteredLayers, showCategories]
|
|
2685
2768
|
);
|
|
2686
|
-
|
|
2687
|
-
if (!containerRef.current || !registerControl) return;
|
|
2688
|
-
const updatePosition = () => {
|
|
2689
|
-
if (!containerRef.current) return;
|
|
2690
|
-
const height = containerRef.current.offsetHeight;
|
|
2691
|
-
const offset = registerControl(managerIdRef.current, position, height);
|
|
2692
|
-
setCustomControlOffset(offset);
|
|
2693
|
-
};
|
|
2694
|
-
updatePosition();
|
|
2695
|
-
const observer = new ResizeObserver(updatePosition);
|
|
2696
|
-
observer.observe(containerRef.current);
|
|
2697
|
-
return () => {
|
|
2698
|
-
observer.disconnect();
|
|
2699
|
-
unregisterControl?.(managerIdRef.current, position);
|
|
2700
|
-
};
|
|
2701
|
-
}, [position, registerControl, unregisterControl]);
|
|
2702
|
-
React25__namespace.useEffect(() => {
|
|
2769
|
+
React26__namespace.useEffect(() => {
|
|
2703
2770
|
if (!isOpen) return;
|
|
2704
2771
|
const handleMouseDown = (e) => {
|
|
2705
2772
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
2706
2773
|
setIsOpen(false);
|
|
2774
|
+
setExpanded(false);
|
|
2707
2775
|
}
|
|
2708
2776
|
};
|
|
2709
2777
|
document.addEventListener("mousedown", handleMouseDown);
|
|
2710
2778
|
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
2711
|
-
}, [isOpen]);
|
|
2712
|
-
|
|
2779
|
+
}, [isOpen, setExpanded]);
|
|
2780
|
+
React26__namespace.useEffect(() => {
|
|
2713
2781
|
if (!isOpen) return;
|
|
2714
2782
|
const handleKeyDown = (e) => {
|
|
2715
2783
|
if (e.key === "Escape") {
|
|
2716
2784
|
setIsOpen(false);
|
|
2785
|
+
setExpanded(false);
|
|
2717
2786
|
}
|
|
2718
2787
|
};
|
|
2719
2788
|
document.addEventListener("keydown", handleKeyDown);
|
|
2720
2789
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
2721
|
-
}, [isOpen]);
|
|
2722
|
-
const handleToggleLayer =
|
|
2790
|
+
}, [isOpen, setExpanded]);
|
|
2791
|
+
const handleToggleLayer = React26__namespace.useCallback(
|
|
2723
2792
|
(layerId) => {
|
|
2724
2793
|
setLayerStates((prev) => {
|
|
2725
2794
|
const newStates = mapsCore.toggleLayerVisibility(prev, layerId);
|
|
@@ -2732,7 +2801,7 @@ var LayerManager = ({
|
|
|
2732
2801
|
},
|
|
2733
2802
|
[onLayerChange]
|
|
2734
2803
|
);
|
|
2735
|
-
const handleOpacityChange =
|
|
2804
|
+
const handleOpacityChange = React26__namespace.useCallback(
|
|
2736
2805
|
(layerId, opacity) => {
|
|
2737
2806
|
setLayerStates((prev) => {
|
|
2738
2807
|
const newStates = mapsCore.setLayerOpacity(prev, layerId, opacity);
|
|
@@ -2745,12 +2814,12 @@ var LayerManager = ({
|
|
|
2745
2814
|
},
|
|
2746
2815
|
[onLayerChange]
|
|
2747
2816
|
);
|
|
2748
|
-
const handleDragStart =
|
|
2817
|
+
const handleDragStart = React26__namespace.useCallback((e, layerId) => {
|
|
2749
2818
|
setDraggedId(layerId);
|
|
2750
2819
|
e.dataTransfer.effectAllowed = "move";
|
|
2751
2820
|
e.dataTransfer.setData("text/plain", layerId);
|
|
2752
2821
|
}, []);
|
|
2753
|
-
const handleDragOver =
|
|
2822
|
+
const handleDragOver = React26__namespace.useCallback(
|
|
2754
2823
|
(e, layerId) => {
|
|
2755
2824
|
e.preventDefault();
|
|
2756
2825
|
e.dataTransfer.dropEffect = "move";
|
|
@@ -2770,14 +2839,14 @@ var LayerManager = ({
|
|
|
2770
2839
|
},
|
|
2771
2840
|
[draggedId, dragOver]
|
|
2772
2841
|
);
|
|
2773
|
-
const handleDragLeave =
|
|
2842
|
+
const handleDragLeave = React26__namespace.useCallback(() => {
|
|
2774
2843
|
setDragOver(null);
|
|
2775
2844
|
}, []);
|
|
2776
|
-
const handleDragEnd =
|
|
2845
|
+
const handleDragEnd = React26__namespace.useCallback(() => {
|
|
2777
2846
|
setDraggedId(null);
|
|
2778
2847
|
setDragOver(null);
|
|
2779
2848
|
}, []);
|
|
2780
|
-
const handleDrop =
|
|
2849
|
+
const handleDrop = React26__namespace.useCallback(
|
|
2781
2850
|
(e, targetLayerId) => {
|
|
2782
2851
|
e.preventDefault();
|
|
2783
2852
|
const sourceLayerId = e.dataTransfer.getData("text/plain");
|
|
@@ -2807,13 +2876,6 @@ var LayerManager = ({
|
|
|
2807
2876
|
},
|
|
2808
2877
|
[layerStates, onLayerChange, dragOver]
|
|
2809
2878
|
);
|
|
2810
|
-
const verticalOffsetStyle = React25__namespace.useMemo(() => {
|
|
2811
|
-
return mapsCore.computeVerticalOffsetStyle(position, customControlOffset);
|
|
2812
|
-
}, [customControlOffset, position]);
|
|
2813
|
-
const hasControlsAtPosition = (controlOffsets?.[position] ?? 0) > 0;
|
|
2814
|
-
const computedPositionClasses = React25__namespace.useMemo(() => {
|
|
2815
|
-
return mapsCore.computePositionClasses(position, hasControlsAtPosition);
|
|
2816
|
-
}, [position, hasControlsAtPosition]);
|
|
2817
2879
|
const isTop = position.startsWith("top");
|
|
2818
2880
|
const renderLayer = (layer, state) => {
|
|
2819
2881
|
if (!state.visible) return null;
|
|
@@ -3024,6 +3086,11 @@ var LayerManager = ({
|
|
|
3024
3086
|
] }) });
|
|
3025
3087
|
};
|
|
3026
3088
|
const visibleLayerStates = mapsCore.getLayerStatesArray(layerStates).filter((s) => s.visible);
|
|
3089
|
+
const handleToggle = () => {
|
|
3090
|
+
const newState = !isOpen;
|
|
3091
|
+
setIsOpen(newState);
|
|
3092
|
+
setExpanded(newState);
|
|
3093
|
+
};
|
|
3027
3094
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3028
3095
|
visibleLayerStates.map((state) => {
|
|
3029
3096
|
const layer = layers.find((l) => l.id === state.id);
|
|
@@ -3033,8 +3100,8 @@ var LayerManager = ({
|
|
|
3033
3100
|
"div",
|
|
3034
3101
|
{
|
|
3035
3102
|
ref: containerRef,
|
|
3036
|
-
className: cn("absolute
|
|
3037
|
-
style
|
|
3103
|
+
className: cn("absolute", !visible && "invisible", className),
|
|
3104
|
+
style,
|
|
3038
3105
|
children: [
|
|
3039
3106
|
isOpen && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3040
3107
|
"div",
|
|
@@ -3112,7 +3179,7 @@ var LayerManager = ({
|
|
|
3112
3179
|
if (catLayers.length === 0) return null;
|
|
3113
3180
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3114
3181
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-2 text-xs font-medium text-muted-foreground uppercase tracking-wider", children: mapsCore.CATEGORY_META[cat].label }),
|
|
3115
|
-
catLayers.map((layer) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3182
|
+
catLayers.map((layer) => /* @__PURE__ */ jsxRuntime.jsxs(React26__namespace.Fragment, { children: [
|
|
3116
3183
|
renderLayerItem(layer),
|
|
3117
3184
|
renderOpacitySlider(layer.id)
|
|
3118
3185
|
] }, layer.id))
|
|
@@ -3120,7 +3187,7 @@ var LayerManager = ({
|
|
|
3120
3187
|
})
|
|
3121
3188
|
) : (
|
|
3122
3189
|
// Flat list
|
|
3123
|
-
filteredLayers.map((layer) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3190
|
+
filteredLayers.map((layer) => /* @__PURE__ */ jsxRuntime.jsxs(React26__namespace.Fragment, { children: [
|
|
3124
3191
|
renderLayerItem(layer),
|
|
3125
3192
|
renderOpacitySlider(layer.id)
|
|
3126
3193
|
] }, layer.id))
|
|
@@ -3140,7 +3207,7 @@ var LayerManager = ({
|
|
|
3140
3207
|
"hover:bg-muted transition-colors cursor-pointer",
|
|
3141
3208
|
"text-foreground"
|
|
3142
3209
|
),
|
|
3143
|
-
onClick:
|
|
3210
|
+
onClick: handleToggle,
|
|
3144
3211
|
"aria-label": "Toggle layer manager",
|
|
3145
3212
|
"aria-expanded": isOpen,
|
|
3146
3213
|
"aria-haspopup": "true",
|
|
@@ -3170,6 +3237,42 @@ var LayerManager = ({
|
|
|
3170
3237
|
] });
|
|
3171
3238
|
};
|
|
3172
3239
|
LayerManager.displayName = "LayerManager";
|
|
3240
|
+
var customControlIdCounter = 0;
|
|
3241
|
+
var CustomControl = ({
|
|
3242
|
+
position = "top-right",
|
|
3243
|
+
fallbacks,
|
|
3244
|
+
priority = "normal",
|
|
3245
|
+
zLayer = "interactive",
|
|
3246
|
+
id,
|
|
3247
|
+
hasExpandedState = false,
|
|
3248
|
+
className,
|
|
3249
|
+
style: userStyle,
|
|
3250
|
+
children
|
|
3251
|
+
}) => {
|
|
3252
|
+
const controlRef = React26__namespace.useRef(null);
|
|
3253
|
+
const controlIdRef = React26__namespace.useRef(id ?? `custom-control-${++customControlIdCounter}`);
|
|
3254
|
+
const { style, visible, setExpanded } = useControlPosition(controlRef, {
|
|
3255
|
+
id: controlIdRef.current,
|
|
3256
|
+
type: "custom",
|
|
3257
|
+
position,
|
|
3258
|
+
fallbacks,
|
|
3259
|
+
priority,
|
|
3260
|
+
zLayer,
|
|
3261
|
+
hasExpandedState
|
|
3262
|
+
});
|
|
3263
|
+
const mergedStyle = React26__namespace.useMemo(() => ({ ...style, ...userStyle }), [style, userStyle]);
|
|
3264
|
+
const contextValue = React26__namespace.useMemo(() => ({ setExpanded }), [setExpanded]);
|
|
3265
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CustomControlContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: controlRef, className: cn(!visible && "invisible", className), style: mergedStyle, children }) });
|
|
3266
|
+
};
|
|
3267
|
+
CustomControl.displayName = "CustomControl";
|
|
3268
|
+
var CustomControlContext = React26__namespace.createContext(null);
|
|
3269
|
+
function useCustomControl() {
|
|
3270
|
+
const context = React26__namespace.useContext(CustomControlContext);
|
|
3271
|
+
if (!context) {
|
|
3272
|
+
throw new Error("useCustomControl must be used within a CustomControl");
|
|
3273
|
+
}
|
|
3274
|
+
return context;
|
|
3275
|
+
}
|
|
3173
3276
|
var DeckOverlay = ({
|
|
3174
3277
|
layers = [],
|
|
3175
3278
|
onHover,
|
|
@@ -3180,9 +3283,9 @@ var DeckOverlay = ({
|
|
|
3180
3283
|
deckProps = {}
|
|
3181
3284
|
}) => {
|
|
3182
3285
|
const { map, loaded } = useMap();
|
|
3183
|
-
const overlayRef =
|
|
3184
|
-
const MapboxOverlayRef =
|
|
3185
|
-
|
|
3286
|
+
const overlayRef = React26__namespace.useRef(null);
|
|
3287
|
+
const MapboxOverlayRef = React26__namespace.useRef(null);
|
|
3288
|
+
React26__namespace.useEffect(() => {
|
|
3186
3289
|
if (!map || !loaded) return;
|
|
3187
3290
|
let cancelled = false;
|
|
3188
3291
|
const initOverlay = async () => {
|
|
@@ -3222,12 +3325,12 @@ var DeckOverlay = ({
|
|
|
3222
3325
|
}
|
|
3223
3326
|
};
|
|
3224
3327
|
}, [map, loaded, interleaved]);
|
|
3225
|
-
|
|
3328
|
+
React26__namespace.useEffect(() => {
|
|
3226
3329
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3227
3330
|
overlayRef.current.setProps({ layers });
|
|
3228
3331
|
}
|
|
3229
3332
|
}, [layers]);
|
|
3230
|
-
|
|
3333
|
+
React26__namespace.useEffect(() => {
|
|
3231
3334
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3232
3335
|
overlayRef.current.setProps({
|
|
3233
3336
|
onHover,
|
|
@@ -3235,7 +3338,7 @@ var DeckOverlay = ({
|
|
|
3235
3338
|
});
|
|
3236
3339
|
}
|
|
3237
3340
|
}, [onHover, onClick]);
|
|
3238
|
-
|
|
3341
|
+
React26__namespace.useEffect(() => {
|
|
3239
3342
|
if (overlayRef.current && effects && "setProps" in overlayRef.current) {
|
|
3240
3343
|
overlayRef.current.setProps({ effects });
|
|
3241
3344
|
}
|
|
@@ -3264,6 +3367,10 @@ Object.defineProperty(exports, "CITY_LIMITS", {
|
|
|
3264
3367
|
enumerable: true,
|
|
3265
3368
|
get: function () { return mapsCore.CITY_LIMITS; }
|
|
3266
3369
|
});
|
|
3370
|
+
Object.defineProperty(exports, "DEFAULT_BASEMAP", {
|
|
3371
|
+
enumerable: true,
|
|
3372
|
+
get: function () { return mapsCore.DEFAULT_BASEMAP; }
|
|
3373
|
+
});
|
|
3267
3374
|
Object.defineProperty(exports, "FLOOD_ZONES", {
|
|
3268
3375
|
enumerable: true,
|
|
3269
3376
|
get: function () { return mapsCore.FLOOD_ZONES; }
|
|
@@ -3280,6 +3387,14 @@ Object.defineProperty(exports, "PARKS", {
|
|
|
3280
3387
|
enumerable: true,
|
|
3281
3388
|
get: function () { return mapsCore.PARKS; }
|
|
3282
3389
|
});
|
|
3390
|
+
Object.defineProperty(exports, "PRIMARY_BASEMAPS", {
|
|
3391
|
+
enumerable: true,
|
|
3392
|
+
get: function () { return mapsCore.PRIMARY_BASEMAPS; }
|
|
3393
|
+
});
|
|
3394
|
+
Object.defineProperty(exports, "SATELLITE_BASEMAP", {
|
|
3395
|
+
enumerable: true,
|
|
3396
|
+
get: function () { return mapsCore.SATELLITE_BASEMAP; }
|
|
3397
|
+
});
|
|
3283
3398
|
Object.defineProperty(exports, "SCHOOL_DISTRICTS", {
|
|
3284
3399
|
enumerable: true,
|
|
3285
3400
|
get: function () { return mapsCore.SCHOOL_DISTRICTS; }
|
|
@@ -3296,6 +3411,10 @@ Object.defineProperty(exports, "THEME_LIGHT", {
|
|
|
3296
3411
|
enumerable: true,
|
|
3297
3412
|
get: function () { return mapsCore.THEME_LIGHT; }
|
|
3298
3413
|
});
|
|
3414
|
+
Object.defineProperty(exports, "TOPO_BASEMAP", {
|
|
3415
|
+
enumerable: true,
|
|
3416
|
+
get: function () { return mapsCore.TOPO_BASEMAP; }
|
|
3417
|
+
});
|
|
3299
3418
|
Object.defineProperty(exports, "TRAILS", {
|
|
3300
3419
|
enumerable: true,
|
|
3301
3420
|
get: function () { return mapsCore.TRAILS; }
|
|
@@ -3471,6 +3590,7 @@ Object.defineProperty(exports, "validateGeoJSON", {
|
|
|
3471
3590
|
exports.BasemapSwitcher = BasemapSwitcher;
|
|
3472
3591
|
exports.CircleLayer = CircleLayer;
|
|
3473
3592
|
exports.CoordinateDisplay = CoordinateDisplay;
|
|
3593
|
+
exports.CustomControl = CustomControl;
|
|
3474
3594
|
exports.DeckOverlay = DeckOverlay;
|
|
3475
3595
|
exports.FillExtrusionLayer = FillExtrusionLayer;
|
|
3476
3596
|
exports.FillLayer = FillLayer;
|
|
@@ -3494,6 +3614,8 @@ exports.PopupHeader = PopupHeader;
|
|
|
3494
3614
|
exports.Source = Source;
|
|
3495
3615
|
exports.SymbolLayer = SymbolLayer;
|
|
3496
3616
|
exports.cn = cn;
|
|
3617
|
+
exports.useControlPosition = useControlPosition;
|
|
3618
|
+
exports.useCustomControl = useCustomControl;
|
|
3497
3619
|
exports.useLayer = useLayer;
|
|
3498
3620
|
exports.useMap = useMap;
|
|
3499
3621
|
exports.useMapInstance = useMapInstance;
|