@classic-homes/maps-react 0.2.6 → 0.2.8
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 +202 -75
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +191 -76
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -383,7 +383,13 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
383
383
|
const positioningCoordinator = positioningCoordinatorRef.current;
|
|
384
384
|
const setMapStyle = React26__namespace.useCallback((style) => {
|
|
385
385
|
activeStyleOverrideRef.current = style;
|
|
386
|
-
mapRef.current
|
|
386
|
+
const map = mapRef.current;
|
|
387
|
+
if (map) {
|
|
388
|
+
map.setStyle(style);
|
|
389
|
+
map.once("idle", () => {
|
|
390
|
+
setStyleVersion((v) => v + 1);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
387
393
|
}, []);
|
|
388
394
|
const prefersReducedMotion2 = useReducedMotion();
|
|
389
395
|
const { style: themeStyle } = useMapTheme(themePref);
|
|
@@ -440,9 +446,6 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
440
446
|
attributionControl: attributionControl ? { customAttribution } : false
|
|
441
447
|
});
|
|
442
448
|
mapRef.current = map;
|
|
443
|
-
map.on("style.load", () => {
|
|
444
|
-
setStyleVersion((v) => v + 1);
|
|
445
|
-
});
|
|
446
449
|
if (navigationControl) {
|
|
447
450
|
map.addControl(
|
|
448
451
|
new maplibregl__default.default.NavigationControl({
|
|
@@ -512,7 +515,19 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
512
515
|
zLayer: "base"
|
|
513
516
|
});
|
|
514
517
|
}
|
|
518
|
+
const initTimeoutId = setTimeout(() => {
|
|
519
|
+
if (!mapRef.current?.loaded()) {
|
|
520
|
+
const errorMessage = "Map initialization timeout - style may be unreachable";
|
|
521
|
+
setMapError(errorMessage);
|
|
522
|
+
onErrorRef.current?.({
|
|
523
|
+
type: "error",
|
|
524
|
+
message: errorMessage,
|
|
525
|
+
error: new Error(errorMessage)
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}, 3e4);
|
|
515
529
|
map.on("load", () => {
|
|
530
|
+
clearTimeout(initTimeoutId);
|
|
516
531
|
setMapLoaded(true);
|
|
517
532
|
if (bounds) {
|
|
518
533
|
map.fitBounds(bounds, {
|
|
@@ -526,11 +541,13 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
526
541
|
const errorMessage = e.error?.message || "Map error";
|
|
527
542
|
const isTransient = errorMessage.includes("non-existing layer") || errorMessage.includes("Cannot filter");
|
|
528
543
|
if (!isTransient) {
|
|
544
|
+
clearTimeout(initTimeoutId);
|
|
529
545
|
setMapError(errorMessage);
|
|
530
546
|
}
|
|
531
547
|
onErrorRef.current?.({ type: "error", message: errorMessage, error: e.error });
|
|
532
548
|
});
|
|
533
549
|
return () => {
|
|
550
|
+
clearTimeout(initTimeoutId);
|
|
534
551
|
map.remove();
|
|
535
552
|
mapRef.current = null;
|
|
536
553
|
setMapLoaded(false);
|
|
@@ -541,6 +558,17 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
541
558
|
onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
|
|
542
559
|
}
|
|
543
560
|
}, []);
|
|
561
|
+
React26__namespace.useEffect(() => {
|
|
562
|
+
const map = mapRef.current;
|
|
563
|
+
if (!map || !mapLoaded) return;
|
|
564
|
+
const handleStyleLoad = () => {
|
|
565
|
+
setStyleVersion((v) => v + 1);
|
|
566
|
+
};
|
|
567
|
+
map.on("style.load", handleStyleLoad);
|
|
568
|
+
return () => {
|
|
569
|
+
map.off("style.load", handleStyleLoad);
|
|
570
|
+
};
|
|
571
|
+
}, [mapLoaded]);
|
|
544
572
|
const styleInitialized = React26__namespace.useRef(false);
|
|
545
573
|
React26__namespace.useEffect(() => {
|
|
546
574
|
if (!mapRef.current || !mapLoaded) return;
|
|
@@ -625,23 +653,23 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
625
653
|
const handleZoom = () => {
|
|
626
654
|
onZoom?.({ type: "zoom", ...createMoveParams() });
|
|
627
655
|
};
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
656
|
+
map.on("click", handleClick);
|
|
657
|
+
map.on("dblclick", handleDblClick);
|
|
658
|
+
map.on("contextmenu", handleContextMenu);
|
|
659
|
+
map.on("mousemove", handleMouseMove);
|
|
660
|
+
map.on("move", handleMove);
|
|
661
|
+
map.on("movestart", handleMoveStart);
|
|
662
|
+
map.on("moveend", handleMoveEnd);
|
|
663
|
+
map.on("zoom", handleZoom);
|
|
636
664
|
return () => {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
665
|
+
map.off("click", handleClick);
|
|
666
|
+
map.off("dblclick", handleDblClick);
|
|
667
|
+
map.off("contextmenu", handleContextMenu);
|
|
668
|
+
map.off("mousemove", handleMouseMove);
|
|
669
|
+
map.off("move", handleMove);
|
|
670
|
+
map.off("movestart", handleMoveStart);
|
|
671
|
+
map.off("moveend", handleMoveEnd);
|
|
672
|
+
map.off("zoom", handleZoom);
|
|
645
673
|
};
|
|
646
674
|
}, [
|
|
647
675
|
mapLoaded,
|
|
@@ -655,6 +683,16 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
655
683
|
onZoom
|
|
656
684
|
]);
|
|
657
685
|
const combinedError = error || mapError;
|
|
686
|
+
const contextValue = React26__namespace.useMemo(
|
|
687
|
+
() => ({
|
|
688
|
+
map: mapRef.current,
|
|
689
|
+
loaded: mapLoaded,
|
|
690
|
+
styleVersion,
|
|
691
|
+
setMapStyle,
|
|
692
|
+
positioningCoordinator
|
|
693
|
+
}),
|
|
694
|
+
[mapLoaded, styleVersion, setMapStyle, positioningCoordinator]
|
|
695
|
+
);
|
|
658
696
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
659
697
|
MapContainer,
|
|
660
698
|
{
|
|
@@ -667,22 +705,10 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
667
705
|
error: combinedError,
|
|
668
706
|
emptyMessage,
|
|
669
707
|
className,
|
|
670
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
671
|
-
|
|
672
|
-
{
|
|
673
|
-
|
|
674
|
-
map: mapRef.current,
|
|
675
|
-
loaded: mapLoaded,
|
|
676
|
-
styleVersion,
|
|
677
|
-
setMapStyle,
|
|
678
|
-
positioningCoordinator
|
|
679
|
-
},
|
|
680
|
-
children: [
|
|
681
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "absolute inset-0" }),
|
|
682
|
-
mapLoaded && children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
|
|
683
|
-
]
|
|
684
|
-
}
|
|
685
|
-
)
|
|
708
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(MapContext.Provider, { value: contextValue, children: [
|
|
709
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "absolute inset-0" }),
|
|
710
|
+
mapLoaded && children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
|
|
711
|
+
] })
|
|
686
712
|
}
|
|
687
713
|
);
|
|
688
714
|
}
|
|
@@ -973,6 +999,9 @@ var Marker = React26__namespace.forwardRef(
|
|
|
973
999
|
const elementRef = React26__namespace.useRef(null);
|
|
974
1000
|
const originalLngLatRef = React26__namespace.useRef();
|
|
975
1001
|
const clickHandlerRef = React26__namespace.useRef(null);
|
|
1002
|
+
const dragStartHandlerRef = React26__namespace.useRef(null);
|
|
1003
|
+
const dragHandlerRef = React26__namespace.useRef(null);
|
|
1004
|
+
const dragEndHandlerRef = React26__namespace.useRef(null);
|
|
976
1005
|
const [mounted, setMounted] = React26__namespace.useState(false);
|
|
977
1006
|
const onClickRef = React26__namespace.useRef(onClick);
|
|
978
1007
|
onClickRef.current = onClick;
|
|
@@ -1038,11 +1067,11 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1038
1067
|
element.addEventListener("click", handleClick);
|
|
1039
1068
|
}
|
|
1040
1069
|
if (draggable) {
|
|
1041
|
-
|
|
1070
|
+
const handleDragStart = () => {
|
|
1042
1071
|
const lngLat = marker.getLngLat();
|
|
1043
1072
|
originalLngLatRef.current = [lngLat.lng, lngLat.lat];
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1073
|
+
};
|
|
1074
|
+
const handleDrag = () => {
|
|
1046
1075
|
const lngLat = marker.getLngLat();
|
|
1047
1076
|
onDragRef.current?.({
|
|
1048
1077
|
type: "drag",
|
|
@@ -1050,8 +1079,8 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1050
1079
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
1051
1080
|
originalLngLat: originalLngLatRef.current
|
|
1052
1081
|
});
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1082
|
+
};
|
|
1083
|
+
const handleDragEnd = () => {
|
|
1055
1084
|
const lngLat = marker.getLngLat();
|
|
1056
1085
|
onDragEndRef.current?.({
|
|
1057
1086
|
type: "dragend",
|
|
@@ -1059,13 +1088,33 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1059
1088
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
1060
1089
|
originalLngLat: originalLngLatRef.current
|
|
1061
1090
|
});
|
|
1062
|
-
}
|
|
1091
|
+
};
|
|
1092
|
+
dragStartHandlerRef.current = handleDragStart;
|
|
1093
|
+
dragHandlerRef.current = handleDrag;
|
|
1094
|
+
dragEndHandlerRef.current = handleDragEnd;
|
|
1095
|
+
marker.on("dragstart", handleDragStart);
|
|
1096
|
+
marker.on("drag", handleDrag);
|
|
1097
|
+
marker.on("dragend", handleDragEnd);
|
|
1063
1098
|
}
|
|
1064
1099
|
return () => {
|
|
1065
1100
|
if (clickHandlerRef.current && markerRef.current) {
|
|
1066
1101
|
markerRef.current.getElement().removeEventListener("click", clickHandlerRef.current);
|
|
1067
1102
|
clickHandlerRef.current = null;
|
|
1068
1103
|
}
|
|
1104
|
+
if (markerRef.current) {
|
|
1105
|
+
if (dragStartHandlerRef.current) {
|
|
1106
|
+
markerRef.current.off("dragstart", dragStartHandlerRef.current);
|
|
1107
|
+
dragStartHandlerRef.current = null;
|
|
1108
|
+
}
|
|
1109
|
+
if (dragHandlerRef.current) {
|
|
1110
|
+
markerRef.current.off("drag", dragHandlerRef.current);
|
|
1111
|
+
dragHandlerRef.current = null;
|
|
1112
|
+
}
|
|
1113
|
+
if (dragEndHandlerRef.current) {
|
|
1114
|
+
markerRef.current.off("dragend", dragEndHandlerRef.current);
|
|
1115
|
+
dragEndHandlerRef.current = null;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1069
1118
|
if (markerRef.current) {
|
|
1070
1119
|
mapsCore.removeMarkerProtection(markerRef.current.getElement());
|
|
1071
1120
|
markerRef.current.remove();
|
|
@@ -1079,10 +1128,53 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1079
1128
|
}
|
|
1080
1129
|
}, [coordinates]);
|
|
1081
1130
|
React26__namespace.useEffect(() => {
|
|
1082
|
-
|
|
1083
|
-
|
|
1131
|
+
const marker = markerRef.current;
|
|
1132
|
+
if (!marker) return;
|
|
1133
|
+
marker.setDraggable(draggable);
|
|
1134
|
+
if (!draggable) {
|
|
1135
|
+
if (dragStartHandlerRef.current) {
|
|
1136
|
+
marker.off("dragstart", dragStartHandlerRef.current);
|
|
1137
|
+
dragStartHandlerRef.current = null;
|
|
1138
|
+
}
|
|
1139
|
+
if (dragHandlerRef.current) {
|
|
1140
|
+
marker.off("drag", dragHandlerRef.current);
|
|
1141
|
+
dragHandlerRef.current = null;
|
|
1142
|
+
}
|
|
1143
|
+
if (dragEndHandlerRef.current) {
|
|
1144
|
+
marker.off("dragend", dragEndHandlerRef.current);
|
|
1145
|
+
dragEndHandlerRef.current = null;
|
|
1146
|
+
}
|
|
1147
|
+
} else if (!dragStartHandlerRef.current) {
|
|
1148
|
+
const handleDragStart = () => {
|
|
1149
|
+
const lngLat = marker.getLngLat();
|
|
1150
|
+
originalLngLatRef.current = [lngLat.lng, lngLat.lat];
|
|
1151
|
+
};
|
|
1152
|
+
const handleDrag = () => {
|
|
1153
|
+
const lngLat = marker.getLngLat();
|
|
1154
|
+
onDragRef.current?.({
|
|
1155
|
+
type: "drag",
|
|
1156
|
+
markerId: id || "",
|
|
1157
|
+
lngLat: [lngLat.lng, lngLat.lat],
|
|
1158
|
+
originalLngLat: originalLngLatRef.current
|
|
1159
|
+
});
|
|
1160
|
+
};
|
|
1161
|
+
const handleDragEnd = () => {
|
|
1162
|
+
const lngLat = marker.getLngLat();
|
|
1163
|
+
onDragEndRef.current?.({
|
|
1164
|
+
type: "dragend",
|
|
1165
|
+
markerId: id || "",
|
|
1166
|
+
lngLat: [lngLat.lng, lngLat.lat],
|
|
1167
|
+
originalLngLat: originalLngLatRef.current
|
|
1168
|
+
});
|
|
1169
|
+
};
|
|
1170
|
+
dragStartHandlerRef.current = handleDragStart;
|
|
1171
|
+
dragHandlerRef.current = handleDrag;
|
|
1172
|
+
dragEndHandlerRef.current = handleDragEnd;
|
|
1173
|
+
marker.on("dragstart", handleDragStart);
|
|
1174
|
+
marker.on("drag", handleDrag);
|
|
1175
|
+
marker.on("dragend", handleDragEnd);
|
|
1084
1176
|
}
|
|
1085
|
-
}, [draggable]);
|
|
1177
|
+
}, [draggable, id]);
|
|
1086
1178
|
React26__namespace.useEffect(() => {
|
|
1087
1179
|
if (markerRef.current && rotation !== void 0) {
|
|
1088
1180
|
markerRef.current.setRotation(rotation);
|
|
@@ -1442,7 +1534,11 @@ function useLayer({
|
|
|
1442
1534
|
const handleClick = (e) => {
|
|
1443
1535
|
const params = createFeatureParams(e);
|
|
1444
1536
|
if (params) {
|
|
1445
|
-
|
|
1537
|
+
try {
|
|
1538
|
+
onClick?.({ type: "click", ...params });
|
|
1539
|
+
} catch (err) {
|
|
1540
|
+
console.error(`[maps-react] Layer "${id}" click handler error:`, err);
|
|
1541
|
+
}
|
|
1446
1542
|
}
|
|
1447
1543
|
};
|
|
1448
1544
|
const handleMouseEnter = (e) => {
|
|
@@ -1464,7 +1560,11 @@ function useLayer({
|
|
|
1464
1560
|
}
|
|
1465
1561
|
const params = createFeatureParams(e);
|
|
1466
1562
|
if (params) {
|
|
1467
|
-
|
|
1563
|
+
try {
|
|
1564
|
+
onHover?.({ type: "mouseenter", ...params });
|
|
1565
|
+
} catch (err) {
|
|
1566
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1567
|
+
}
|
|
1468
1568
|
}
|
|
1469
1569
|
};
|
|
1470
1570
|
const handleMouseMove = (e) => {
|
|
@@ -1489,7 +1589,11 @@ function useLayer({
|
|
|
1489
1589
|
lastHoverCallTime.current = now;
|
|
1490
1590
|
const params = createFeatureParams(e);
|
|
1491
1591
|
if (params) {
|
|
1492
|
-
|
|
1592
|
+
try {
|
|
1593
|
+
onHover?.({ type: "mousemove", ...params });
|
|
1594
|
+
} catch (err) {
|
|
1595
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1596
|
+
}
|
|
1493
1597
|
}
|
|
1494
1598
|
}
|
|
1495
1599
|
} else {
|
|
@@ -1507,15 +1611,19 @@ function useLayer({
|
|
|
1507
1611
|
hoveredFeatureId.current = null;
|
|
1508
1612
|
}
|
|
1509
1613
|
const lastPos = lastMousePosition.current;
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1614
|
+
try {
|
|
1615
|
+
onHover?.({
|
|
1616
|
+
type: "mouseleave",
|
|
1617
|
+
feature: null,
|
|
1618
|
+
layerId: id,
|
|
1619
|
+
sourceId: source,
|
|
1620
|
+
lngLat: lastPos?.lngLat ?? [0, 0],
|
|
1621
|
+
point: lastPos?.point ?? [0, 0],
|
|
1622
|
+
map
|
|
1623
|
+
});
|
|
1624
|
+
} catch (err) {
|
|
1625
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1626
|
+
}
|
|
1519
1627
|
lastMousePosition.current = null;
|
|
1520
1628
|
};
|
|
1521
1629
|
if (onClick) {
|
|
@@ -2107,7 +2215,6 @@ function useControlPosition(ref, options) {
|
|
|
2107
2215
|
visible: offset?.visible ?? false
|
|
2108
2216
|
};
|
|
2109
2217
|
}
|
|
2110
|
-
var legendIdCounter = 0;
|
|
2111
2218
|
var Legend = ({
|
|
2112
2219
|
title,
|
|
2113
2220
|
position = "bottom-left",
|
|
@@ -2123,9 +2230,10 @@ var Legend = ({
|
|
|
2123
2230
|
}) => {
|
|
2124
2231
|
const [isCollapsed, setIsCollapsed] = React26__namespace.useState(initialCollapsed);
|
|
2125
2232
|
const legendRef = React26__namespace.useRef(null);
|
|
2126
|
-
const
|
|
2233
|
+
const generatedId = React26__namespace.useId();
|
|
2234
|
+
const legendId = `legend-${generatedId}`;
|
|
2127
2235
|
const { style, visible } = useControlPosition(legendRef, {
|
|
2128
|
-
id:
|
|
2236
|
+
id: legendId,
|
|
2129
2237
|
type: "legend",
|
|
2130
2238
|
position,
|
|
2131
2239
|
priority: "normal",
|
|
@@ -2386,7 +2494,6 @@ var LegendGroup = ({
|
|
|
2386
2494
|
);
|
|
2387
2495
|
};
|
|
2388
2496
|
LegendGroup.displayName = "LegendGroup";
|
|
2389
|
-
var coordDisplayIdCounter = 0;
|
|
2390
2497
|
var NAV_CONTROL_WIDTH = 29;
|
|
2391
2498
|
var CoordinateDisplay = ({
|
|
2392
2499
|
position = "bottom-right",
|
|
@@ -2401,9 +2508,10 @@ var CoordinateDisplay = ({
|
|
|
2401
2508
|
const [currentZoom, setCurrentZoom] = React26__namespace.useState(0);
|
|
2402
2509
|
const [currentBearing, setCurrentBearing] = React26__namespace.useState(0);
|
|
2403
2510
|
const controlRef = React26__namespace.useRef(null);
|
|
2404
|
-
const
|
|
2511
|
+
const uniqueId = React26__namespace.useId();
|
|
2512
|
+
const controlId = `coord-display${uniqueId}`;
|
|
2405
2513
|
const { style, visible } = useControlPosition(controlRef, {
|
|
2406
|
-
id:
|
|
2514
|
+
id: controlId,
|
|
2407
2515
|
type: "coordinate-display",
|
|
2408
2516
|
position,
|
|
2409
2517
|
priority: "critical",
|
|
@@ -2495,7 +2603,6 @@ var CoordinateDisplay = ({
|
|
|
2495
2603
|
);
|
|
2496
2604
|
};
|
|
2497
2605
|
CoordinateDisplay.displayName = "CoordinateDisplay";
|
|
2498
|
-
var switcherIdCounter = 0;
|
|
2499
2606
|
var BasemapSwitcher = ({
|
|
2500
2607
|
basemaps,
|
|
2501
2608
|
extraBasemaps,
|
|
@@ -2503,6 +2610,7 @@ var BasemapSwitcher = ({
|
|
|
2503
2610
|
defaultBasemapId,
|
|
2504
2611
|
activeBasemapId,
|
|
2505
2612
|
onBasemapChange,
|
|
2613
|
+
onStyleError,
|
|
2506
2614
|
columns = 3,
|
|
2507
2615
|
thumbnailSize = 64,
|
|
2508
2616
|
position = "bottom-right",
|
|
@@ -2515,7 +2623,8 @@ var BasemapSwitcher = ({
|
|
|
2515
2623
|
);
|
|
2516
2624
|
const containerRef = React26__namespace.useRef(null);
|
|
2517
2625
|
const panelRef = React26__namespace.useRef(null);
|
|
2518
|
-
const
|
|
2626
|
+
const generatedId = React26__namespace.useId();
|
|
2627
|
+
const switcherId = `basemap-switcher-${generatedId}`;
|
|
2519
2628
|
const sourceBasemaps = basemaps ?? mapsCore.FREE_BASEMAPS;
|
|
2520
2629
|
const availableBasemaps = React26__namespace.useMemo(() => {
|
|
2521
2630
|
const available = mapsCore.getAvailableBasemaps(sourceBasemaps, apiKeys);
|
|
@@ -2526,7 +2635,7 @@ var BasemapSwitcher = ({
|
|
|
2526
2635
|
}, [sourceBasemaps, extraBasemaps, apiKeys]);
|
|
2527
2636
|
const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
|
|
2528
2637
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2529
|
-
id:
|
|
2638
|
+
id: switcherId,
|
|
2530
2639
|
type: "basemap-switcher",
|
|
2531
2640
|
position,
|
|
2532
2641
|
priority: "normal",
|
|
@@ -2557,7 +2666,12 @@ var BasemapSwitcher = ({
|
|
|
2557
2666
|
}, [isOpen, setExpanded]);
|
|
2558
2667
|
const handleSelect = (basemap) => {
|
|
2559
2668
|
const resolvedStyle = mapsCore.resolveBasemapStyle(basemap, apiKeys);
|
|
2560
|
-
if (!resolvedStyle)
|
|
2669
|
+
if (!resolvedStyle) {
|
|
2670
|
+
const reason = basemap.requiresApiKey ? `Basemap "${basemap.name}" requires an API key that was not provided` : `Failed to resolve style for basemap "${basemap.name}"`;
|
|
2671
|
+
console.warn(`[maps-react] BasemapSwitcher: ${reason}`);
|
|
2672
|
+
onStyleError?.({ basemap, reason });
|
|
2673
|
+
return;
|
|
2674
|
+
}
|
|
2561
2675
|
if (!activeBasemapId) {
|
|
2562
2676
|
setInternalActiveId(basemap.id);
|
|
2563
2677
|
}
|
|
@@ -2681,7 +2795,6 @@ var BasemapSwitcher = ({
|
|
|
2681
2795
|
);
|
|
2682
2796
|
};
|
|
2683
2797
|
BasemapSwitcher.displayName = "BasemapSwitcher";
|
|
2684
|
-
var managerIdCounter = 0;
|
|
2685
2798
|
var LayerManager = ({
|
|
2686
2799
|
layers,
|
|
2687
2800
|
apiKeys,
|
|
@@ -2706,10 +2819,11 @@ var LayerManager = ({
|
|
|
2706
2819
|
const [draggedId, setDraggedId] = React26__namespace.useState(null);
|
|
2707
2820
|
const [dragOver, setDragOver] = React26__namespace.useState(null);
|
|
2708
2821
|
const containerRef = React26__namespace.useRef(null);
|
|
2709
|
-
const
|
|
2822
|
+
const uniqueId = React26__namespace.useId();
|
|
2823
|
+
const managerId = `layer-manager${uniqueId}`;
|
|
2710
2824
|
const lastLayerIdsRef = React26__namespace.useRef(new Set(layers.map((l) => l.id)));
|
|
2711
2825
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2712
|
-
id:
|
|
2826
|
+
id: managerId,
|
|
2713
2827
|
type: "layer-manager",
|
|
2714
2828
|
position,
|
|
2715
2829
|
priority: "high",
|
|
@@ -3237,7 +3351,6 @@ var LayerManager = ({
|
|
|
3237
3351
|
] });
|
|
3238
3352
|
};
|
|
3239
3353
|
LayerManager.displayName = "LayerManager";
|
|
3240
|
-
var customControlIdCounter = 0;
|
|
3241
3354
|
var CustomControl = ({
|
|
3242
3355
|
position = "top-right",
|
|
3243
3356
|
fallbacks,
|
|
@@ -3250,9 +3363,10 @@ var CustomControl = ({
|
|
|
3250
3363
|
children
|
|
3251
3364
|
}) => {
|
|
3252
3365
|
const controlRef = React26__namespace.useRef(null);
|
|
3253
|
-
const
|
|
3366
|
+
const generatedId = React26__namespace.useId();
|
|
3367
|
+
const controlId = id ?? `custom-control-${generatedId}`;
|
|
3254
3368
|
const { style, visible, setExpanded } = useControlPosition(controlRef, {
|
|
3255
|
-
id:
|
|
3369
|
+
id: controlId,
|
|
3256
3370
|
type: "custom",
|
|
3257
3371
|
position,
|
|
3258
3372
|
fallbacks,
|
|
@@ -3334,10 +3448,11 @@ var DeckOverlay = ({
|
|
|
3334
3448
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3335
3449
|
overlayRef.current.setProps({
|
|
3336
3450
|
onHover,
|
|
3337
|
-
onClick
|
|
3451
|
+
onClick,
|
|
3452
|
+
...getCursor ? { getCursor } : {}
|
|
3338
3453
|
});
|
|
3339
3454
|
}
|
|
3340
|
-
}, [onHover, onClick]);
|
|
3455
|
+
}, [onHover, onClick, getCursor]);
|
|
3341
3456
|
React26__namespace.useEffect(() => {
|
|
3342
3457
|
if (overlayRef.current && effects && "setProps" in overlayRef.current) {
|
|
3343
3458
|
overlayRef.current.setProps({ effects });
|
|
@@ -3447,6 +3562,18 @@ Object.defineProperty(exports, "countFeaturesByType", {
|
|
|
3447
3562
|
enumerable: true,
|
|
3448
3563
|
get: function () { return mapsCore.countFeaturesByType; }
|
|
3449
3564
|
});
|
|
3565
|
+
Object.defineProperty(exports, "createClusterCirclePaint", {
|
|
3566
|
+
enumerable: true,
|
|
3567
|
+
get: function () { return mapsCore.createClusterCirclePaint; }
|
|
3568
|
+
});
|
|
3569
|
+
Object.defineProperty(exports, "createClusterStyles", {
|
|
3570
|
+
enumerable: true,
|
|
3571
|
+
get: function () { return mapsCore.createClusterStyles; }
|
|
3572
|
+
});
|
|
3573
|
+
Object.defineProperty(exports, "createClusterTextLayout", {
|
|
3574
|
+
enumerable: true,
|
|
3575
|
+
get: function () { return mapsCore.createClusterTextLayout; }
|
|
3576
|
+
});
|
|
3450
3577
|
Object.defineProperty(exports, "createHoverExpression", {
|
|
3451
3578
|
enumerable: true,
|
|
3452
3579
|
get: function () { return mapsCore.createHoverExpression; }
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, BaseLayerProps, FeatureClickEventParams, FeatureHoverEventParams, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
|
|
3
|
-
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterExpandOptions, ClusterFeatureProperties, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
3
|
+
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterCircleStyleOptions, ClusterExpandOptions, ClusterFeatureProperties, ClusterLayerStyles, ClusterTextStyleOptions, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, UnclusteredPointStyleOptions, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
4
4
|
import maplibregl, { Map as Map$1, StyleSpecification } from 'maplibre-gl';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
6
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -108,7 +108,7 @@ interface MapContextValue {
|
|
|
108
108
|
map: Map$1 | null;
|
|
109
109
|
/** Whether the map has loaded */
|
|
110
110
|
loaded: boolean;
|
|
111
|
-
/** Counter incremented on
|
|
111
|
+
/** Counter incremented on style changes, used to re-initialize sources/layers */
|
|
112
112
|
styleVersion: number;
|
|
113
113
|
/** Set the map style programmatically (e.g. basemap switching) */
|
|
114
114
|
setMapStyle?: (style: string | StyleSpecification) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, BaseLayerProps, FeatureClickEventParams, FeatureHoverEventParams, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
|
|
3
|
-
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterExpandOptions, ClusterFeatureProperties, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
3
|
+
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterCircleStyleOptions, ClusterExpandOptions, ClusterFeatureProperties, ClusterLayerStyles, ClusterTextStyleOptions, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, UnclusteredPointStyleOptions, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
4
4
|
import maplibregl, { Map as Map$1, StyleSpecification } from 'maplibre-gl';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
6
|
import { VariantProps } from 'class-variance-authority';
|
|
@@ -108,7 +108,7 @@ interface MapContextValue {
|
|
|
108
108
|
map: Map$1 | null;
|
|
109
109
|
/** Whether the map has loaded */
|
|
110
110
|
loaded: boolean;
|
|
111
|
-
/** Counter incremented on
|
|
111
|
+
/** Counter incremented on style changes, used to re-initialize sources/layers */
|
|
112
112
|
styleVersion: number;
|
|
113
113
|
/** Set the map style programmatically (e.g. basemap switching) */
|
|
114
114
|
setMapStyle?: (style: string | StyleSpecification) => void;
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import 'maplibre-gl/dist/maplibre-gl.css';
|
|
|
8
8
|
import '@classic-homes/maps-core/styles/controls.css';
|
|
9
9
|
import '@classic-homes/maps-core/styles/marker.css';
|
|
10
10
|
import { createPositioningCoordinator, generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, DEFAULT_BASEMAP, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, EDGE_MARGIN, formatCoordinates, getAvailableBasemaps, FREE_BASEMAPS, resolveBasemapThumbnail, createInitialLayerStates, getLayerCategories, searchLayers, groupLayersByCategory, toggleLayerVisibility, setLayerOpacity, getLayerStatesArray, reorderLayers, CATEGORY_META, resolveBasemapStyle, STACK_GAP, getLayerStyleForTheme, resolveLayerSourceUrl } from '@classic-homes/maps-core';
|
|
11
|
-
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, CATEGORY_META, CITY_LIMITS, DEFAULT_BASEMAP, FLOOD_ZONES, FREE_BASEMAPS, OSM_STANDARD, PARKS, PRIMARY_BASEMAPS, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, WATERSHEDS, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
11
|
+
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, CATEGORY_META, CITY_LIMITS, DEFAULT_BASEMAP, FLOOD_ZONES, FREE_BASEMAPS, OSM_STANDARD, PARKS, PRIMARY_BASEMAPS, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, WATERSHEDS, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
12
12
|
import * as ReactDOM from 'react-dom';
|
|
13
13
|
import { cva } from 'class-variance-authority';
|
|
14
14
|
import '@classic-homes/maps-core/styles/basemap-switcher.css';
|
|
@@ -359,7 +359,13 @@ var Map2 = React26.forwardRef(
|
|
|
359
359
|
const positioningCoordinator = positioningCoordinatorRef.current;
|
|
360
360
|
const setMapStyle = React26.useCallback((style) => {
|
|
361
361
|
activeStyleOverrideRef.current = style;
|
|
362
|
-
mapRef.current
|
|
362
|
+
const map = mapRef.current;
|
|
363
|
+
if (map) {
|
|
364
|
+
map.setStyle(style);
|
|
365
|
+
map.once("idle", () => {
|
|
366
|
+
setStyleVersion((v) => v + 1);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
363
369
|
}, []);
|
|
364
370
|
const prefersReducedMotion2 = useReducedMotion();
|
|
365
371
|
const { style: themeStyle } = useMapTheme(themePref);
|
|
@@ -416,9 +422,6 @@ var Map2 = React26.forwardRef(
|
|
|
416
422
|
attributionControl: attributionControl ? { customAttribution } : false
|
|
417
423
|
});
|
|
418
424
|
mapRef.current = map;
|
|
419
|
-
map.on("style.load", () => {
|
|
420
|
-
setStyleVersion((v) => v + 1);
|
|
421
|
-
});
|
|
422
425
|
if (navigationControl) {
|
|
423
426
|
map.addControl(
|
|
424
427
|
new maplibregl.NavigationControl({
|
|
@@ -488,7 +491,19 @@ var Map2 = React26.forwardRef(
|
|
|
488
491
|
zLayer: "base"
|
|
489
492
|
});
|
|
490
493
|
}
|
|
494
|
+
const initTimeoutId = setTimeout(() => {
|
|
495
|
+
if (!mapRef.current?.loaded()) {
|
|
496
|
+
const errorMessage = "Map initialization timeout - style may be unreachable";
|
|
497
|
+
setMapError(errorMessage);
|
|
498
|
+
onErrorRef.current?.({
|
|
499
|
+
type: "error",
|
|
500
|
+
message: errorMessage,
|
|
501
|
+
error: new Error(errorMessage)
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
}, 3e4);
|
|
491
505
|
map.on("load", () => {
|
|
506
|
+
clearTimeout(initTimeoutId);
|
|
492
507
|
setMapLoaded(true);
|
|
493
508
|
if (bounds) {
|
|
494
509
|
map.fitBounds(bounds, {
|
|
@@ -502,11 +517,13 @@ var Map2 = React26.forwardRef(
|
|
|
502
517
|
const errorMessage = e.error?.message || "Map error";
|
|
503
518
|
const isTransient = errorMessage.includes("non-existing layer") || errorMessage.includes("Cannot filter");
|
|
504
519
|
if (!isTransient) {
|
|
520
|
+
clearTimeout(initTimeoutId);
|
|
505
521
|
setMapError(errorMessage);
|
|
506
522
|
}
|
|
507
523
|
onErrorRef.current?.({ type: "error", message: errorMessage, error: e.error });
|
|
508
524
|
});
|
|
509
525
|
return () => {
|
|
526
|
+
clearTimeout(initTimeoutId);
|
|
510
527
|
map.remove();
|
|
511
528
|
mapRef.current = null;
|
|
512
529
|
setMapLoaded(false);
|
|
@@ -517,6 +534,17 @@ var Map2 = React26.forwardRef(
|
|
|
517
534
|
onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
|
|
518
535
|
}
|
|
519
536
|
}, []);
|
|
537
|
+
React26.useEffect(() => {
|
|
538
|
+
const map = mapRef.current;
|
|
539
|
+
if (!map || !mapLoaded) return;
|
|
540
|
+
const handleStyleLoad = () => {
|
|
541
|
+
setStyleVersion((v) => v + 1);
|
|
542
|
+
};
|
|
543
|
+
map.on("style.load", handleStyleLoad);
|
|
544
|
+
return () => {
|
|
545
|
+
map.off("style.load", handleStyleLoad);
|
|
546
|
+
};
|
|
547
|
+
}, [mapLoaded]);
|
|
520
548
|
const styleInitialized = React26.useRef(false);
|
|
521
549
|
React26.useEffect(() => {
|
|
522
550
|
if (!mapRef.current || !mapLoaded) return;
|
|
@@ -601,23 +629,23 @@ var Map2 = React26.forwardRef(
|
|
|
601
629
|
const handleZoom = () => {
|
|
602
630
|
onZoom?.({ type: "zoom", ...createMoveParams() });
|
|
603
631
|
};
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
632
|
+
map.on("click", handleClick);
|
|
633
|
+
map.on("dblclick", handleDblClick);
|
|
634
|
+
map.on("contextmenu", handleContextMenu);
|
|
635
|
+
map.on("mousemove", handleMouseMove);
|
|
636
|
+
map.on("move", handleMove);
|
|
637
|
+
map.on("movestart", handleMoveStart);
|
|
638
|
+
map.on("moveend", handleMoveEnd);
|
|
639
|
+
map.on("zoom", handleZoom);
|
|
612
640
|
return () => {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
641
|
+
map.off("click", handleClick);
|
|
642
|
+
map.off("dblclick", handleDblClick);
|
|
643
|
+
map.off("contextmenu", handleContextMenu);
|
|
644
|
+
map.off("mousemove", handleMouseMove);
|
|
645
|
+
map.off("move", handleMove);
|
|
646
|
+
map.off("movestart", handleMoveStart);
|
|
647
|
+
map.off("moveend", handleMoveEnd);
|
|
648
|
+
map.off("zoom", handleZoom);
|
|
621
649
|
};
|
|
622
650
|
}, [
|
|
623
651
|
mapLoaded,
|
|
@@ -631,6 +659,16 @@ var Map2 = React26.forwardRef(
|
|
|
631
659
|
onZoom
|
|
632
660
|
]);
|
|
633
661
|
const combinedError = error || mapError;
|
|
662
|
+
const contextValue = React26.useMemo(
|
|
663
|
+
() => ({
|
|
664
|
+
map: mapRef.current,
|
|
665
|
+
loaded: mapLoaded,
|
|
666
|
+
styleVersion,
|
|
667
|
+
setMapStyle,
|
|
668
|
+
positioningCoordinator
|
|
669
|
+
}),
|
|
670
|
+
[mapLoaded, styleVersion, setMapStyle, positioningCoordinator]
|
|
671
|
+
);
|
|
634
672
|
return /* @__PURE__ */ jsx(
|
|
635
673
|
MapContainer,
|
|
636
674
|
{
|
|
@@ -643,22 +681,10 @@ var Map2 = React26.forwardRef(
|
|
|
643
681
|
error: combinedError,
|
|
644
682
|
emptyMessage,
|
|
645
683
|
className,
|
|
646
|
-
children: /* @__PURE__ */ jsxs(
|
|
647
|
-
|
|
648
|
-
{
|
|
649
|
-
|
|
650
|
-
map: mapRef.current,
|
|
651
|
-
loaded: mapLoaded,
|
|
652
|
-
styleVersion,
|
|
653
|
-
setMapStyle,
|
|
654
|
-
positioningCoordinator
|
|
655
|
-
},
|
|
656
|
-
children: [
|
|
657
|
-
/* @__PURE__ */ jsx("div", { ref: containerRef, className: "absolute inset-0" }),
|
|
658
|
-
mapLoaded && children && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
|
|
659
|
-
]
|
|
660
|
-
}
|
|
661
|
-
)
|
|
684
|
+
children: /* @__PURE__ */ jsxs(MapContext.Provider, { value: contextValue, children: [
|
|
685
|
+
/* @__PURE__ */ jsx("div", { ref: containerRef, className: "absolute inset-0" }),
|
|
686
|
+
mapLoaded && children && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
|
|
687
|
+
] })
|
|
662
688
|
}
|
|
663
689
|
);
|
|
664
690
|
}
|
|
@@ -949,6 +975,9 @@ var Marker = React26.forwardRef(
|
|
|
949
975
|
const elementRef = React26.useRef(null);
|
|
950
976
|
const originalLngLatRef = React26.useRef();
|
|
951
977
|
const clickHandlerRef = React26.useRef(null);
|
|
978
|
+
const dragStartHandlerRef = React26.useRef(null);
|
|
979
|
+
const dragHandlerRef = React26.useRef(null);
|
|
980
|
+
const dragEndHandlerRef = React26.useRef(null);
|
|
952
981
|
const [mounted, setMounted] = React26.useState(false);
|
|
953
982
|
const onClickRef = React26.useRef(onClick);
|
|
954
983
|
onClickRef.current = onClick;
|
|
@@ -1014,11 +1043,11 @@ var Marker = React26.forwardRef(
|
|
|
1014
1043
|
element.addEventListener("click", handleClick);
|
|
1015
1044
|
}
|
|
1016
1045
|
if (draggable) {
|
|
1017
|
-
|
|
1046
|
+
const handleDragStart = () => {
|
|
1018
1047
|
const lngLat = marker.getLngLat();
|
|
1019
1048
|
originalLngLatRef.current = [lngLat.lng, lngLat.lat];
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1049
|
+
};
|
|
1050
|
+
const handleDrag = () => {
|
|
1022
1051
|
const lngLat = marker.getLngLat();
|
|
1023
1052
|
onDragRef.current?.({
|
|
1024
1053
|
type: "drag",
|
|
@@ -1026,8 +1055,8 @@ var Marker = React26.forwardRef(
|
|
|
1026
1055
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
1027
1056
|
originalLngLat: originalLngLatRef.current
|
|
1028
1057
|
});
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1058
|
+
};
|
|
1059
|
+
const handleDragEnd = () => {
|
|
1031
1060
|
const lngLat = marker.getLngLat();
|
|
1032
1061
|
onDragEndRef.current?.({
|
|
1033
1062
|
type: "dragend",
|
|
@@ -1035,13 +1064,33 @@ var Marker = React26.forwardRef(
|
|
|
1035
1064
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
1036
1065
|
originalLngLat: originalLngLatRef.current
|
|
1037
1066
|
});
|
|
1038
|
-
}
|
|
1067
|
+
};
|
|
1068
|
+
dragStartHandlerRef.current = handleDragStart;
|
|
1069
|
+
dragHandlerRef.current = handleDrag;
|
|
1070
|
+
dragEndHandlerRef.current = handleDragEnd;
|
|
1071
|
+
marker.on("dragstart", handleDragStart);
|
|
1072
|
+
marker.on("drag", handleDrag);
|
|
1073
|
+
marker.on("dragend", handleDragEnd);
|
|
1039
1074
|
}
|
|
1040
1075
|
return () => {
|
|
1041
1076
|
if (clickHandlerRef.current && markerRef.current) {
|
|
1042
1077
|
markerRef.current.getElement().removeEventListener("click", clickHandlerRef.current);
|
|
1043
1078
|
clickHandlerRef.current = null;
|
|
1044
1079
|
}
|
|
1080
|
+
if (markerRef.current) {
|
|
1081
|
+
if (dragStartHandlerRef.current) {
|
|
1082
|
+
markerRef.current.off("dragstart", dragStartHandlerRef.current);
|
|
1083
|
+
dragStartHandlerRef.current = null;
|
|
1084
|
+
}
|
|
1085
|
+
if (dragHandlerRef.current) {
|
|
1086
|
+
markerRef.current.off("drag", dragHandlerRef.current);
|
|
1087
|
+
dragHandlerRef.current = null;
|
|
1088
|
+
}
|
|
1089
|
+
if (dragEndHandlerRef.current) {
|
|
1090
|
+
markerRef.current.off("dragend", dragEndHandlerRef.current);
|
|
1091
|
+
dragEndHandlerRef.current = null;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1045
1094
|
if (markerRef.current) {
|
|
1046
1095
|
removeMarkerProtection(markerRef.current.getElement());
|
|
1047
1096
|
markerRef.current.remove();
|
|
@@ -1055,10 +1104,53 @@ var Marker = React26.forwardRef(
|
|
|
1055
1104
|
}
|
|
1056
1105
|
}, [coordinates]);
|
|
1057
1106
|
React26.useEffect(() => {
|
|
1058
|
-
|
|
1059
|
-
|
|
1107
|
+
const marker = markerRef.current;
|
|
1108
|
+
if (!marker) return;
|
|
1109
|
+
marker.setDraggable(draggable);
|
|
1110
|
+
if (!draggable) {
|
|
1111
|
+
if (dragStartHandlerRef.current) {
|
|
1112
|
+
marker.off("dragstart", dragStartHandlerRef.current);
|
|
1113
|
+
dragStartHandlerRef.current = null;
|
|
1114
|
+
}
|
|
1115
|
+
if (dragHandlerRef.current) {
|
|
1116
|
+
marker.off("drag", dragHandlerRef.current);
|
|
1117
|
+
dragHandlerRef.current = null;
|
|
1118
|
+
}
|
|
1119
|
+
if (dragEndHandlerRef.current) {
|
|
1120
|
+
marker.off("dragend", dragEndHandlerRef.current);
|
|
1121
|
+
dragEndHandlerRef.current = null;
|
|
1122
|
+
}
|
|
1123
|
+
} else if (!dragStartHandlerRef.current) {
|
|
1124
|
+
const handleDragStart = () => {
|
|
1125
|
+
const lngLat = marker.getLngLat();
|
|
1126
|
+
originalLngLatRef.current = [lngLat.lng, lngLat.lat];
|
|
1127
|
+
};
|
|
1128
|
+
const handleDrag = () => {
|
|
1129
|
+
const lngLat = marker.getLngLat();
|
|
1130
|
+
onDragRef.current?.({
|
|
1131
|
+
type: "drag",
|
|
1132
|
+
markerId: id || "",
|
|
1133
|
+
lngLat: [lngLat.lng, lngLat.lat],
|
|
1134
|
+
originalLngLat: originalLngLatRef.current
|
|
1135
|
+
});
|
|
1136
|
+
};
|
|
1137
|
+
const handleDragEnd = () => {
|
|
1138
|
+
const lngLat = marker.getLngLat();
|
|
1139
|
+
onDragEndRef.current?.({
|
|
1140
|
+
type: "dragend",
|
|
1141
|
+
markerId: id || "",
|
|
1142
|
+
lngLat: [lngLat.lng, lngLat.lat],
|
|
1143
|
+
originalLngLat: originalLngLatRef.current
|
|
1144
|
+
});
|
|
1145
|
+
};
|
|
1146
|
+
dragStartHandlerRef.current = handleDragStart;
|
|
1147
|
+
dragHandlerRef.current = handleDrag;
|
|
1148
|
+
dragEndHandlerRef.current = handleDragEnd;
|
|
1149
|
+
marker.on("dragstart", handleDragStart);
|
|
1150
|
+
marker.on("drag", handleDrag);
|
|
1151
|
+
marker.on("dragend", handleDragEnd);
|
|
1060
1152
|
}
|
|
1061
|
-
}, [draggable]);
|
|
1153
|
+
}, [draggable, id]);
|
|
1062
1154
|
React26.useEffect(() => {
|
|
1063
1155
|
if (markerRef.current && rotation !== void 0) {
|
|
1064
1156
|
markerRef.current.setRotation(rotation);
|
|
@@ -1418,7 +1510,11 @@ function useLayer({
|
|
|
1418
1510
|
const handleClick = (e) => {
|
|
1419
1511
|
const params = createFeatureParams(e);
|
|
1420
1512
|
if (params) {
|
|
1421
|
-
|
|
1513
|
+
try {
|
|
1514
|
+
onClick?.({ type: "click", ...params });
|
|
1515
|
+
} catch (err) {
|
|
1516
|
+
console.error(`[maps-react] Layer "${id}" click handler error:`, err);
|
|
1517
|
+
}
|
|
1422
1518
|
}
|
|
1423
1519
|
};
|
|
1424
1520
|
const handleMouseEnter = (e) => {
|
|
@@ -1440,7 +1536,11 @@ function useLayer({
|
|
|
1440
1536
|
}
|
|
1441
1537
|
const params = createFeatureParams(e);
|
|
1442
1538
|
if (params) {
|
|
1443
|
-
|
|
1539
|
+
try {
|
|
1540
|
+
onHover?.({ type: "mouseenter", ...params });
|
|
1541
|
+
} catch (err) {
|
|
1542
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1543
|
+
}
|
|
1444
1544
|
}
|
|
1445
1545
|
};
|
|
1446
1546
|
const handleMouseMove = (e) => {
|
|
@@ -1465,7 +1565,11 @@ function useLayer({
|
|
|
1465
1565
|
lastHoverCallTime.current = now;
|
|
1466
1566
|
const params = createFeatureParams(e);
|
|
1467
1567
|
if (params) {
|
|
1468
|
-
|
|
1568
|
+
try {
|
|
1569
|
+
onHover?.({ type: "mousemove", ...params });
|
|
1570
|
+
} catch (err) {
|
|
1571
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1572
|
+
}
|
|
1469
1573
|
}
|
|
1470
1574
|
}
|
|
1471
1575
|
} else {
|
|
@@ -1483,15 +1587,19 @@ function useLayer({
|
|
|
1483
1587
|
hoveredFeatureId.current = null;
|
|
1484
1588
|
}
|
|
1485
1589
|
const lastPos = lastMousePosition.current;
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1590
|
+
try {
|
|
1591
|
+
onHover?.({
|
|
1592
|
+
type: "mouseleave",
|
|
1593
|
+
feature: null,
|
|
1594
|
+
layerId: id,
|
|
1595
|
+
sourceId: source,
|
|
1596
|
+
lngLat: lastPos?.lngLat ?? [0, 0],
|
|
1597
|
+
point: lastPos?.point ?? [0, 0],
|
|
1598
|
+
map
|
|
1599
|
+
});
|
|
1600
|
+
} catch (err) {
|
|
1601
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1602
|
+
}
|
|
1495
1603
|
lastMousePosition.current = null;
|
|
1496
1604
|
};
|
|
1497
1605
|
if (onClick) {
|
|
@@ -2083,7 +2191,6 @@ function useControlPosition(ref, options) {
|
|
|
2083
2191
|
visible: offset?.visible ?? false
|
|
2084
2192
|
};
|
|
2085
2193
|
}
|
|
2086
|
-
var legendIdCounter = 0;
|
|
2087
2194
|
var Legend = ({
|
|
2088
2195
|
title,
|
|
2089
2196
|
position = "bottom-left",
|
|
@@ -2099,9 +2206,10 @@ var Legend = ({
|
|
|
2099
2206
|
}) => {
|
|
2100
2207
|
const [isCollapsed, setIsCollapsed] = React26.useState(initialCollapsed);
|
|
2101
2208
|
const legendRef = React26.useRef(null);
|
|
2102
|
-
const
|
|
2209
|
+
const generatedId = React26.useId();
|
|
2210
|
+
const legendId = `legend-${generatedId}`;
|
|
2103
2211
|
const { style, visible } = useControlPosition(legendRef, {
|
|
2104
|
-
id:
|
|
2212
|
+
id: legendId,
|
|
2105
2213
|
type: "legend",
|
|
2106
2214
|
position,
|
|
2107
2215
|
priority: "normal",
|
|
@@ -2362,7 +2470,6 @@ var LegendGroup = ({
|
|
|
2362
2470
|
);
|
|
2363
2471
|
};
|
|
2364
2472
|
LegendGroup.displayName = "LegendGroup";
|
|
2365
|
-
var coordDisplayIdCounter = 0;
|
|
2366
2473
|
var NAV_CONTROL_WIDTH = 29;
|
|
2367
2474
|
var CoordinateDisplay = ({
|
|
2368
2475
|
position = "bottom-right",
|
|
@@ -2377,9 +2484,10 @@ var CoordinateDisplay = ({
|
|
|
2377
2484
|
const [currentZoom, setCurrentZoom] = React26.useState(0);
|
|
2378
2485
|
const [currentBearing, setCurrentBearing] = React26.useState(0);
|
|
2379
2486
|
const controlRef = React26.useRef(null);
|
|
2380
|
-
const
|
|
2487
|
+
const uniqueId = React26.useId();
|
|
2488
|
+
const controlId = `coord-display${uniqueId}`;
|
|
2381
2489
|
const { style, visible } = useControlPosition(controlRef, {
|
|
2382
|
-
id:
|
|
2490
|
+
id: controlId,
|
|
2383
2491
|
type: "coordinate-display",
|
|
2384
2492
|
position,
|
|
2385
2493
|
priority: "critical",
|
|
@@ -2471,7 +2579,6 @@ var CoordinateDisplay = ({
|
|
|
2471
2579
|
);
|
|
2472
2580
|
};
|
|
2473
2581
|
CoordinateDisplay.displayName = "CoordinateDisplay";
|
|
2474
|
-
var switcherIdCounter = 0;
|
|
2475
2582
|
var BasemapSwitcher = ({
|
|
2476
2583
|
basemaps,
|
|
2477
2584
|
extraBasemaps,
|
|
@@ -2479,6 +2586,7 @@ var BasemapSwitcher = ({
|
|
|
2479
2586
|
defaultBasemapId,
|
|
2480
2587
|
activeBasemapId,
|
|
2481
2588
|
onBasemapChange,
|
|
2589
|
+
onStyleError,
|
|
2482
2590
|
columns = 3,
|
|
2483
2591
|
thumbnailSize = 64,
|
|
2484
2592
|
position = "bottom-right",
|
|
@@ -2491,7 +2599,8 @@ var BasemapSwitcher = ({
|
|
|
2491
2599
|
);
|
|
2492
2600
|
const containerRef = React26.useRef(null);
|
|
2493
2601
|
const panelRef = React26.useRef(null);
|
|
2494
|
-
const
|
|
2602
|
+
const generatedId = React26.useId();
|
|
2603
|
+
const switcherId = `basemap-switcher-${generatedId}`;
|
|
2495
2604
|
const sourceBasemaps = basemaps ?? FREE_BASEMAPS;
|
|
2496
2605
|
const availableBasemaps = React26.useMemo(() => {
|
|
2497
2606
|
const available = getAvailableBasemaps(sourceBasemaps, apiKeys);
|
|
@@ -2502,7 +2611,7 @@ var BasemapSwitcher = ({
|
|
|
2502
2611
|
}, [sourceBasemaps, extraBasemaps, apiKeys]);
|
|
2503
2612
|
const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
|
|
2504
2613
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2505
|
-
id:
|
|
2614
|
+
id: switcherId,
|
|
2506
2615
|
type: "basemap-switcher",
|
|
2507
2616
|
position,
|
|
2508
2617
|
priority: "normal",
|
|
@@ -2533,7 +2642,12 @@ var BasemapSwitcher = ({
|
|
|
2533
2642
|
}, [isOpen, setExpanded]);
|
|
2534
2643
|
const handleSelect = (basemap) => {
|
|
2535
2644
|
const resolvedStyle = resolveBasemapStyle(basemap, apiKeys);
|
|
2536
|
-
if (!resolvedStyle)
|
|
2645
|
+
if (!resolvedStyle) {
|
|
2646
|
+
const reason = basemap.requiresApiKey ? `Basemap "${basemap.name}" requires an API key that was not provided` : `Failed to resolve style for basemap "${basemap.name}"`;
|
|
2647
|
+
console.warn(`[maps-react] BasemapSwitcher: ${reason}`);
|
|
2648
|
+
onStyleError?.({ basemap, reason });
|
|
2649
|
+
return;
|
|
2650
|
+
}
|
|
2537
2651
|
if (!activeBasemapId) {
|
|
2538
2652
|
setInternalActiveId(basemap.id);
|
|
2539
2653
|
}
|
|
@@ -2657,7 +2771,6 @@ var BasemapSwitcher = ({
|
|
|
2657
2771
|
);
|
|
2658
2772
|
};
|
|
2659
2773
|
BasemapSwitcher.displayName = "BasemapSwitcher";
|
|
2660
|
-
var managerIdCounter = 0;
|
|
2661
2774
|
var LayerManager = ({
|
|
2662
2775
|
layers,
|
|
2663
2776
|
apiKeys,
|
|
@@ -2682,10 +2795,11 @@ var LayerManager = ({
|
|
|
2682
2795
|
const [draggedId, setDraggedId] = React26.useState(null);
|
|
2683
2796
|
const [dragOver, setDragOver] = React26.useState(null);
|
|
2684
2797
|
const containerRef = React26.useRef(null);
|
|
2685
|
-
const
|
|
2798
|
+
const uniqueId = React26.useId();
|
|
2799
|
+
const managerId = `layer-manager${uniqueId}`;
|
|
2686
2800
|
const lastLayerIdsRef = React26.useRef(new Set(layers.map((l) => l.id)));
|
|
2687
2801
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2688
|
-
id:
|
|
2802
|
+
id: managerId,
|
|
2689
2803
|
type: "layer-manager",
|
|
2690
2804
|
position,
|
|
2691
2805
|
priority: "high",
|
|
@@ -3213,7 +3327,6 @@ var LayerManager = ({
|
|
|
3213
3327
|
] });
|
|
3214
3328
|
};
|
|
3215
3329
|
LayerManager.displayName = "LayerManager";
|
|
3216
|
-
var customControlIdCounter = 0;
|
|
3217
3330
|
var CustomControl = ({
|
|
3218
3331
|
position = "top-right",
|
|
3219
3332
|
fallbacks,
|
|
@@ -3226,9 +3339,10 @@ var CustomControl = ({
|
|
|
3226
3339
|
children
|
|
3227
3340
|
}) => {
|
|
3228
3341
|
const controlRef = React26.useRef(null);
|
|
3229
|
-
const
|
|
3342
|
+
const generatedId = React26.useId();
|
|
3343
|
+
const controlId = id ?? `custom-control-${generatedId}`;
|
|
3230
3344
|
const { style, visible, setExpanded } = useControlPosition(controlRef, {
|
|
3231
|
-
id:
|
|
3345
|
+
id: controlId,
|
|
3232
3346
|
type: "custom",
|
|
3233
3347
|
position,
|
|
3234
3348
|
fallbacks,
|
|
@@ -3310,10 +3424,11 @@ var DeckOverlay = ({
|
|
|
3310
3424
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3311
3425
|
overlayRef.current.setProps({
|
|
3312
3426
|
onHover,
|
|
3313
|
-
onClick
|
|
3427
|
+
onClick,
|
|
3428
|
+
...getCursor ? { getCursor } : {}
|
|
3314
3429
|
});
|
|
3315
3430
|
}
|
|
3316
|
-
}, [onHover, onClick]);
|
|
3431
|
+
}, [onHover, onClick, getCursor]);
|
|
3317
3432
|
React26.useEffect(() => {
|
|
3318
3433
|
if (overlayRef.current && effects && "setProps" in overlayRef.current) {
|
|
3319
3434
|
overlayRef.current.setProps({ effects });
|