@classic-homes/maps-react 0.1.1 → 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 +301 -180
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +302 -181
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
var maplibregl = require('maplibre-gl');
|
|
8
8
|
require('maplibre-gl/dist/maplibre-gl.css');
|
|
9
9
|
require('@classic-homes/maps-core/styles/controls.css');
|
|
10
|
+
require('@classic-homes/maps-core/styles/marker.css');
|
|
10
11
|
var mapsCore = require('@classic-homes/maps-core');
|
|
11
12
|
var ReactDOM = require('react-dom');
|
|
12
13
|
var classVarianceAuthority = require('class-variance-authority');
|
|
@@ -295,11 +296,7 @@ function useReducedMotion() {
|
|
|
295
296
|
}, []);
|
|
296
297
|
return prefersReducedMotion2;
|
|
297
298
|
}
|
|
298
|
-
var MapContext = React6__namespace.createContext(
|
|
299
|
-
map: null,
|
|
300
|
-
loaded: false,
|
|
301
|
-
controlOffsets: {}
|
|
302
|
-
});
|
|
299
|
+
var MapContext = React6__namespace.createContext(null);
|
|
303
300
|
function useMap() {
|
|
304
301
|
const context = React6__namespace.useContext(MapContext);
|
|
305
302
|
if (!context) {
|
|
@@ -378,6 +375,10 @@ var Map = React6__namespace.forwardRef(
|
|
|
378
375
|
const [, forceUpdate] = React6__namespace.useReducer((x) => x + 1, 0);
|
|
379
376
|
const prefersReducedMotion2 = useReducedMotion();
|
|
380
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;
|
|
381
382
|
const mapStyle = customStyle || themeStyle;
|
|
382
383
|
const controlOffsets = React6__namespace.useMemo(() => {
|
|
383
384
|
const offsets = {
|
|
@@ -506,12 +507,15 @@ var Map = React6__namespace.forwardRef(
|
|
|
506
507
|
animate: animation && !prefersReducedMotion2
|
|
507
508
|
});
|
|
508
509
|
}
|
|
509
|
-
|
|
510
|
+
onLoadRef.current?.({ type: "load", loaded: true });
|
|
510
511
|
});
|
|
511
512
|
map.on("error", (e) => {
|
|
512
513
|
const errorMessage = e.error?.message || "Map error";
|
|
513
|
-
|
|
514
|
-
|
|
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 });
|
|
515
519
|
});
|
|
516
520
|
return () => {
|
|
517
521
|
map.remove();
|
|
@@ -521,11 +525,16 @@ var Map = React6__namespace.forwardRef(
|
|
|
521
525
|
} catch (err) {
|
|
522
526
|
const errorMessage = err instanceof Error ? err.message : "Failed to initialize map";
|
|
523
527
|
setMapError(errorMessage);
|
|
524
|
-
|
|
528
|
+
onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
|
|
525
529
|
}
|
|
526
530
|
}, []);
|
|
531
|
+
const styleInitialized = React6__namespace.useRef(false);
|
|
527
532
|
React6__namespace.useEffect(() => {
|
|
528
533
|
if (!mapRef.current || !mapLoaded) return;
|
|
534
|
+
if (!styleInitialized.current) {
|
|
535
|
+
styleInitialized.current = true;
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
529
538
|
mapRef.current.setStyle(mapStyle);
|
|
530
539
|
}, [mapStyle, mapLoaded]);
|
|
531
540
|
React6__namespace.useEffect(() => {
|
|
@@ -716,7 +725,7 @@ var Source = ({
|
|
|
716
725
|
return;
|
|
717
726
|
}
|
|
718
727
|
const prefersReducedMotion2 = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
719
|
-
requestAnimationFrame(() => {
|
|
728
|
+
const rafHandle = requestAnimationFrame(() => {
|
|
720
729
|
if (cancelledRef.current || initialFitDone.current) return;
|
|
721
730
|
try {
|
|
722
731
|
const centerLng = (swLng + neLng) / 2;
|
|
@@ -739,6 +748,7 @@ var Source = ({
|
|
|
739
748
|
console.warn("[maps-react] Source: fitBounds failed", err);
|
|
740
749
|
}
|
|
741
750
|
});
|
|
751
|
+
return rafHandle;
|
|
742
752
|
},
|
|
743
753
|
[map]
|
|
744
754
|
);
|
|
@@ -814,18 +824,21 @@ var Source = ({
|
|
|
814
824
|
return;
|
|
815
825
|
}
|
|
816
826
|
const cancelledRef = { current: false };
|
|
827
|
+
const rafHandles = [];
|
|
817
828
|
const handleSourceData = (e) => {
|
|
818
829
|
if (cancelledRef.current) return;
|
|
819
830
|
if (e.sourceId === id && e.isSourceLoaded) {
|
|
820
831
|
map.off("sourcedata", handleSourceData);
|
|
821
|
-
performFitBounds(cancelledRef);
|
|
832
|
+
const h = performFitBounds(cancelledRef);
|
|
833
|
+
if (h !== void 0) rafHandles.push(h);
|
|
822
834
|
}
|
|
823
835
|
};
|
|
824
836
|
map.on("sourcedata", handleSourceData);
|
|
825
837
|
const handleIdle = () => {
|
|
826
838
|
if (cancelledRef.current) return;
|
|
827
839
|
map.off("idle", handleIdle);
|
|
828
|
-
performFitBounds(cancelledRef);
|
|
840
|
+
const h = performFitBounds(cancelledRef);
|
|
841
|
+
if (h !== void 0) rafHandles.push(h);
|
|
829
842
|
};
|
|
830
843
|
map.once("idle", handleIdle);
|
|
831
844
|
map.addSource(id, sourceConfig);
|
|
@@ -834,12 +847,16 @@ var Source = ({
|
|
|
834
847
|
if (source && map.isSourceLoaded(id)) {
|
|
835
848
|
map.off("sourcedata", handleSourceData);
|
|
836
849
|
map.off("idle", handleIdle);
|
|
837
|
-
performFitBounds(cancelledRef);
|
|
850
|
+
const h = performFitBounds(cancelledRef);
|
|
851
|
+
if (h !== void 0) rafHandles.push(h);
|
|
838
852
|
}
|
|
839
853
|
const cleanupListeners = () => {
|
|
840
854
|
cancelledRef.current = true;
|
|
841
855
|
map.off("sourcedata", handleSourceData);
|
|
842
856
|
map.off("idle", handleIdle);
|
|
857
|
+
for (const h of rafHandles) {
|
|
858
|
+
cancelAnimationFrame(h);
|
|
859
|
+
}
|
|
843
860
|
};
|
|
844
861
|
return () => {
|
|
845
862
|
cleanupListeners();
|
|
@@ -921,13 +938,25 @@ var Marker = React6__namespace.forwardRef(
|
|
|
921
938
|
const elementRef = React6__namespace.useRef(null);
|
|
922
939
|
const originalLngLatRef = React6__namespace.useRef();
|
|
923
940
|
const clickHandlerRef = React6__namespace.useRef(null);
|
|
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;
|
|
948
|
+
React6__namespace.useEffect(() => {
|
|
949
|
+
setMounted(true);
|
|
950
|
+
return () => setMounted(false);
|
|
951
|
+
}, []);
|
|
924
952
|
React6__namespace.useEffect(() => {
|
|
925
953
|
if (children && !elementRef.current) {
|
|
926
954
|
elementRef.current = document.createElement("div");
|
|
927
955
|
}
|
|
928
956
|
}, [children]);
|
|
929
957
|
React6__namespace.useEffect(() => {
|
|
930
|
-
if (!map || !loaded) return;
|
|
958
|
+
if (!map || !loaded || !mounted) return;
|
|
959
|
+
if (markerRef.current) return;
|
|
931
960
|
const markerOptions = {
|
|
932
961
|
color: children ? void 0 : color,
|
|
933
962
|
anchor,
|
|
@@ -944,6 +973,11 @@ var Marker = React6__namespace.forwardRef(
|
|
|
944
973
|
markerOptions.element = elementRef.current;
|
|
945
974
|
}
|
|
946
975
|
const marker = new maplibregl__default.default.Marker(markerOptions).setLngLat(coordinates).addTo(map);
|
|
976
|
+
const el = marker.getElement();
|
|
977
|
+
mapsCore.applyMarkerProtection(el);
|
|
978
|
+
if (children && elementRef.current) {
|
|
979
|
+
mapsCore.applyMarkerChildProtection(elementRef.current);
|
|
980
|
+
}
|
|
947
981
|
markerRef.current = marker;
|
|
948
982
|
if (ref) {
|
|
949
983
|
if (typeof ref === "function") {
|
|
@@ -952,12 +986,13 @@ var Marker = React6__namespace.forwardRef(
|
|
|
952
986
|
ref.current = marker;
|
|
953
987
|
}
|
|
954
988
|
}
|
|
955
|
-
|
|
989
|
+
{
|
|
956
990
|
const element = marker.getElement();
|
|
957
991
|
const handleClick = (e) => {
|
|
992
|
+
if (!onClickRef.current) return;
|
|
958
993
|
e.stopPropagation();
|
|
959
994
|
const lngLat = marker.getLngLat();
|
|
960
|
-
|
|
995
|
+
onClickRef.current({
|
|
961
996
|
type: "click",
|
|
962
997
|
markerId: id || "",
|
|
963
998
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
@@ -973,37 +1008,36 @@ var Marker = React6__namespace.forwardRef(
|
|
|
973
1008
|
originalLngLatRef.current = [lngLat.lng, lngLat.lat];
|
|
974
1009
|
});
|
|
975
1010
|
marker.on("drag", () => {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
});
|
|
984
|
-
}
|
|
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
|
+
});
|
|
985
1018
|
});
|
|
986
1019
|
marker.on("dragend", () => {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
});
|
|
995
|
-
}
|
|
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
|
+
});
|
|
996
1027
|
});
|
|
997
1028
|
}
|
|
998
1029
|
return () => {
|
|
999
|
-
if (clickHandlerRef.current) {
|
|
1000
|
-
|
|
1030
|
+
if (clickHandlerRef.current && markerRef.current) {
|
|
1031
|
+
markerRef.current.getElement().removeEventListener("click", clickHandlerRef.current);
|
|
1001
1032
|
clickHandlerRef.current = null;
|
|
1002
1033
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1034
|
+
if (markerRef.current) {
|
|
1035
|
+
mapsCore.removeMarkerProtection(markerRef.current.getElement());
|
|
1036
|
+
markerRef.current.remove();
|
|
1037
|
+
markerRef.current = null;
|
|
1038
|
+
}
|
|
1005
1039
|
};
|
|
1006
|
-
}, [map, loaded]);
|
|
1040
|
+
}, [map, loaded, mounted]);
|
|
1007
1041
|
React6__namespace.useEffect(() => {
|
|
1008
1042
|
if (markerRef.current) {
|
|
1009
1043
|
markerRef.current.setLngLat(coordinates);
|
|
@@ -1079,8 +1113,14 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1079
1113
|
}, ref) => {
|
|
1080
1114
|
const { map, loaded } = useMap();
|
|
1081
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;
|
|
1082
1122
|
const containerRef = React6__namespace.useRef(null);
|
|
1083
|
-
if (!containerRef.current) {
|
|
1123
|
+
if (!containerRef.current && typeof document !== "undefined") {
|
|
1084
1124
|
containerRef.current = document.createElement("div");
|
|
1085
1125
|
containerRef.current.className = "maplibregl-popup-content-wrapper";
|
|
1086
1126
|
}
|
|
@@ -1103,23 +1143,16 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1103
1143
|
});
|
|
1104
1144
|
popup.setDOMContent(containerRef.current);
|
|
1105
1145
|
popupRef.current = popup;
|
|
1106
|
-
if (ref) {
|
|
1107
|
-
if (typeof ref === "function") {
|
|
1108
|
-
ref(popup);
|
|
1109
|
-
} else {
|
|
1110
|
-
ref.current = popup;
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
1146
|
popup.on("open", () => {
|
|
1114
|
-
|
|
1147
|
+
onOpenRef.current?.({
|
|
1115
1148
|
type: "open",
|
|
1116
|
-
lngLat:
|
|
1149
|
+
lngLat: coordinatesRef.current
|
|
1117
1150
|
});
|
|
1118
1151
|
});
|
|
1119
1152
|
popup.on("close", () => {
|
|
1120
|
-
|
|
1153
|
+
onCloseRef.current?.({
|
|
1121
1154
|
type: "close",
|
|
1122
|
-
lngLat:
|
|
1155
|
+
lngLat: coordinatesRef.current
|
|
1123
1156
|
});
|
|
1124
1157
|
});
|
|
1125
1158
|
return () => {
|
|
@@ -1135,12 +1168,16 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1135
1168
|
anchor,
|
|
1136
1169
|
offset,
|
|
1137
1170
|
maxWidth,
|
|
1138
|
-
focusAfterOpen
|
|
1139
|
-
ref,
|
|
1140
|
-
onOpen,
|
|
1141
|
-
onClose,
|
|
1142
|
-
coordinates
|
|
1171
|
+
focusAfterOpen
|
|
1143
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]);
|
|
1144
1181
|
React6__namespace.useEffect(() => {
|
|
1145
1182
|
if (popupRef.current) {
|
|
1146
1183
|
popupRef.current.setLngLat(coordinates);
|
|
@@ -1148,10 +1185,11 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1148
1185
|
}, [coordinates]);
|
|
1149
1186
|
React6__namespace.useEffect(() => {
|
|
1150
1187
|
if (!map || !popupRef.current || !contentReady) return;
|
|
1188
|
+
let rafHandle;
|
|
1151
1189
|
if (open) {
|
|
1152
1190
|
popupRef.current.setLngLat(coordinates).addTo(map);
|
|
1153
1191
|
if (autoPan) {
|
|
1154
|
-
requestAnimationFrame(() => {
|
|
1192
|
+
rafHandle = requestAnimationFrame(() => {
|
|
1155
1193
|
if (popupRef.current && map) {
|
|
1156
1194
|
panToFitPopup(map, popupRef.current, normalizePadding(autoPanPadding));
|
|
1157
1195
|
}
|
|
@@ -1160,7 +1198,13 @@ var Popup = React6__namespace.forwardRef(
|
|
|
1160
1198
|
} else {
|
|
1161
1199
|
popupRef.current.remove();
|
|
1162
1200
|
}
|
|
1201
|
+
return () => {
|
|
1202
|
+
if (rafHandle !== void 0) {
|
|
1203
|
+
cancelAnimationFrame(rafHandle);
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1163
1206
|
}, [map, open, coordinates, autoPan, autoPanPadding, contentReady]);
|
|
1207
|
+
if (!containerRef.current) return null;
|
|
1164
1208
|
return ReactDOM__namespace.createPortal(
|
|
1165
1209
|
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: contentCallbackRef, children }),
|
|
1166
1210
|
containerRef.current
|
|
@@ -1279,7 +1323,7 @@ function useLayer({
|
|
|
1279
1323
|
}
|
|
1280
1324
|
addLayer();
|
|
1281
1325
|
function addLayer() {
|
|
1282
|
-
if (
|
|
1326
|
+
if (map.getLayer(id)) {
|
|
1283
1327
|
setLayerAdded(true);
|
|
1284
1328
|
return;
|
|
1285
1329
|
}
|
|
@@ -1313,7 +1357,7 @@ function useLayer({
|
|
|
1313
1357
|
}
|
|
1314
1358
|
}
|
|
1315
1359
|
return () => {
|
|
1316
|
-
if (map
|
|
1360
|
+
if (map) {
|
|
1317
1361
|
try {
|
|
1318
1362
|
if (map.getLayer(id)) {
|
|
1319
1363
|
map.removeLayer(id);
|
|
@@ -1323,29 +1367,23 @@ function useLayer({
|
|
|
1323
1367
|
setLayerAdded(false);
|
|
1324
1368
|
}
|
|
1325
1369
|
};
|
|
1326
|
-
}, [map, loaded, id, source, sourceLayer, type, beforeId
|
|
1370
|
+
}, [map, loaded, id, source, sourceLayer, type, beforeId]);
|
|
1327
1371
|
React6__namespace.useEffect(() => {
|
|
1328
1372
|
if (!map || !layerAdded) return;
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
} catch {
|
|
1332
|
-
}
|
|
1373
|
+
if (!map.getLayer(id)) return;
|
|
1374
|
+
map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
|
|
1333
1375
|
}, [map, id, visible, layerAdded]);
|
|
1334
1376
|
React6__namespace.useEffect(() => {
|
|
1335
1377
|
if (!map || !layerAdded) return;
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
} catch {
|
|
1341
|
-
}
|
|
1378
|
+
if (!map.getLayer(id)) return;
|
|
1379
|
+
Object.entries(paint).forEach(([key, value]) => {
|
|
1380
|
+
map.setPaintProperty(id, key, value);
|
|
1381
|
+
});
|
|
1342
1382
|
}, [map, id, paint, layerAdded]);
|
|
1343
1383
|
React6__namespace.useEffect(() => {
|
|
1344
1384
|
if (!map || !layerAdded || !filter) return;
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
} catch {
|
|
1348
|
-
}
|
|
1385
|
+
if (!map.getLayer(id)) return;
|
|
1386
|
+
map.setFilter(id, filter);
|
|
1349
1387
|
}, [map, id, filter, layerAdded]);
|
|
1350
1388
|
React6__namespace.useEffect(() => {
|
|
1351
1389
|
if (!map || !layerAdded) return;
|
|
@@ -1463,8 +1501,6 @@ function useLayer({
|
|
|
1463
1501
|
}, [map, id, source, sourceLayer, onClick, onHover, hoverThrottleMs, layerAdded]);
|
|
1464
1502
|
return { layerAdded };
|
|
1465
1503
|
}
|
|
1466
|
-
|
|
1467
|
-
// src/components/layers/FillLayer.tsx
|
|
1468
1504
|
var FillLayer = ({
|
|
1469
1505
|
id,
|
|
1470
1506
|
source,
|
|
@@ -1485,17 +1521,28 @@ var FillLayer = ({
|
|
|
1485
1521
|
fillTranslate,
|
|
1486
1522
|
fillAntialias
|
|
1487
1523
|
}) => {
|
|
1488
|
-
const paint = {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
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(() => ({}), []);
|
|
1499
1546
|
useLayer({
|
|
1500
1547
|
id,
|
|
1501
1548
|
source,
|
|
@@ -1515,8 +1562,6 @@ var FillLayer = ({
|
|
|
1515
1562
|
return null;
|
|
1516
1563
|
};
|
|
1517
1564
|
FillLayer.displayName = "FillLayer";
|
|
1518
|
-
|
|
1519
|
-
// src/components/layers/LineLayer.tsx
|
|
1520
1565
|
var LineLayer = ({
|
|
1521
1566
|
id,
|
|
1522
1567
|
source,
|
|
@@ -1541,21 +1586,37 @@ var LineLayer = ({
|
|
|
1541
1586
|
lineOffset,
|
|
1542
1587
|
lineGradient
|
|
1543
1588
|
}) => {
|
|
1544
|
-
const paint = {
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
}
|
|
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]);
|
|
1559
1620
|
useLayer({
|
|
1560
1621
|
id,
|
|
1561
1622
|
source,
|
|
@@ -1575,8 +1636,6 @@ var LineLayer = ({
|
|
|
1575
1636
|
return null;
|
|
1576
1637
|
};
|
|
1577
1638
|
LineLayer.displayName = "LineLayer";
|
|
1578
|
-
|
|
1579
|
-
// src/components/layers/CircleLayer.tsx
|
|
1580
1639
|
var CircleLayer = ({
|
|
1581
1640
|
id,
|
|
1582
1641
|
source,
|
|
@@ -1601,21 +1660,36 @@ var CircleLayer = ({
|
|
|
1601
1660
|
circlePitchScale,
|
|
1602
1661
|
circleTranslate
|
|
1603
1662
|
}) => {
|
|
1604
|
-
const paint = {
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
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(() => ({}), []);
|
|
1619
1693
|
useLayer({
|
|
1620
1694
|
id,
|
|
1621
1695
|
source,
|
|
@@ -1635,8 +1709,6 @@ var CircleLayer = ({
|
|
|
1635
1709
|
return null;
|
|
1636
1710
|
};
|
|
1637
1711
|
CircleLayer.displayName = "CircleLayer";
|
|
1638
|
-
|
|
1639
|
-
// src/components/layers/SymbolLayer.tsx
|
|
1640
1712
|
var SymbolLayer = ({
|
|
1641
1713
|
id,
|
|
1642
1714
|
source,
|
|
@@ -1677,34 +1749,68 @@ var SymbolLayer = ({
|
|
|
1677
1749
|
symbolSpacing,
|
|
1678
1750
|
symbolSortKey
|
|
1679
1751
|
}) => {
|
|
1680
|
-
const paint = {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
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
|
+
]);
|
|
1708
1814
|
useLayer({
|
|
1709
1815
|
id,
|
|
1710
1816
|
source,
|
|
@@ -1724,8 +1830,6 @@ var SymbolLayer = ({
|
|
|
1724
1830
|
return null;
|
|
1725
1831
|
};
|
|
1726
1832
|
SymbolLayer.displayName = "SymbolLayer";
|
|
1727
|
-
|
|
1728
|
-
// src/components/layers/FillExtrusionLayer.tsx
|
|
1729
1833
|
var FillExtrusionLayer = ({
|
|
1730
1834
|
id,
|
|
1731
1835
|
source,
|
|
@@ -1747,21 +1851,33 @@ var FillExtrusionLayer = ({
|
|
|
1747
1851
|
fillExtrusionTranslate,
|
|
1748
1852
|
fillExtrusionVerticalGradient
|
|
1749
1853
|
}) => {
|
|
1750
|
-
const paint = {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
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(() => ({}), []);
|
|
1765
1881
|
useLayer({
|
|
1766
1882
|
id,
|
|
1767
1883
|
source,
|
|
@@ -1781,8 +1897,6 @@ var FillExtrusionLayer = ({
|
|
|
1781
1897
|
return null;
|
|
1782
1898
|
};
|
|
1783
1899
|
FillExtrusionLayer.displayName = "FillExtrusionLayer";
|
|
1784
|
-
|
|
1785
|
-
// src/components/layers/HeatmapLayer.tsx
|
|
1786
1900
|
var HeatmapLayer = ({
|
|
1787
1901
|
id,
|
|
1788
1902
|
source,
|
|
@@ -1802,16 +1916,19 @@ var HeatmapLayer = ({
|
|
|
1802
1916
|
heatmapRadius,
|
|
1803
1917
|
heatmapOpacity
|
|
1804
1918
|
}) => {
|
|
1805
|
-
const paint = {
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
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(() => ({}), []);
|
|
1815
1932
|
useLayer({
|
|
1816
1933
|
id,
|
|
1817
1934
|
source,
|
|
@@ -2259,9 +2376,11 @@ var DeckOverlay = ({
|
|
|
2259
2376
|
const MapboxOverlayRef = React6__namespace.useRef(null);
|
|
2260
2377
|
React6__namespace.useEffect(() => {
|
|
2261
2378
|
if (!map || !loaded) return;
|
|
2379
|
+
let cancelled = false;
|
|
2262
2380
|
const initOverlay = async () => {
|
|
2263
2381
|
try {
|
|
2264
2382
|
const deckMapbox = await import('@deck.gl/mapbox');
|
|
2383
|
+
if (cancelled) return;
|
|
2265
2384
|
const MapboxOverlay = deckMapbox.MapboxOverlay;
|
|
2266
2385
|
MapboxOverlayRef.current = MapboxOverlay;
|
|
2267
2386
|
const overlay = new MapboxOverlay({
|
|
@@ -2276,6 +2395,7 @@ var DeckOverlay = ({
|
|
|
2276
2395
|
map.addControl(overlay);
|
|
2277
2396
|
overlayRef.current = overlay;
|
|
2278
2397
|
} catch (err) {
|
|
2398
|
+
if (cancelled) return;
|
|
2279
2399
|
console.warn(
|
|
2280
2400
|
"[maps-react] Deck.gl is not available. Install @deck.gl/core, @deck.gl/layers, and @deck.gl/mapbox to use DeckOverlay.",
|
|
2281
2401
|
err
|
|
@@ -2284,6 +2404,7 @@ var DeckOverlay = ({
|
|
|
2284
2404
|
};
|
|
2285
2405
|
initOverlay();
|
|
2286
2406
|
return () => {
|
|
2407
|
+
cancelled = true;
|
|
2287
2408
|
if (overlayRef.current && map) {
|
|
2288
2409
|
try {
|
|
2289
2410
|
map.removeControl(overlayRef.current);
|