@classic-homes/maps-react 0.2.7 → 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 -77
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +191 -78
- 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,11 +446,6 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
440
446
|
attributionControl: attributionControl ? { customAttribution } : false
|
|
441
447
|
});
|
|
442
448
|
mapRef.current = map;
|
|
443
|
-
map.on("data", (e) => {
|
|
444
|
-
if (e.dataType === "style") {
|
|
445
|
-
setStyleVersion((v) => v + 1);
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
449
|
if (navigationControl) {
|
|
449
450
|
map.addControl(
|
|
450
451
|
new maplibregl__default.default.NavigationControl({
|
|
@@ -514,7 +515,19 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
514
515
|
zLayer: "base"
|
|
515
516
|
});
|
|
516
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);
|
|
517
529
|
map.on("load", () => {
|
|
530
|
+
clearTimeout(initTimeoutId);
|
|
518
531
|
setMapLoaded(true);
|
|
519
532
|
if (bounds) {
|
|
520
533
|
map.fitBounds(bounds, {
|
|
@@ -528,11 +541,13 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
528
541
|
const errorMessage = e.error?.message || "Map error";
|
|
529
542
|
const isTransient = errorMessage.includes("non-existing layer") || errorMessage.includes("Cannot filter");
|
|
530
543
|
if (!isTransient) {
|
|
544
|
+
clearTimeout(initTimeoutId);
|
|
531
545
|
setMapError(errorMessage);
|
|
532
546
|
}
|
|
533
547
|
onErrorRef.current?.({ type: "error", message: errorMessage, error: e.error });
|
|
534
548
|
});
|
|
535
549
|
return () => {
|
|
550
|
+
clearTimeout(initTimeoutId);
|
|
536
551
|
map.remove();
|
|
537
552
|
mapRef.current = null;
|
|
538
553
|
setMapLoaded(false);
|
|
@@ -543,6 +558,17 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
543
558
|
onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
|
|
544
559
|
}
|
|
545
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]);
|
|
546
572
|
const styleInitialized = React26__namespace.useRef(false);
|
|
547
573
|
React26__namespace.useEffect(() => {
|
|
548
574
|
if (!mapRef.current || !mapLoaded) return;
|
|
@@ -627,23 +653,23 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
627
653
|
const handleZoom = () => {
|
|
628
654
|
onZoom?.({ type: "zoom", ...createMoveParams() });
|
|
629
655
|
};
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
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);
|
|
638
664
|
return () => {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
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);
|
|
647
673
|
};
|
|
648
674
|
}, [
|
|
649
675
|
mapLoaded,
|
|
@@ -657,6 +683,16 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
657
683
|
onZoom
|
|
658
684
|
]);
|
|
659
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
|
+
);
|
|
660
696
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
661
697
|
MapContainer,
|
|
662
698
|
{
|
|
@@ -669,22 +705,10 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
669
705
|
error: combinedError,
|
|
670
706
|
emptyMessage,
|
|
671
707
|
className,
|
|
672
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
673
|
-
|
|
674
|
-
{
|
|
675
|
-
|
|
676
|
-
map: mapRef.current,
|
|
677
|
-
loaded: mapLoaded,
|
|
678
|
-
styleVersion,
|
|
679
|
-
setMapStyle,
|
|
680
|
-
positioningCoordinator
|
|
681
|
-
},
|
|
682
|
-
children: [
|
|
683
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "absolute inset-0" }),
|
|
684
|
-
mapLoaded && children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
|
|
685
|
-
]
|
|
686
|
-
}
|
|
687
|
-
)
|
|
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
|
+
] })
|
|
688
712
|
}
|
|
689
713
|
);
|
|
690
714
|
}
|
|
@@ -975,6 +999,9 @@ var Marker = React26__namespace.forwardRef(
|
|
|
975
999
|
const elementRef = React26__namespace.useRef(null);
|
|
976
1000
|
const originalLngLatRef = React26__namespace.useRef();
|
|
977
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);
|
|
978
1005
|
const [mounted, setMounted] = React26__namespace.useState(false);
|
|
979
1006
|
const onClickRef = React26__namespace.useRef(onClick);
|
|
980
1007
|
onClickRef.current = onClick;
|
|
@@ -1040,11 +1067,11 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1040
1067
|
element.addEventListener("click", handleClick);
|
|
1041
1068
|
}
|
|
1042
1069
|
if (draggable) {
|
|
1043
|
-
|
|
1070
|
+
const handleDragStart = () => {
|
|
1044
1071
|
const lngLat = marker.getLngLat();
|
|
1045
1072
|
originalLngLatRef.current = [lngLat.lng, lngLat.lat];
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1073
|
+
};
|
|
1074
|
+
const handleDrag = () => {
|
|
1048
1075
|
const lngLat = marker.getLngLat();
|
|
1049
1076
|
onDragRef.current?.({
|
|
1050
1077
|
type: "drag",
|
|
@@ -1052,8 +1079,8 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1052
1079
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
1053
1080
|
originalLngLat: originalLngLatRef.current
|
|
1054
1081
|
});
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1082
|
+
};
|
|
1083
|
+
const handleDragEnd = () => {
|
|
1057
1084
|
const lngLat = marker.getLngLat();
|
|
1058
1085
|
onDragEndRef.current?.({
|
|
1059
1086
|
type: "dragend",
|
|
@@ -1061,13 +1088,33 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1061
1088
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
1062
1089
|
originalLngLat: originalLngLatRef.current
|
|
1063
1090
|
});
|
|
1064
|
-
}
|
|
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);
|
|
1065
1098
|
}
|
|
1066
1099
|
return () => {
|
|
1067
1100
|
if (clickHandlerRef.current && markerRef.current) {
|
|
1068
1101
|
markerRef.current.getElement().removeEventListener("click", clickHandlerRef.current);
|
|
1069
1102
|
clickHandlerRef.current = null;
|
|
1070
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
|
+
}
|
|
1071
1118
|
if (markerRef.current) {
|
|
1072
1119
|
mapsCore.removeMarkerProtection(markerRef.current.getElement());
|
|
1073
1120
|
markerRef.current.remove();
|
|
@@ -1081,10 +1128,53 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1081
1128
|
}
|
|
1082
1129
|
}, [coordinates]);
|
|
1083
1130
|
React26__namespace.useEffect(() => {
|
|
1084
|
-
|
|
1085
|
-
|
|
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);
|
|
1086
1176
|
}
|
|
1087
|
-
}, [draggable]);
|
|
1177
|
+
}, [draggable, id]);
|
|
1088
1178
|
React26__namespace.useEffect(() => {
|
|
1089
1179
|
if (markerRef.current && rotation !== void 0) {
|
|
1090
1180
|
markerRef.current.setRotation(rotation);
|
|
@@ -1444,7 +1534,11 @@ function useLayer({
|
|
|
1444
1534
|
const handleClick = (e) => {
|
|
1445
1535
|
const params = createFeatureParams(e);
|
|
1446
1536
|
if (params) {
|
|
1447
|
-
|
|
1537
|
+
try {
|
|
1538
|
+
onClick?.({ type: "click", ...params });
|
|
1539
|
+
} catch (err) {
|
|
1540
|
+
console.error(`[maps-react] Layer "${id}" click handler error:`, err);
|
|
1541
|
+
}
|
|
1448
1542
|
}
|
|
1449
1543
|
};
|
|
1450
1544
|
const handleMouseEnter = (e) => {
|
|
@@ -1466,7 +1560,11 @@ function useLayer({
|
|
|
1466
1560
|
}
|
|
1467
1561
|
const params = createFeatureParams(e);
|
|
1468
1562
|
if (params) {
|
|
1469
|
-
|
|
1563
|
+
try {
|
|
1564
|
+
onHover?.({ type: "mouseenter", ...params });
|
|
1565
|
+
} catch (err) {
|
|
1566
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1567
|
+
}
|
|
1470
1568
|
}
|
|
1471
1569
|
};
|
|
1472
1570
|
const handleMouseMove = (e) => {
|
|
@@ -1491,7 +1589,11 @@ function useLayer({
|
|
|
1491
1589
|
lastHoverCallTime.current = now;
|
|
1492
1590
|
const params = createFeatureParams(e);
|
|
1493
1591
|
if (params) {
|
|
1494
|
-
|
|
1592
|
+
try {
|
|
1593
|
+
onHover?.({ type: "mousemove", ...params });
|
|
1594
|
+
} catch (err) {
|
|
1595
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1596
|
+
}
|
|
1495
1597
|
}
|
|
1496
1598
|
}
|
|
1497
1599
|
} else {
|
|
@@ -1509,15 +1611,19 @@ function useLayer({
|
|
|
1509
1611
|
hoveredFeatureId.current = null;
|
|
1510
1612
|
}
|
|
1511
1613
|
const lastPos = lastMousePosition.current;
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
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
|
+
}
|
|
1521
1627
|
lastMousePosition.current = null;
|
|
1522
1628
|
};
|
|
1523
1629
|
if (onClick) {
|
|
@@ -2109,7 +2215,6 @@ function useControlPosition(ref, options) {
|
|
|
2109
2215
|
visible: offset?.visible ?? false
|
|
2110
2216
|
};
|
|
2111
2217
|
}
|
|
2112
|
-
var legendIdCounter = 0;
|
|
2113
2218
|
var Legend = ({
|
|
2114
2219
|
title,
|
|
2115
2220
|
position = "bottom-left",
|
|
@@ -2125,9 +2230,10 @@ var Legend = ({
|
|
|
2125
2230
|
}) => {
|
|
2126
2231
|
const [isCollapsed, setIsCollapsed] = React26__namespace.useState(initialCollapsed);
|
|
2127
2232
|
const legendRef = React26__namespace.useRef(null);
|
|
2128
|
-
const
|
|
2233
|
+
const generatedId = React26__namespace.useId();
|
|
2234
|
+
const legendId = `legend-${generatedId}`;
|
|
2129
2235
|
const { style, visible } = useControlPosition(legendRef, {
|
|
2130
|
-
id:
|
|
2236
|
+
id: legendId,
|
|
2131
2237
|
type: "legend",
|
|
2132
2238
|
position,
|
|
2133
2239
|
priority: "normal",
|
|
@@ -2388,7 +2494,6 @@ var LegendGroup = ({
|
|
|
2388
2494
|
);
|
|
2389
2495
|
};
|
|
2390
2496
|
LegendGroup.displayName = "LegendGroup";
|
|
2391
|
-
var coordDisplayIdCounter = 0;
|
|
2392
2497
|
var NAV_CONTROL_WIDTH = 29;
|
|
2393
2498
|
var CoordinateDisplay = ({
|
|
2394
2499
|
position = "bottom-right",
|
|
@@ -2403,9 +2508,10 @@ var CoordinateDisplay = ({
|
|
|
2403
2508
|
const [currentZoom, setCurrentZoom] = React26__namespace.useState(0);
|
|
2404
2509
|
const [currentBearing, setCurrentBearing] = React26__namespace.useState(0);
|
|
2405
2510
|
const controlRef = React26__namespace.useRef(null);
|
|
2406
|
-
const
|
|
2511
|
+
const uniqueId = React26__namespace.useId();
|
|
2512
|
+
const controlId = `coord-display${uniqueId}`;
|
|
2407
2513
|
const { style, visible } = useControlPosition(controlRef, {
|
|
2408
|
-
id:
|
|
2514
|
+
id: controlId,
|
|
2409
2515
|
type: "coordinate-display",
|
|
2410
2516
|
position,
|
|
2411
2517
|
priority: "critical",
|
|
@@ -2497,7 +2603,6 @@ var CoordinateDisplay = ({
|
|
|
2497
2603
|
);
|
|
2498
2604
|
};
|
|
2499
2605
|
CoordinateDisplay.displayName = "CoordinateDisplay";
|
|
2500
|
-
var switcherIdCounter = 0;
|
|
2501
2606
|
var BasemapSwitcher = ({
|
|
2502
2607
|
basemaps,
|
|
2503
2608
|
extraBasemaps,
|
|
@@ -2505,6 +2610,7 @@ var BasemapSwitcher = ({
|
|
|
2505
2610
|
defaultBasemapId,
|
|
2506
2611
|
activeBasemapId,
|
|
2507
2612
|
onBasemapChange,
|
|
2613
|
+
onStyleError,
|
|
2508
2614
|
columns = 3,
|
|
2509
2615
|
thumbnailSize = 64,
|
|
2510
2616
|
position = "bottom-right",
|
|
@@ -2517,7 +2623,8 @@ var BasemapSwitcher = ({
|
|
|
2517
2623
|
);
|
|
2518
2624
|
const containerRef = React26__namespace.useRef(null);
|
|
2519
2625
|
const panelRef = React26__namespace.useRef(null);
|
|
2520
|
-
const
|
|
2626
|
+
const generatedId = React26__namespace.useId();
|
|
2627
|
+
const switcherId = `basemap-switcher-${generatedId}`;
|
|
2521
2628
|
const sourceBasemaps = basemaps ?? mapsCore.FREE_BASEMAPS;
|
|
2522
2629
|
const availableBasemaps = React26__namespace.useMemo(() => {
|
|
2523
2630
|
const available = mapsCore.getAvailableBasemaps(sourceBasemaps, apiKeys);
|
|
@@ -2528,7 +2635,7 @@ var BasemapSwitcher = ({
|
|
|
2528
2635
|
}, [sourceBasemaps, extraBasemaps, apiKeys]);
|
|
2529
2636
|
const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
|
|
2530
2637
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2531
|
-
id:
|
|
2638
|
+
id: switcherId,
|
|
2532
2639
|
type: "basemap-switcher",
|
|
2533
2640
|
position,
|
|
2534
2641
|
priority: "normal",
|
|
@@ -2559,7 +2666,12 @@ var BasemapSwitcher = ({
|
|
|
2559
2666
|
}, [isOpen, setExpanded]);
|
|
2560
2667
|
const handleSelect = (basemap) => {
|
|
2561
2668
|
const resolvedStyle = mapsCore.resolveBasemapStyle(basemap, apiKeys);
|
|
2562
|
-
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
|
+
}
|
|
2563
2675
|
if (!activeBasemapId) {
|
|
2564
2676
|
setInternalActiveId(basemap.id);
|
|
2565
2677
|
}
|
|
@@ -2683,7 +2795,6 @@ var BasemapSwitcher = ({
|
|
|
2683
2795
|
);
|
|
2684
2796
|
};
|
|
2685
2797
|
BasemapSwitcher.displayName = "BasemapSwitcher";
|
|
2686
|
-
var managerIdCounter = 0;
|
|
2687
2798
|
var LayerManager = ({
|
|
2688
2799
|
layers,
|
|
2689
2800
|
apiKeys,
|
|
@@ -2708,10 +2819,11 @@ var LayerManager = ({
|
|
|
2708
2819
|
const [draggedId, setDraggedId] = React26__namespace.useState(null);
|
|
2709
2820
|
const [dragOver, setDragOver] = React26__namespace.useState(null);
|
|
2710
2821
|
const containerRef = React26__namespace.useRef(null);
|
|
2711
|
-
const
|
|
2822
|
+
const uniqueId = React26__namespace.useId();
|
|
2823
|
+
const managerId = `layer-manager${uniqueId}`;
|
|
2712
2824
|
const lastLayerIdsRef = React26__namespace.useRef(new Set(layers.map((l) => l.id)));
|
|
2713
2825
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2714
|
-
id:
|
|
2826
|
+
id: managerId,
|
|
2715
2827
|
type: "layer-manager",
|
|
2716
2828
|
position,
|
|
2717
2829
|
priority: "high",
|
|
@@ -3239,7 +3351,6 @@ var LayerManager = ({
|
|
|
3239
3351
|
] });
|
|
3240
3352
|
};
|
|
3241
3353
|
LayerManager.displayName = "LayerManager";
|
|
3242
|
-
var customControlIdCounter = 0;
|
|
3243
3354
|
var CustomControl = ({
|
|
3244
3355
|
position = "top-right",
|
|
3245
3356
|
fallbacks,
|
|
@@ -3252,9 +3363,10 @@ var CustomControl = ({
|
|
|
3252
3363
|
children
|
|
3253
3364
|
}) => {
|
|
3254
3365
|
const controlRef = React26__namespace.useRef(null);
|
|
3255
|
-
const
|
|
3366
|
+
const generatedId = React26__namespace.useId();
|
|
3367
|
+
const controlId = id ?? `custom-control-${generatedId}`;
|
|
3256
3368
|
const { style, visible, setExpanded } = useControlPosition(controlRef, {
|
|
3257
|
-
id:
|
|
3369
|
+
id: controlId,
|
|
3258
3370
|
type: "custom",
|
|
3259
3371
|
position,
|
|
3260
3372
|
fallbacks,
|
|
@@ -3336,10 +3448,11 @@ var DeckOverlay = ({
|
|
|
3336
3448
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3337
3449
|
overlayRef.current.setProps({
|
|
3338
3450
|
onHover,
|
|
3339
|
-
onClick
|
|
3451
|
+
onClick,
|
|
3452
|
+
...getCursor ? { getCursor } : {}
|
|
3340
3453
|
});
|
|
3341
3454
|
}
|
|
3342
|
-
}, [onHover, onClick]);
|
|
3455
|
+
}, [onHover, onClick, getCursor]);
|
|
3343
3456
|
React26__namespace.useEffect(() => {
|
|
3344
3457
|
if (overlayRef.current && effects && "setProps" in overlayRef.current) {
|
|
3345
3458
|
overlayRef.current.setProps({ effects });
|
|
@@ -3449,6 +3562,18 @@ Object.defineProperty(exports, "countFeaturesByType", {
|
|
|
3449
3562
|
enumerable: true,
|
|
3450
3563
|
get: function () { return mapsCore.countFeaturesByType; }
|
|
3451
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
|
+
});
|
|
3452
3577
|
Object.defineProperty(exports, "createHoverExpression", {
|
|
3453
3578
|
enumerable: true,
|
|
3454
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,11 +422,6 @@ var Map2 = React26.forwardRef(
|
|
|
416
422
|
attributionControl: attributionControl ? { customAttribution } : false
|
|
417
423
|
});
|
|
418
424
|
mapRef.current = map;
|
|
419
|
-
map.on("data", (e) => {
|
|
420
|
-
if (e.dataType === "style") {
|
|
421
|
-
setStyleVersion((v) => v + 1);
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
425
|
if (navigationControl) {
|
|
425
426
|
map.addControl(
|
|
426
427
|
new maplibregl.NavigationControl({
|
|
@@ -490,7 +491,19 @@ var Map2 = React26.forwardRef(
|
|
|
490
491
|
zLayer: "base"
|
|
491
492
|
});
|
|
492
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);
|
|
493
505
|
map.on("load", () => {
|
|
506
|
+
clearTimeout(initTimeoutId);
|
|
494
507
|
setMapLoaded(true);
|
|
495
508
|
if (bounds) {
|
|
496
509
|
map.fitBounds(bounds, {
|
|
@@ -504,11 +517,13 @@ var Map2 = React26.forwardRef(
|
|
|
504
517
|
const errorMessage = e.error?.message || "Map error";
|
|
505
518
|
const isTransient = errorMessage.includes("non-existing layer") || errorMessage.includes("Cannot filter");
|
|
506
519
|
if (!isTransient) {
|
|
520
|
+
clearTimeout(initTimeoutId);
|
|
507
521
|
setMapError(errorMessage);
|
|
508
522
|
}
|
|
509
523
|
onErrorRef.current?.({ type: "error", message: errorMessage, error: e.error });
|
|
510
524
|
});
|
|
511
525
|
return () => {
|
|
526
|
+
clearTimeout(initTimeoutId);
|
|
512
527
|
map.remove();
|
|
513
528
|
mapRef.current = null;
|
|
514
529
|
setMapLoaded(false);
|
|
@@ -519,6 +534,17 @@ var Map2 = React26.forwardRef(
|
|
|
519
534
|
onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
|
|
520
535
|
}
|
|
521
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]);
|
|
522
548
|
const styleInitialized = React26.useRef(false);
|
|
523
549
|
React26.useEffect(() => {
|
|
524
550
|
if (!mapRef.current || !mapLoaded) return;
|
|
@@ -603,23 +629,23 @@ var Map2 = React26.forwardRef(
|
|
|
603
629
|
const handleZoom = () => {
|
|
604
630
|
onZoom?.({ type: "zoom", ...createMoveParams() });
|
|
605
631
|
};
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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);
|
|
614
640
|
return () => {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
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);
|
|
623
649
|
};
|
|
624
650
|
}, [
|
|
625
651
|
mapLoaded,
|
|
@@ -633,6 +659,16 @@ var Map2 = React26.forwardRef(
|
|
|
633
659
|
onZoom
|
|
634
660
|
]);
|
|
635
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
|
+
);
|
|
636
672
|
return /* @__PURE__ */ jsx(
|
|
637
673
|
MapContainer,
|
|
638
674
|
{
|
|
@@ -645,22 +681,10 @@ var Map2 = React26.forwardRef(
|
|
|
645
681
|
error: combinedError,
|
|
646
682
|
emptyMessage,
|
|
647
683
|
className,
|
|
648
|
-
children: /* @__PURE__ */ jsxs(
|
|
649
|
-
|
|
650
|
-
{
|
|
651
|
-
|
|
652
|
-
map: mapRef.current,
|
|
653
|
-
loaded: mapLoaded,
|
|
654
|
-
styleVersion,
|
|
655
|
-
setMapStyle,
|
|
656
|
-
positioningCoordinator
|
|
657
|
-
},
|
|
658
|
-
children: [
|
|
659
|
-
/* @__PURE__ */ jsx("div", { ref: containerRef, className: "absolute inset-0" }),
|
|
660
|
-
mapLoaded && children && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
|
|
661
|
-
]
|
|
662
|
-
}
|
|
663
|
-
)
|
|
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
|
+
] })
|
|
664
688
|
}
|
|
665
689
|
);
|
|
666
690
|
}
|
|
@@ -951,6 +975,9 @@ var Marker = React26.forwardRef(
|
|
|
951
975
|
const elementRef = React26.useRef(null);
|
|
952
976
|
const originalLngLatRef = React26.useRef();
|
|
953
977
|
const clickHandlerRef = React26.useRef(null);
|
|
978
|
+
const dragStartHandlerRef = React26.useRef(null);
|
|
979
|
+
const dragHandlerRef = React26.useRef(null);
|
|
980
|
+
const dragEndHandlerRef = React26.useRef(null);
|
|
954
981
|
const [mounted, setMounted] = React26.useState(false);
|
|
955
982
|
const onClickRef = React26.useRef(onClick);
|
|
956
983
|
onClickRef.current = onClick;
|
|
@@ -1016,11 +1043,11 @@ var Marker = React26.forwardRef(
|
|
|
1016
1043
|
element.addEventListener("click", handleClick);
|
|
1017
1044
|
}
|
|
1018
1045
|
if (draggable) {
|
|
1019
|
-
|
|
1046
|
+
const handleDragStart = () => {
|
|
1020
1047
|
const lngLat = marker.getLngLat();
|
|
1021
1048
|
originalLngLatRef.current = [lngLat.lng, lngLat.lat];
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1049
|
+
};
|
|
1050
|
+
const handleDrag = () => {
|
|
1024
1051
|
const lngLat = marker.getLngLat();
|
|
1025
1052
|
onDragRef.current?.({
|
|
1026
1053
|
type: "drag",
|
|
@@ -1028,8 +1055,8 @@ var Marker = React26.forwardRef(
|
|
|
1028
1055
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
1029
1056
|
originalLngLat: originalLngLatRef.current
|
|
1030
1057
|
});
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1058
|
+
};
|
|
1059
|
+
const handleDragEnd = () => {
|
|
1033
1060
|
const lngLat = marker.getLngLat();
|
|
1034
1061
|
onDragEndRef.current?.({
|
|
1035
1062
|
type: "dragend",
|
|
@@ -1037,13 +1064,33 @@ var Marker = React26.forwardRef(
|
|
|
1037
1064
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
1038
1065
|
originalLngLat: originalLngLatRef.current
|
|
1039
1066
|
});
|
|
1040
|
-
}
|
|
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);
|
|
1041
1074
|
}
|
|
1042
1075
|
return () => {
|
|
1043
1076
|
if (clickHandlerRef.current && markerRef.current) {
|
|
1044
1077
|
markerRef.current.getElement().removeEventListener("click", clickHandlerRef.current);
|
|
1045
1078
|
clickHandlerRef.current = null;
|
|
1046
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
|
+
}
|
|
1047
1094
|
if (markerRef.current) {
|
|
1048
1095
|
removeMarkerProtection(markerRef.current.getElement());
|
|
1049
1096
|
markerRef.current.remove();
|
|
@@ -1057,10 +1104,53 @@ var Marker = React26.forwardRef(
|
|
|
1057
1104
|
}
|
|
1058
1105
|
}, [coordinates]);
|
|
1059
1106
|
React26.useEffect(() => {
|
|
1060
|
-
|
|
1061
|
-
|
|
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);
|
|
1062
1152
|
}
|
|
1063
|
-
}, [draggable]);
|
|
1153
|
+
}, [draggable, id]);
|
|
1064
1154
|
React26.useEffect(() => {
|
|
1065
1155
|
if (markerRef.current && rotation !== void 0) {
|
|
1066
1156
|
markerRef.current.setRotation(rotation);
|
|
@@ -1420,7 +1510,11 @@ function useLayer({
|
|
|
1420
1510
|
const handleClick = (e) => {
|
|
1421
1511
|
const params = createFeatureParams(e);
|
|
1422
1512
|
if (params) {
|
|
1423
|
-
|
|
1513
|
+
try {
|
|
1514
|
+
onClick?.({ type: "click", ...params });
|
|
1515
|
+
} catch (err) {
|
|
1516
|
+
console.error(`[maps-react] Layer "${id}" click handler error:`, err);
|
|
1517
|
+
}
|
|
1424
1518
|
}
|
|
1425
1519
|
};
|
|
1426
1520
|
const handleMouseEnter = (e) => {
|
|
@@ -1442,7 +1536,11 @@ function useLayer({
|
|
|
1442
1536
|
}
|
|
1443
1537
|
const params = createFeatureParams(e);
|
|
1444
1538
|
if (params) {
|
|
1445
|
-
|
|
1539
|
+
try {
|
|
1540
|
+
onHover?.({ type: "mouseenter", ...params });
|
|
1541
|
+
} catch (err) {
|
|
1542
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1543
|
+
}
|
|
1446
1544
|
}
|
|
1447
1545
|
};
|
|
1448
1546
|
const handleMouseMove = (e) => {
|
|
@@ -1467,7 +1565,11 @@ function useLayer({
|
|
|
1467
1565
|
lastHoverCallTime.current = now;
|
|
1468
1566
|
const params = createFeatureParams(e);
|
|
1469
1567
|
if (params) {
|
|
1470
|
-
|
|
1568
|
+
try {
|
|
1569
|
+
onHover?.({ type: "mousemove", ...params });
|
|
1570
|
+
} catch (err) {
|
|
1571
|
+
console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
|
|
1572
|
+
}
|
|
1471
1573
|
}
|
|
1472
1574
|
}
|
|
1473
1575
|
} else {
|
|
@@ -1485,15 +1587,19 @@ function useLayer({
|
|
|
1485
1587
|
hoveredFeatureId.current = null;
|
|
1486
1588
|
}
|
|
1487
1589
|
const lastPos = lastMousePosition.current;
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
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
|
+
}
|
|
1497
1603
|
lastMousePosition.current = null;
|
|
1498
1604
|
};
|
|
1499
1605
|
if (onClick) {
|
|
@@ -2085,7 +2191,6 @@ function useControlPosition(ref, options) {
|
|
|
2085
2191
|
visible: offset?.visible ?? false
|
|
2086
2192
|
};
|
|
2087
2193
|
}
|
|
2088
|
-
var legendIdCounter = 0;
|
|
2089
2194
|
var Legend = ({
|
|
2090
2195
|
title,
|
|
2091
2196
|
position = "bottom-left",
|
|
@@ -2101,9 +2206,10 @@ var Legend = ({
|
|
|
2101
2206
|
}) => {
|
|
2102
2207
|
const [isCollapsed, setIsCollapsed] = React26.useState(initialCollapsed);
|
|
2103
2208
|
const legendRef = React26.useRef(null);
|
|
2104
|
-
const
|
|
2209
|
+
const generatedId = React26.useId();
|
|
2210
|
+
const legendId = `legend-${generatedId}`;
|
|
2105
2211
|
const { style, visible } = useControlPosition(legendRef, {
|
|
2106
|
-
id:
|
|
2212
|
+
id: legendId,
|
|
2107
2213
|
type: "legend",
|
|
2108
2214
|
position,
|
|
2109
2215
|
priority: "normal",
|
|
@@ -2364,7 +2470,6 @@ var LegendGroup = ({
|
|
|
2364
2470
|
);
|
|
2365
2471
|
};
|
|
2366
2472
|
LegendGroup.displayName = "LegendGroup";
|
|
2367
|
-
var coordDisplayIdCounter = 0;
|
|
2368
2473
|
var NAV_CONTROL_WIDTH = 29;
|
|
2369
2474
|
var CoordinateDisplay = ({
|
|
2370
2475
|
position = "bottom-right",
|
|
@@ -2379,9 +2484,10 @@ var CoordinateDisplay = ({
|
|
|
2379
2484
|
const [currentZoom, setCurrentZoom] = React26.useState(0);
|
|
2380
2485
|
const [currentBearing, setCurrentBearing] = React26.useState(0);
|
|
2381
2486
|
const controlRef = React26.useRef(null);
|
|
2382
|
-
const
|
|
2487
|
+
const uniqueId = React26.useId();
|
|
2488
|
+
const controlId = `coord-display${uniqueId}`;
|
|
2383
2489
|
const { style, visible } = useControlPosition(controlRef, {
|
|
2384
|
-
id:
|
|
2490
|
+
id: controlId,
|
|
2385
2491
|
type: "coordinate-display",
|
|
2386
2492
|
position,
|
|
2387
2493
|
priority: "critical",
|
|
@@ -2473,7 +2579,6 @@ var CoordinateDisplay = ({
|
|
|
2473
2579
|
);
|
|
2474
2580
|
};
|
|
2475
2581
|
CoordinateDisplay.displayName = "CoordinateDisplay";
|
|
2476
|
-
var switcherIdCounter = 0;
|
|
2477
2582
|
var BasemapSwitcher = ({
|
|
2478
2583
|
basemaps,
|
|
2479
2584
|
extraBasemaps,
|
|
@@ -2481,6 +2586,7 @@ var BasemapSwitcher = ({
|
|
|
2481
2586
|
defaultBasemapId,
|
|
2482
2587
|
activeBasemapId,
|
|
2483
2588
|
onBasemapChange,
|
|
2589
|
+
onStyleError,
|
|
2484
2590
|
columns = 3,
|
|
2485
2591
|
thumbnailSize = 64,
|
|
2486
2592
|
position = "bottom-right",
|
|
@@ -2493,7 +2599,8 @@ var BasemapSwitcher = ({
|
|
|
2493
2599
|
);
|
|
2494
2600
|
const containerRef = React26.useRef(null);
|
|
2495
2601
|
const panelRef = React26.useRef(null);
|
|
2496
|
-
const
|
|
2602
|
+
const generatedId = React26.useId();
|
|
2603
|
+
const switcherId = `basemap-switcher-${generatedId}`;
|
|
2497
2604
|
const sourceBasemaps = basemaps ?? FREE_BASEMAPS;
|
|
2498
2605
|
const availableBasemaps = React26.useMemo(() => {
|
|
2499
2606
|
const available = getAvailableBasemaps(sourceBasemaps, apiKeys);
|
|
@@ -2504,7 +2611,7 @@ var BasemapSwitcher = ({
|
|
|
2504
2611
|
}, [sourceBasemaps, extraBasemaps, apiKeys]);
|
|
2505
2612
|
const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
|
|
2506
2613
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2507
|
-
id:
|
|
2614
|
+
id: switcherId,
|
|
2508
2615
|
type: "basemap-switcher",
|
|
2509
2616
|
position,
|
|
2510
2617
|
priority: "normal",
|
|
@@ -2535,7 +2642,12 @@ var BasemapSwitcher = ({
|
|
|
2535
2642
|
}, [isOpen, setExpanded]);
|
|
2536
2643
|
const handleSelect = (basemap) => {
|
|
2537
2644
|
const resolvedStyle = resolveBasemapStyle(basemap, apiKeys);
|
|
2538
|
-
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
|
+
}
|
|
2539
2651
|
if (!activeBasemapId) {
|
|
2540
2652
|
setInternalActiveId(basemap.id);
|
|
2541
2653
|
}
|
|
@@ -2659,7 +2771,6 @@ var BasemapSwitcher = ({
|
|
|
2659
2771
|
);
|
|
2660
2772
|
};
|
|
2661
2773
|
BasemapSwitcher.displayName = "BasemapSwitcher";
|
|
2662
|
-
var managerIdCounter = 0;
|
|
2663
2774
|
var LayerManager = ({
|
|
2664
2775
|
layers,
|
|
2665
2776
|
apiKeys,
|
|
@@ -2684,10 +2795,11 @@ var LayerManager = ({
|
|
|
2684
2795
|
const [draggedId, setDraggedId] = React26.useState(null);
|
|
2685
2796
|
const [dragOver, setDragOver] = React26.useState(null);
|
|
2686
2797
|
const containerRef = React26.useRef(null);
|
|
2687
|
-
const
|
|
2798
|
+
const uniqueId = React26.useId();
|
|
2799
|
+
const managerId = `layer-manager${uniqueId}`;
|
|
2688
2800
|
const lastLayerIdsRef = React26.useRef(new Set(layers.map((l) => l.id)));
|
|
2689
2801
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2690
|
-
id:
|
|
2802
|
+
id: managerId,
|
|
2691
2803
|
type: "layer-manager",
|
|
2692
2804
|
position,
|
|
2693
2805
|
priority: "high",
|
|
@@ -3215,7 +3327,6 @@ var LayerManager = ({
|
|
|
3215
3327
|
] });
|
|
3216
3328
|
};
|
|
3217
3329
|
LayerManager.displayName = "LayerManager";
|
|
3218
|
-
var customControlIdCounter = 0;
|
|
3219
3330
|
var CustomControl = ({
|
|
3220
3331
|
position = "top-right",
|
|
3221
3332
|
fallbacks,
|
|
@@ -3228,9 +3339,10 @@ var CustomControl = ({
|
|
|
3228
3339
|
children
|
|
3229
3340
|
}) => {
|
|
3230
3341
|
const controlRef = React26.useRef(null);
|
|
3231
|
-
const
|
|
3342
|
+
const generatedId = React26.useId();
|
|
3343
|
+
const controlId = id ?? `custom-control-${generatedId}`;
|
|
3232
3344
|
const { style, visible, setExpanded } = useControlPosition(controlRef, {
|
|
3233
|
-
id:
|
|
3345
|
+
id: controlId,
|
|
3234
3346
|
type: "custom",
|
|
3235
3347
|
position,
|
|
3236
3348
|
fallbacks,
|
|
@@ -3312,10 +3424,11 @@ var DeckOverlay = ({
|
|
|
3312
3424
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3313
3425
|
overlayRef.current.setProps({
|
|
3314
3426
|
onHover,
|
|
3315
|
-
onClick
|
|
3427
|
+
onClick,
|
|
3428
|
+
...getCursor ? { getCursor } : {}
|
|
3316
3429
|
});
|
|
3317
3430
|
}
|
|
3318
|
-
}, [onHover, onClick]);
|
|
3431
|
+
}, [onHover, onClick, getCursor]);
|
|
3319
3432
|
React26.useEffect(() => {
|
|
3320
3433
|
if (overlayRef.current && effects && "setProps" in overlayRef.current) {
|
|
3321
3434
|
overlayRef.current.setProps({ effects });
|