@classic-homes/maps-react 0.1.2 → 0.1.3
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 +280 -174
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +280 -174
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -296,11 +296,7 @@ function useReducedMotion() {
|
|
|
296
296
|
}, []);
|
|
297
297
|
return prefersReducedMotion2;
|
|
298
298
|
}
|
|
299
|
-
var MapContext = React6__namespace.createContext(
|
|
300
|
-
map: null,
|
|
301
|
-
loaded: false,
|
|
302
|
-
controlOffsets: {}
|
|
303
|
-
});
|
|
299
|
+
var MapContext = React6__namespace.createContext(null);
|
|
304
300
|
function useMap() {
|
|
305
301
|
const context = React6__namespace.useContext(MapContext);
|
|
306
302
|
if (!context) {
|
|
@@ -379,6 +375,10 @@ var Map = React6__namespace.forwardRef(
|
|
|
379
375
|
const [, forceUpdate] = React6__namespace.useReducer((x) => x + 1, 0);
|
|
380
376
|
const prefersReducedMotion2 = useReducedMotion();
|
|
381
377
|
const { style: themeStyle } = useMapTheme(themePref);
|
|
378
|
+
const onLoadRef = React6__namespace.useRef(onLoad);
|
|
379
|
+
onLoadRef.current = onLoad;
|
|
380
|
+
const onErrorRef = React6__namespace.useRef(onError);
|
|
381
|
+
onErrorRef.current = onError;
|
|
382
382
|
const mapStyle = customStyle || themeStyle;
|
|
383
383
|
const controlOffsets = React6__namespace.useMemo(() => {
|
|
384
384
|
const offsets = {
|
|
@@ -507,12 +507,15 @@ var Map = React6__namespace.forwardRef(
|
|
|
507
507
|
animate: animation && !prefersReducedMotion2
|
|
508
508
|
});
|
|
509
509
|
}
|
|
510
|
-
|
|
510
|
+
onLoadRef.current?.({ type: "load", loaded: true });
|
|
511
511
|
});
|
|
512
512
|
map.on("error", (e) => {
|
|
513
513
|
const errorMessage = e.error?.message || "Map error";
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
const isTransient = errorMessage.includes("non-existing layer") || errorMessage.includes("Cannot filter");
|
|
515
|
+
if (!isTransient) {
|
|
516
|
+
setMapError(errorMessage);
|
|
517
|
+
}
|
|
518
|
+
onErrorRef.current?.({ type: "error", message: errorMessage, error: e.error });
|
|
516
519
|
});
|
|
517
520
|
return () => {
|
|
518
521
|
map.remove();
|
|
@@ -522,11 +525,16 @@ var Map = React6__namespace.forwardRef(
|
|
|
522
525
|
} catch (err) {
|
|
523
526
|
const errorMessage = err instanceof Error ? err.message : "Failed to initialize map";
|
|
524
527
|
setMapError(errorMessage);
|
|
525
|
-
|
|
528
|
+
onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
|
|
526
529
|
}
|
|
527
530
|
}, []);
|
|
531
|
+
const styleInitialized = React6__namespace.useRef(false);
|
|
528
532
|
React6__namespace.useEffect(() => {
|
|
529
533
|
if (!mapRef.current || !mapLoaded) return;
|
|
534
|
+
if (!styleInitialized.current) {
|
|
535
|
+
styleInitialized.current = true;
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
530
538
|
mapRef.current.setStyle(mapStyle);
|
|
531
539
|
}, [mapStyle, mapLoaded]);
|
|
532
540
|
React6__namespace.useEffect(() => {
|
|
@@ -717,7 +725,7 @@ var Source = ({
|
|
|
717
725
|
return;
|
|
718
726
|
}
|
|
719
727
|
const prefersReducedMotion2 = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
720
|
-
requestAnimationFrame(() => {
|
|
728
|
+
const rafHandle = requestAnimationFrame(() => {
|
|
721
729
|
if (cancelledRef.current || initialFitDone.current) return;
|
|
722
730
|
try {
|
|
723
731
|
const centerLng = (swLng + neLng) / 2;
|
|
@@ -740,6 +748,7 @@ var Source = ({
|
|
|
740
748
|
console.warn("[maps-react] Source: fitBounds failed", err);
|
|
741
749
|
}
|
|
742
750
|
});
|
|
751
|
+
return rafHandle;
|
|
743
752
|
},
|
|
744
753
|
[map]
|
|
745
754
|
);
|
|
@@ -815,18 +824,21 @@ var Source = ({
|
|
|
815
824
|
return;
|
|
816
825
|
}
|
|
817
826
|
const cancelledRef = { current: false };
|
|
827
|
+
const rafHandles = [];
|
|
818
828
|
const handleSourceData = (e) => {
|
|
819
829
|
if (cancelledRef.current) return;
|
|
820
830
|
if (e.sourceId === id && e.isSourceLoaded) {
|
|
821
831
|
map.off("sourcedata", handleSourceData);
|
|
822
|
-
performFitBounds(cancelledRef);
|
|
832
|
+
const h = performFitBounds(cancelledRef);
|
|
833
|
+
if (h !== void 0) rafHandles.push(h);
|
|
823
834
|
}
|
|
824
835
|
};
|
|
825
836
|
map.on("sourcedata", handleSourceData);
|
|
826
837
|
const handleIdle = () => {
|
|
827
838
|
if (cancelledRef.current) return;
|
|
828
839
|
map.off("idle", handleIdle);
|
|
829
|
-
performFitBounds(cancelledRef);
|
|
840
|
+
const h = performFitBounds(cancelledRef);
|
|
841
|
+
if (h !== void 0) rafHandles.push(h);
|
|
830
842
|
};
|
|
831
843
|
map.once("idle", handleIdle);
|
|
832
844
|
map.addSource(id, sourceConfig);
|
|
@@ -835,12 +847,16 @@ var Source = ({
|
|
|
835
847
|
if (source && map.isSourceLoaded(id)) {
|
|
836
848
|
map.off("sourcedata", handleSourceData);
|
|
837
849
|
map.off("idle", handleIdle);
|
|
838
|
-
performFitBounds(cancelledRef);
|
|
850
|
+
const h = performFitBounds(cancelledRef);
|
|
851
|
+
if (h !== void 0) rafHandles.push(h);
|
|
839
852
|
}
|
|
840
853
|
const cleanupListeners = () => {
|
|
841
854
|
cancelledRef.current = true;
|
|
842
855
|
map.off("sourcedata", handleSourceData);
|
|
843
856
|
map.off("idle", handleIdle);
|
|
857
|
+
for (const h of rafHandles) {
|
|
858
|
+
cancelAnimationFrame(h);
|
|
859
|
+
}
|
|
844
860
|
};
|
|
845
861
|
return () => {
|
|
846
862
|
cleanupListeners();
|
|
@@ -923,6 +939,12 @@ var Marker = React6__namespace.forwardRef(
|
|
|
923
939
|
const originalLngLatRef = React6__namespace.useRef();
|
|
924
940
|
const clickHandlerRef = React6__namespace.useRef(null);
|
|
925
941
|
const [mounted, setMounted] = React6__namespace.useState(false);
|
|
942
|
+
const onClickRef = React6__namespace.useRef(onClick);
|
|
943
|
+
onClickRef.current = onClick;
|
|
944
|
+
const onDragRef = React6__namespace.useRef(onDrag);
|
|
945
|
+
onDragRef.current = onDrag;
|
|
946
|
+
const onDragEndRef = React6__namespace.useRef(onDragEnd);
|
|
947
|
+
onDragEndRef.current = onDragEnd;
|
|
926
948
|
React6__namespace.useEffect(() => {
|
|
927
949
|
setMounted(true);
|
|
928
950
|
return () => setMounted(false);
|
|
@@ -964,12 +986,13 @@ var Marker = React6__namespace.forwardRef(
|
|
|
964
986
|
ref.current = marker;
|
|
965
987
|
}
|
|
966
988
|
}
|
|
967
|
-
|
|
989
|
+
{
|
|
968
990
|
const element = marker.getElement();
|
|
969
991
|
const handleClick = (e) => {
|
|
992
|
+
if (!onClickRef.current) return;
|
|
970
993
|
e.stopPropagation();
|
|
971
994
|
const lngLat = marker.getLngLat();
|
|
972
|
-
|
|
995
|
+
onClickRef.current({
|
|
973
996
|
type: "click",
|
|
974
997
|
markerId: id || "",
|
|
975
998
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
@@ -985,26 +1008,22 @@ var Marker = React6__namespace.forwardRef(
|
|
|
985
1008
|
originalLngLatRef.current = [lngLat.lng, lngLat.lat];
|
|
986
1009
|
});
|
|
987
1010
|
marker.on("drag", () => {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
});
|
|
996
|
-
}
|
|
1011
|
+
const lngLat = marker.getLngLat();
|
|
1012
|
+
onDragRef.current?.({
|
|
1013
|
+
type: "drag",
|
|
1014
|
+
markerId: id || "",
|
|
1015
|
+
lngLat: [lngLat.lng, lngLat.lat],
|
|
1016
|
+
originalLngLat: originalLngLatRef.current
|
|
1017
|
+
});
|
|
997
1018
|
});
|
|
998
1019
|
marker.on("dragend", () => {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1020
|
+
const lngLat = marker.getLngLat();
|
|
1021
|
+
onDragEndRef.current?.({
|
|
1022
|
+
type: "dragend",
|
|
1023
|
+
markerId: id || "",
|
|
1024
|
+
lngLat: [lngLat.lng, lngLat.lat],
|
|
1025
|
+
originalLngLat: originalLngLatRef.current
|
|
1026
|
+
});
|
|
1008
1027
|
});
|
|
1009
1028
|
}
|
|
1010
1029
|
return () => {
|
|
@@ -1094,8 +1113,14 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1094
1113
|
}, ref) => {
|
|
1095
1114
|
const { map, loaded } = useMap();
|
|
1096
1115
|
const popupRef = React6__namespace.useRef(null);
|
|
1116
|
+
const onOpenRef = React6__namespace.useRef(onOpen);
|
|
1117
|
+
onOpenRef.current = onOpen;
|
|
1118
|
+
const onCloseRef = React6__namespace.useRef(onClose);
|
|
1119
|
+
onCloseRef.current = onClose;
|
|
1120
|
+
const coordinatesRef = React6__namespace.useRef(coordinates);
|
|
1121
|
+
coordinatesRef.current = coordinates;
|
|
1097
1122
|
const containerRef = React6__namespace.useRef(null);
|
|
1098
|
-
if (!containerRef.current) {
|
|
1123
|
+
if (!containerRef.current && typeof document !== "undefined") {
|
|
1099
1124
|
containerRef.current = document.createElement("div");
|
|
1100
1125
|
containerRef.current.className = "maplibregl-popup-content-wrapper";
|
|
1101
1126
|
}
|
|
@@ -1118,23 +1143,16 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1118
1143
|
});
|
|
1119
1144
|
popup.setDOMContent(containerRef.current);
|
|
1120
1145
|
popupRef.current = popup;
|
|
1121
|
-
if (ref) {
|
|
1122
|
-
if (typeof ref === "function") {
|
|
1123
|
-
ref(popup);
|
|
1124
|
-
} else {
|
|
1125
|
-
ref.current = popup;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
1146
|
popup.on("open", () => {
|
|
1129
|
-
|
|
1147
|
+
onOpenRef.current?.({
|
|
1130
1148
|
type: "open",
|
|
1131
|
-
lngLat:
|
|
1149
|
+
lngLat: coordinatesRef.current
|
|
1132
1150
|
});
|
|
1133
1151
|
});
|
|
1134
1152
|
popup.on("close", () => {
|
|
1135
|
-
|
|
1153
|
+
onCloseRef.current?.({
|
|
1136
1154
|
type: "close",
|
|
1137
|
-
lngLat:
|
|
1155
|
+
lngLat: coordinatesRef.current
|
|
1138
1156
|
});
|
|
1139
1157
|
});
|
|
1140
1158
|
return () => {
|
|
@@ -1150,12 +1168,16 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1150
1168
|
anchor,
|
|
1151
1169
|
offset,
|
|
1152
1170
|
maxWidth,
|
|
1153
|
-
focusAfterOpen
|
|
1154
|
-
ref,
|
|
1155
|
-
onOpen,
|
|
1156
|
-
onClose,
|
|
1157
|
-
coordinates
|
|
1171
|
+
focusAfterOpen
|
|
1158
1172
|
]);
|
|
1173
|
+
React6__namespace.useEffect(() => {
|
|
1174
|
+
if (!popupRef.current || !ref) return;
|
|
1175
|
+
if (typeof ref === "function") {
|
|
1176
|
+
ref(popupRef.current);
|
|
1177
|
+
} else {
|
|
1178
|
+
ref.current = popupRef.current;
|
|
1179
|
+
}
|
|
1180
|
+
}, [ref]);
|
|
1159
1181
|
React6__namespace.useEffect(() => {
|
|
1160
1182
|
if (popupRef.current) {
|
|
1161
1183
|
popupRef.current.setLngLat(coordinates);
|
|
@@ -1163,10 +1185,11 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1163
1185
|
}, [coordinates]);
|
|
1164
1186
|
React6__namespace.useEffect(() => {
|
|
1165
1187
|
if (!map || !popupRef.current || !contentReady) return;
|
|
1188
|
+
let rafHandle;
|
|
1166
1189
|
if (open) {
|
|
1167
1190
|
popupRef.current.setLngLat(coordinates).addTo(map);
|
|
1168
1191
|
if (autoPan) {
|
|
1169
|
-
requestAnimationFrame(() => {
|
|
1192
|
+
rafHandle = requestAnimationFrame(() => {
|
|
1170
1193
|
if (popupRef.current && map) {
|
|
1171
1194
|
panToFitPopup(map, popupRef.current, normalizePadding(autoPanPadding));
|
|
1172
1195
|
}
|
|
@@ -1175,7 +1198,13 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1175
1198
|
} else {
|
|
1176
1199
|
popupRef.current.remove();
|
|
1177
1200
|
}
|
|
1201
|
+
return () => {
|
|
1202
|
+
if (rafHandle !== void 0) {
|
|
1203
|
+
cancelAnimationFrame(rafHandle);
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1178
1206
|
}, [map, open, coordinates, autoPan, autoPanPadding, contentReady]);
|
|
1207
|
+
if (!containerRef.current) return null;
|
|
1179
1208
|
return ReactDOM__namespace.createPortal(
|
|
1180
1209
|
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: contentCallbackRef, children }),
|
|
1181
1210
|
containerRef.current
|
|
@@ -1294,7 +1323,7 @@ function useLayer({
|
|
|
1294
1323
|
}
|
|
1295
1324
|
addLayer();
|
|
1296
1325
|
function addLayer() {
|
|
1297
|
-
if (
|
|
1326
|
+
if (map.getLayer(id)) {
|
|
1298
1327
|
setLayerAdded(true);
|
|
1299
1328
|
return;
|
|
1300
1329
|
}
|
|
@@ -1328,7 +1357,7 @@ function useLayer({
|
|
|
1328
1357
|
}
|
|
1329
1358
|
}
|
|
1330
1359
|
return () => {
|
|
1331
|
-
if (map
|
|
1360
|
+
if (map) {
|
|
1332
1361
|
try {
|
|
1333
1362
|
if (map.getLayer(id)) {
|
|
1334
1363
|
map.removeLayer(id);
|
|
@@ -1338,29 +1367,23 @@ function useLayer({
|
|
|
1338
1367
|
setLayerAdded(false);
|
|
1339
1368
|
}
|
|
1340
1369
|
};
|
|
1341
|
-
}, [map, loaded, id, source, sourceLayer, type, beforeId
|
|
1370
|
+
}, [map, loaded, id, source, sourceLayer, type, beforeId]);
|
|
1342
1371
|
React6__namespace.useEffect(() => {
|
|
1343
1372
|
if (!map || !layerAdded) return;
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
} catch {
|
|
1347
|
-
}
|
|
1373
|
+
if (!map.getLayer(id)) return;
|
|
1374
|
+
map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
|
|
1348
1375
|
}, [map, id, visible, layerAdded]);
|
|
1349
1376
|
React6__namespace.useEffect(() => {
|
|
1350
1377
|
if (!map || !layerAdded) return;
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
} catch {
|
|
1356
|
-
}
|
|
1378
|
+
if (!map.getLayer(id)) return;
|
|
1379
|
+
Object.entries(paint).forEach(([key, value]) => {
|
|
1380
|
+
map.setPaintProperty(id, key, value);
|
|
1381
|
+
});
|
|
1357
1382
|
}, [map, id, paint, layerAdded]);
|
|
1358
1383
|
React6__namespace.useEffect(() => {
|
|
1359
1384
|
if (!map || !layerAdded || !filter) return;
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
} catch {
|
|
1363
|
-
}
|
|
1385
|
+
if (!map.getLayer(id)) return;
|
|
1386
|
+
map.setFilter(id, filter);
|
|
1364
1387
|
}, [map, id, filter, layerAdded]);
|
|
1365
1388
|
React6__namespace.useEffect(() => {
|
|
1366
1389
|
if (!map || !layerAdded) return;
|
|
@@ -1478,8 +1501,6 @@ function useLayer({
|
|
|
1478
1501
|
}, [map, id, source, sourceLayer, onClick, onHover, hoverThrottleMs, layerAdded]);
|
|
1479
1502
|
return { layerAdded };
|
|
1480
1503
|
}
|
|
1481
|
-
|
|
1482
|
-
// src/components/layers/FillLayer.tsx
|
|
1483
1504
|
var FillLayer = ({
|
|
1484
1505
|
id,
|
|
1485
1506
|
source,
|
|
@@ -1500,17 +1521,28 @@ var FillLayer = ({
|
|
|
1500
1521
|
fillTranslate,
|
|
1501
1522
|
fillAntialias
|
|
1502
1523
|
}) => {
|
|
1503
|
-
const paint = {
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1524
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1525
|
+
const p = {};
|
|
1526
|
+
if (fillColor !== void 0) p["fill-color"] = fillColor;
|
|
1527
|
+
if (fillOpacity !== void 0) p["fill-opacity"] = fillOpacity;
|
|
1528
|
+
if (fillOutlineColor !== void 0) p["fill-outline-color"] = fillOutlineColor;
|
|
1529
|
+
if (fillPattern !== void 0) p["fill-pattern"] = fillPattern;
|
|
1530
|
+
if (fillTranslate !== void 0) p["fill-translate"] = fillTranslate;
|
|
1531
|
+
if (fillAntialias !== void 0) p["fill-antialias"] = fillAntialias;
|
|
1532
|
+
if (opacity !== void 0 && fillOpacity === void 0) {
|
|
1533
|
+
p["fill-opacity"] = opacity;
|
|
1534
|
+
}
|
|
1535
|
+
return p;
|
|
1536
|
+
}, [
|
|
1537
|
+
fillColor,
|
|
1538
|
+
fillOpacity,
|
|
1539
|
+
fillOutlineColor,
|
|
1540
|
+
fillPattern,
|
|
1541
|
+
fillTranslate,
|
|
1542
|
+
fillAntialias,
|
|
1543
|
+
opacity
|
|
1544
|
+
]);
|
|
1545
|
+
const layout = React6__namespace.useMemo(() => ({}), []);
|
|
1514
1546
|
useLayer({
|
|
1515
1547
|
id,
|
|
1516
1548
|
source,
|
|
@@ -1530,8 +1562,6 @@ var FillLayer = ({
|
|
|
1530
1562
|
return null;
|
|
1531
1563
|
};
|
|
1532
1564
|
FillLayer.displayName = "FillLayer";
|
|
1533
|
-
|
|
1534
|
-
// src/components/layers/LineLayer.tsx
|
|
1535
1565
|
var LineLayer = ({
|
|
1536
1566
|
id,
|
|
1537
1567
|
source,
|
|
@@ -1556,21 +1586,37 @@ var LineLayer = ({
|
|
|
1556
1586
|
lineOffset,
|
|
1557
1587
|
lineGradient
|
|
1558
1588
|
}) => {
|
|
1559
|
-
const paint = {
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
}
|
|
1589
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1590
|
+
const p = {};
|
|
1591
|
+
if (lineColor !== void 0) p["line-color"] = lineColor;
|
|
1592
|
+
if (lineWidth !== void 0) p["line-width"] = lineWidth;
|
|
1593
|
+
if (lineOpacity !== void 0) p["line-opacity"] = lineOpacity;
|
|
1594
|
+
if (lineBlur !== void 0) p["line-blur"] = lineBlur;
|
|
1595
|
+
if (lineDasharray !== void 0) p["line-dasharray"] = lineDasharray;
|
|
1596
|
+
if (lineGapWidth !== void 0) p["line-gap-width"] = lineGapWidth;
|
|
1597
|
+
if (lineOffset !== void 0) p["line-offset"] = lineOffset;
|
|
1598
|
+
if (lineGradient !== void 0) p["line-gradient"] = lineGradient;
|
|
1599
|
+
if (opacity !== void 0 && lineOpacity === void 0) {
|
|
1600
|
+
p["line-opacity"] = opacity;
|
|
1601
|
+
}
|
|
1602
|
+
return p;
|
|
1603
|
+
}, [
|
|
1604
|
+
lineColor,
|
|
1605
|
+
lineWidth,
|
|
1606
|
+
lineOpacity,
|
|
1607
|
+
lineBlur,
|
|
1608
|
+
lineDasharray,
|
|
1609
|
+
lineGapWidth,
|
|
1610
|
+
lineOffset,
|
|
1611
|
+
lineGradient,
|
|
1612
|
+
opacity
|
|
1613
|
+
]);
|
|
1614
|
+
const layout = React6__namespace.useMemo(() => {
|
|
1615
|
+
const l = {};
|
|
1616
|
+
if (lineCap !== void 0) l["line-cap"] = lineCap;
|
|
1617
|
+
if (lineJoin !== void 0) l["line-join"] = lineJoin;
|
|
1618
|
+
return l;
|
|
1619
|
+
}, [lineCap, lineJoin]);
|
|
1574
1620
|
useLayer({
|
|
1575
1621
|
id,
|
|
1576
1622
|
source,
|
|
@@ -1590,8 +1636,6 @@ var LineLayer = ({
|
|
|
1590
1636
|
return null;
|
|
1591
1637
|
};
|
|
1592
1638
|
LineLayer.displayName = "LineLayer";
|
|
1593
|
-
|
|
1594
|
-
// src/components/layers/CircleLayer.tsx
|
|
1595
1639
|
var CircleLayer = ({
|
|
1596
1640
|
id,
|
|
1597
1641
|
source,
|
|
@@ -1616,21 +1660,36 @@ var CircleLayer = ({
|
|
|
1616
1660
|
circlePitchScale,
|
|
1617
1661
|
circleTranslate
|
|
1618
1662
|
}) => {
|
|
1619
|
-
const paint = {
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1663
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1664
|
+
const p = {};
|
|
1665
|
+
if (circleRadius !== void 0) p["circle-radius"] = circleRadius;
|
|
1666
|
+
if (circleColor !== void 0) p["circle-color"] = circleColor;
|
|
1667
|
+
if (circleOpacity !== void 0) p["circle-opacity"] = circleOpacity;
|
|
1668
|
+
if (circleStrokeWidth !== void 0) p["circle-stroke-width"] = circleStrokeWidth;
|
|
1669
|
+
if (circleStrokeColor !== void 0) p["circle-stroke-color"] = circleStrokeColor;
|
|
1670
|
+
if (circleStrokeOpacity !== void 0) p["circle-stroke-opacity"] = circleStrokeOpacity;
|
|
1671
|
+
if (circleBlur !== void 0) p["circle-blur"] = circleBlur;
|
|
1672
|
+
if (circlePitchAlignment !== void 0) p["circle-pitch-alignment"] = circlePitchAlignment;
|
|
1673
|
+
if (circlePitchScale !== void 0) p["circle-pitch-scale"] = circlePitchScale;
|
|
1674
|
+
if (circleTranslate !== void 0) p["circle-translate"] = circleTranslate;
|
|
1675
|
+
if (opacity !== void 0 && circleOpacity === void 0) {
|
|
1676
|
+
p["circle-opacity"] = opacity;
|
|
1677
|
+
}
|
|
1678
|
+
return p;
|
|
1679
|
+
}, [
|
|
1680
|
+
circleRadius,
|
|
1681
|
+
circleColor,
|
|
1682
|
+
circleOpacity,
|
|
1683
|
+
circleStrokeWidth,
|
|
1684
|
+
circleStrokeColor,
|
|
1685
|
+
circleStrokeOpacity,
|
|
1686
|
+
circleBlur,
|
|
1687
|
+
circlePitchAlignment,
|
|
1688
|
+
circlePitchScale,
|
|
1689
|
+
circleTranslate,
|
|
1690
|
+
opacity
|
|
1691
|
+
]);
|
|
1692
|
+
const layout = React6__namespace.useMemo(() => ({}), []);
|
|
1634
1693
|
useLayer({
|
|
1635
1694
|
id,
|
|
1636
1695
|
source,
|
|
@@ -1650,8 +1709,6 @@ var CircleLayer = ({
|
|
|
1650
1709
|
return null;
|
|
1651
1710
|
};
|
|
1652
1711
|
CircleLayer.displayName = "CircleLayer";
|
|
1653
|
-
|
|
1654
|
-
// src/components/layers/SymbolLayer.tsx
|
|
1655
1712
|
var SymbolLayer = ({
|
|
1656
1713
|
id,
|
|
1657
1714
|
source,
|
|
@@ -1692,34 +1749,68 @@ var SymbolLayer = ({
|
|
|
1692
1749
|
symbolSpacing,
|
|
1693
1750
|
symbolSortKey
|
|
1694
1751
|
}) => {
|
|
1695
|
-
const paint = {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1752
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1753
|
+
const p = {};
|
|
1754
|
+
if (iconOpacity !== void 0) p["icon-opacity"] = iconOpacity;
|
|
1755
|
+
if (iconColor !== void 0) p["icon-color"] = iconColor;
|
|
1756
|
+
if (iconHaloColor !== void 0) p["icon-halo-color"] = iconHaloColor;
|
|
1757
|
+
if (iconHaloWidth !== void 0) p["icon-halo-width"] = iconHaloWidth;
|
|
1758
|
+
if (textColor !== void 0) p["text-color"] = textColor;
|
|
1759
|
+
if (textOpacity !== void 0) p["text-opacity"] = textOpacity;
|
|
1760
|
+
if (textHaloColor !== void 0) p["text-halo-color"] = textHaloColor;
|
|
1761
|
+
if (textHaloWidth !== void 0) p["text-halo-width"] = textHaloWidth;
|
|
1762
|
+
return p;
|
|
1763
|
+
}, [
|
|
1764
|
+
iconOpacity,
|
|
1765
|
+
iconColor,
|
|
1766
|
+
iconHaloColor,
|
|
1767
|
+
iconHaloWidth,
|
|
1768
|
+
textColor,
|
|
1769
|
+
textOpacity,
|
|
1770
|
+
textHaloColor,
|
|
1771
|
+
textHaloWidth
|
|
1772
|
+
]);
|
|
1773
|
+
const layout = React6__namespace.useMemo(() => {
|
|
1774
|
+
const l = {};
|
|
1775
|
+
if (iconImage !== void 0) l["icon-image"] = iconImage;
|
|
1776
|
+
if (iconSize !== void 0) l["icon-size"] = iconSize;
|
|
1777
|
+
if (iconRotate !== void 0) l["icon-rotate"] = iconRotate;
|
|
1778
|
+
if (iconOffset !== void 0) l["icon-offset"] = iconOffset;
|
|
1779
|
+
if (iconAnchor !== void 0) l["icon-anchor"] = iconAnchor;
|
|
1780
|
+
if (iconAllowOverlap !== void 0) l["icon-allow-overlap"] = iconAllowOverlap;
|
|
1781
|
+
if (iconIgnorePlacement !== void 0) l["icon-ignore-placement"] = iconIgnorePlacement;
|
|
1782
|
+
if (textField !== void 0) l["text-field"] = textField;
|
|
1783
|
+
if (textFont !== void 0) l["text-font"] = textFont;
|
|
1784
|
+
if (textSize !== void 0) l["text-size"] = textSize;
|
|
1785
|
+
if (textAnchor !== void 0) l["text-anchor"] = textAnchor;
|
|
1786
|
+
if (textOffset !== void 0) l["text-offset"] = textOffset;
|
|
1787
|
+
if (textRotate !== void 0) l["text-rotate"] = textRotate;
|
|
1788
|
+
if (textAllowOverlap !== void 0) l["text-allow-overlap"] = textAllowOverlap;
|
|
1789
|
+
if (textIgnorePlacement !== void 0) l["text-ignore-placement"] = textIgnorePlacement;
|
|
1790
|
+
if (symbolPlacement !== void 0) l["symbol-placement"] = symbolPlacement;
|
|
1791
|
+
if (symbolSpacing !== void 0) l["symbol-spacing"] = symbolSpacing;
|
|
1792
|
+
if (symbolSortKey !== void 0) l["symbol-sort-key"] = symbolSortKey;
|
|
1793
|
+
return l;
|
|
1794
|
+
}, [
|
|
1795
|
+
iconImage,
|
|
1796
|
+
iconSize,
|
|
1797
|
+
iconRotate,
|
|
1798
|
+
iconOffset,
|
|
1799
|
+
iconAnchor,
|
|
1800
|
+
iconAllowOverlap,
|
|
1801
|
+
iconIgnorePlacement,
|
|
1802
|
+
textField,
|
|
1803
|
+
textFont,
|
|
1804
|
+
textSize,
|
|
1805
|
+
textAnchor,
|
|
1806
|
+
textOffset,
|
|
1807
|
+
textRotate,
|
|
1808
|
+
textAllowOverlap,
|
|
1809
|
+
textIgnorePlacement,
|
|
1810
|
+
symbolPlacement,
|
|
1811
|
+
symbolSpacing,
|
|
1812
|
+
symbolSortKey
|
|
1813
|
+
]);
|
|
1723
1814
|
useLayer({
|
|
1724
1815
|
id,
|
|
1725
1816
|
source,
|
|
@@ -1739,8 +1830,6 @@ var SymbolLayer = ({
|
|
|
1739
1830
|
return null;
|
|
1740
1831
|
};
|
|
1741
1832
|
SymbolLayer.displayName = "SymbolLayer";
|
|
1742
|
-
|
|
1743
|
-
// src/components/layers/FillExtrusionLayer.tsx
|
|
1744
1833
|
var FillExtrusionLayer = ({
|
|
1745
1834
|
id,
|
|
1746
1835
|
source,
|
|
@@ -1762,21 +1851,33 @@ var FillExtrusionLayer = ({
|
|
|
1762
1851
|
fillExtrusionTranslate,
|
|
1763
1852
|
fillExtrusionVerticalGradient
|
|
1764
1853
|
}) => {
|
|
1765
|
-
const paint = {
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1854
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1855
|
+
const p = {};
|
|
1856
|
+
if (fillExtrusionHeight !== void 0) p["fill-extrusion-height"] = fillExtrusionHeight;
|
|
1857
|
+
if (fillExtrusionBase !== void 0) p["fill-extrusion-base"] = fillExtrusionBase;
|
|
1858
|
+
if (fillExtrusionColor !== void 0) p["fill-extrusion-color"] = fillExtrusionColor;
|
|
1859
|
+
if (fillExtrusionOpacity !== void 0) p["fill-extrusion-opacity"] = fillExtrusionOpacity;
|
|
1860
|
+
if (fillExtrusionPattern !== void 0) p["fill-extrusion-pattern"] = fillExtrusionPattern;
|
|
1861
|
+
if (fillExtrusionTranslate !== void 0)
|
|
1862
|
+
p["fill-extrusion-translate"] = fillExtrusionTranslate;
|
|
1863
|
+
if (fillExtrusionVerticalGradient !== void 0) {
|
|
1864
|
+
p["fill-extrusion-vertical-gradient"] = fillExtrusionVerticalGradient;
|
|
1865
|
+
}
|
|
1866
|
+
if (opacity !== void 0 && fillExtrusionOpacity === void 0) {
|
|
1867
|
+
p["fill-extrusion-opacity"] = opacity;
|
|
1868
|
+
}
|
|
1869
|
+
return p;
|
|
1870
|
+
}, [
|
|
1871
|
+
fillExtrusionHeight,
|
|
1872
|
+
fillExtrusionBase,
|
|
1873
|
+
fillExtrusionColor,
|
|
1874
|
+
fillExtrusionOpacity,
|
|
1875
|
+
fillExtrusionPattern,
|
|
1876
|
+
fillExtrusionTranslate,
|
|
1877
|
+
fillExtrusionVerticalGradient,
|
|
1878
|
+
opacity
|
|
1879
|
+
]);
|
|
1880
|
+
const layout = React6__namespace.useMemo(() => ({}), []);
|
|
1780
1881
|
useLayer({
|
|
1781
1882
|
id,
|
|
1782
1883
|
source,
|
|
@@ -1796,8 +1897,6 @@ var FillExtrusionLayer = ({
|
|
|
1796
1897
|
return null;
|
|
1797
1898
|
};
|
|
1798
1899
|
FillExtrusionLayer.displayName = "FillExtrusionLayer";
|
|
1799
|
-
|
|
1800
|
-
// src/components/layers/HeatmapLayer.tsx
|
|
1801
1900
|
var HeatmapLayer = ({
|
|
1802
1901
|
id,
|
|
1803
1902
|
source,
|
|
@@ -1817,16 +1916,19 @@ var HeatmapLayer = ({
|
|
|
1817
1916
|
heatmapRadius,
|
|
1818
1917
|
heatmapOpacity
|
|
1819
1918
|
}) => {
|
|
1820
|
-
const paint = {
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1919
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1920
|
+
const p = {};
|
|
1921
|
+
if (heatmapIntensity !== void 0) p["heatmap-intensity"] = heatmapIntensity;
|
|
1922
|
+
if (heatmapWeight !== void 0) p["heatmap-weight"] = heatmapWeight;
|
|
1923
|
+
if (heatmapColor !== void 0) p["heatmap-color"] = heatmapColor;
|
|
1924
|
+
if (heatmapRadius !== void 0) p["heatmap-radius"] = heatmapRadius;
|
|
1925
|
+
if (heatmapOpacity !== void 0) p["heatmap-opacity"] = heatmapOpacity;
|
|
1926
|
+
if (opacity !== void 0 && heatmapOpacity === void 0) {
|
|
1927
|
+
p["heatmap-opacity"] = opacity;
|
|
1928
|
+
}
|
|
1929
|
+
return p;
|
|
1930
|
+
}, [heatmapIntensity, heatmapWeight, heatmapColor, heatmapRadius, heatmapOpacity, opacity]);
|
|
1931
|
+
const layout = React6__namespace.useMemo(() => ({}), []);
|
|
1830
1932
|
useLayer({
|
|
1831
1933
|
id,
|
|
1832
1934
|
source,
|
|
@@ -2274,9 +2376,11 @@ var DeckOverlay = ({
|
|
|
2274
2376
|
const MapboxOverlayRef = React6__namespace.useRef(null);
|
|
2275
2377
|
React6__namespace.useEffect(() => {
|
|
2276
2378
|
if (!map || !loaded) return;
|
|
2379
|
+
let cancelled = false;
|
|
2277
2380
|
const initOverlay = async () => {
|
|
2278
2381
|
try {
|
|
2279
2382
|
const deckMapbox = await import('@deck.gl/mapbox');
|
|
2383
|
+
if (cancelled) return;
|
|
2280
2384
|
const MapboxOverlay = deckMapbox.MapboxOverlay;
|
|
2281
2385
|
MapboxOverlayRef.current = MapboxOverlay;
|
|
2282
2386
|
const overlay = new MapboxOverlay({
|
|
@@ -2291,6 +2395,7 @@ var DeckOverlay = ({
|
|
|
2291
2395
|
map.addControl(overlay);
|
|
2292
2396
|
overlayRef.current = overlay;
|
|
2293
2397
|
} catch (err) {
|
|
2398
|
+
if (cancelled) return;
|
|
2294
2399
|
console.warn(
|
|
2295
2400
|
"[maps-react] Deck.gl is not available. Install @deck.gl/core, @deck.gl/layers, and @deck.gl/mapbox to use DeckOverlay.",
|
|
2296
2401
|
err
|
|
@@ -2299,6 +2404,7 @@ var DeckOverlay = ({
|
|
|
2299
2404
|
};
|
|
2300
2405
|
initOverlay();
|
|
2301
2406
|
return () => {
|
|
2407
|
+
cancelled = true;
|
|
2302
2408
|
if (overlayRef.current && map) {
|
|
2303
2409
|
try {
|
|
2304
2410
|
map.removeControl(overlayRef.current);
|