@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.js
CHANGED
|
@@ -6,7 +6,8 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
6
6
|
import maplibregl from 'maplibre-gl';
|
|
7
7
|
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
8
8
|
import '@classic-homes/maps-core/styles/controls.css';
|
|
9
|
-
import
|
|
9
|
+
import '@classic-homes/maps-core/styles/marker.css';
|
|
10
|
+
import { generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, darkBasicStyle, lightBasicStyle, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, computeVerticalOffsetStyle, computePositionClasses, formatCoordinates } from '@classic-homes/maps-core';
|
|
10
11
|
export { THEME_DARK, THEME_LIGHT, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createHoverExpression, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getSelectionStyle, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, validateGeoJSON } from '@classic-homes/maps-core';
|
|
11
12
|
import * as ReactDOM from 'react-dom';
|
|
12
13
|
import { cva } from 'class-variance-authority';
|
|
@@ -271,11 +272,7 @@ function useReducedMotion() {
|
|
|
271
272
|
}, []);
|
|
272
273
|
return prefersReducedMotion2;
|
|
273
274
|
}
|
|
274
|
-
var MapContext = React6.createContext(
|
|
275
|
-
map: null,
|
|
276
|
-
loaded: false,
|
|
277
|
-
controlOffsets: {}
|
|
278
|
-
});
|
|
275
|
+
var MapContext = React6.createContext(null);
|
|
279
276
|
function useMap() {
|
|
280
277
|
const context = React6.useContext(MapContext);
|
|
281
278
|
if (!context) {
|
|
@@ -354,6 +351,10 @@ var Map = React6.forwardRef(
|
|
|
354
351
|
const [, forceUpdate] = React6.useReducer((x) => x + 1, 0);
|
|
355
352
|
const prefersReducedMotion2 = useReducedMotion();
|
|
356
353
|
const { style: themeStyle } = useMapTheme(themePref);
|
|
354
|
+
const onLoadRef = React6.useRef(onLoad);
|
|
355
|
+
onLoadRef.current = onLoad;
|
|
356
|
+
const onErrorRef = React6.useRef(onError);
|
|
357
|
+
onErrorRef.current = onError;
|
|
357
358
|
const mapStyle = customStyle || themeStyle;
|
|
358
359
|
const controlOffsets = React6.useMemo(() => {
|
|
359
360
|
const offsets = {
|
|
@@ -482,12 +483,15 @@ var Map = React6.forwardRef(
|
|
|
482
483
|
animate: animation && !prefersReducedMotion2
|
|
483
484
|
});
|
|
484
485
|
}
|
|
485
|
-
|
|
486
|
+
onLoadRef.current?.({ type: "load", loaded: true });
|
|
486
487
|
});
|
|
487
488
|
map.on("error", (e) => {
|
|
488
489
|
const errorMessage = e.error?.message || "Map error";
|
|
489
|
-
|
|
490
|
-
|
|
490
|
+
const isTransient = errorMessage.includes("non-existing layer") || errorMessage.includes("Cannot filter");
|
|
491
|
+
if (!isTransient) {
|
|
492
|
+
setMapError(errorMessage);
|
|
493
|
+
}
|
|
494
|
+
onErrorRef.current?.({ type: "error", message: errorMessage, error: e.error });
|
|
491
495
|
});
|
|
492
496
|
return () => {
|
|
493
497
|
map.remove();
|
|
@@ -497,11 +501,16 @@ var Map = React6.forwardRef(
|
|
|
497
501
|
} catch (err) {
|
|
498
502
|
const errorMessage = err instanceof Error ? err.message : "Failed to initialize map";
|
|
499
503
|
setMapError(errorMessage);
|
|
500
|
-
|
|
504
|
+
onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
|
|
501
505
|
}
|
|
502
506
|
}, []);
|
|
507
|
+
const styleInitialized = React6.useRef(false);
|
|
503
508
|
React6.useEffect(() => {
|
|
504
509
|
if (!mapRef.current || !mapLoaded) return;
|
|
510
|
+
if (!styleInitialized.current) {
|
|
511
|
+
styleInitialized.current = true;
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
505
514
|
mapRef.current.setStyle(mapStyle);
|
|
506
515
|
}, [mapStyle, mapLoaded]);
|
|
507
516
|
React6.useEffect(() => {
|
|
@@ -692,7 +701,7 @@ var Source = ({
|
|
|
692
701
|
return;
|
|
693
702
|
}
|
|
694
703
|
const prefersReducedMotion2 = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
695
|
-
requestAnimationFrame(() => {
|
|
704
|
+
const rafHandle = requestAnimationFrame(() => {
|
|
696
705
|
if (cancelledRef.current || initialFitDone.current) return;
|
|
697
706
|
try {
|
|
698
707
|
const centerLng = (swLng + neLng) / 2;
|
|
@@ -715,6 +724,7 @@ var Source = ({
|
|
|
715
724
|
console.warn("[maps-react] Source: fitBounds failed", err);
|
|
716
725
|
}
|
|
717
726
|
});
|
|
727
|
+
return rafHandle;
|
|
718
728
|
},
|
|
719
729
|
[map]
|
|
720
730
|
);
|
|
@@ -790,18 +800,21 @@ var Source = ({
|
|
|
790
800
|
return;
|
|
791
801
|
}
|
|
792
802
|
const cancelledRef = { current: false };
|
|
803
|
+
const rafHandles = [];
|
|
793
804
|
const handleSourceData = (e) => {
|
|
794
805
|
if (cancelledRef.current) return;
|
|
795
806
|
if (e.sourceId === id && e.isSourceLoaded) {
|
|
796
807
|
map.off("sourcedata", handleSourceData);
|
|
797
|
-
performFitBounds(cancelledRef);
|
|
808
|
+
const h = performFitBounds(cancelledRef);
|
|
809
|
+
if (h !== void 0) rafHandles.push(h);
|
|
798
810
|
}
|
|
799
811
|
};
|
|
800
812
|
map.on("sourcedata", handleSourceData);
|
|
801
813
|
const handleIdle = () => {
|
|
802
814
|
if (cancelledRef.current) return;
|
|
803
815
|
map.off("idle", handleIdle);
|
|
804
|
-
performFitBounds(cancelledRef);
|
|
816
|
+
const h = performFitBounds(cancelledRef);
|
|
817
|
+
if (h !== void 0) rafHandles.push(h);
|
|
805
818
|
};
|
|
806
819
|
map.once("idle", handleIdle);
|
|
807
820
|
map.addSource(id, sourceConfig);
|
|
@@ -810,12 +823,16 @@ var Source = ({
|
|
|
810
823
|
if (source && map.isSourceLoaded(id)) {
|
|
811
824
|
map.off("sourcedata", handleSourceData);
|
|
812
825
|
map.off("idle", handleIdle);
|
|
813
|
-
performFitBounds(cancelledRef);
|
|
826
|
+
const h = performFitBounds(cancelledRef);
|
|
827
|
+
if (h !== void 0) rafHandles.push(h);
|
|
814
828
|
}
|
|
815
829
|
const cleanupListeners = () => {
|
|
816
830
|
cancelledRef.current = true;
|
|
817
831
|
map.off("sourcedata", handleSourceData);
|
|
818
832
|
map.off("idle", handleIdle);
|
|
833
|
+
for (const h of rafHandles) {
|
|
834
|
+
cancelAnimationFrame(h);
|
|
835
|
+
}
|
|
819
836
|
};
|
|
820
837
|
return () => {
|
|
821
838
|
cleanupListeners();
|
|
@@ -897,13 +914,25 @@ var Marker = React6.forwardRef(
|
|
|
897
914
|
const elementRef = React6.useRef(null);
|
|
898
915
|
const originalLngLatRef = React6.useRef();
|
|
899
916
|
const clickHandlerRef = React6.useRef(null);
|
|
917
|
+
const [mounted, setMounted] = React6.useState(false);
|
|
918
|
+
const onClickRef = React6.useRef(onClick);
|
|
919
|
+
onClickRef.current = onClick;
|
|
920
|
+
const onDragRef = React6.useRef(onDrag);
|
|
921
|
+
onDragRef.current = onDrag;
|
|
922
|
+
const onDragEndRef = React6.useRef(onDragEnd);
|
|
923
|
+
onDragEndRef.current = onDragEnd;
|
|
924
|
+
React6.useEffect(() => {
|
|
925
|
+
setMounted(true);
|
|
926
|
+
return () => setMounted(false);
|
|
927
|
+
}, []);
|
|
900
928
|
React6.useEffect(() => {
|
|
901
929
|
if (children && !elementRef.current) {
|
|
902
930
|
elementRef.current = document.createElement("div");
|
|
903
931
|
}
|
|
904
932
|
}, [children]);
|
|
905
933
|
React6.useEffect(() => {
|
|
906
|
-
if (!map || !loaded) return;
|
|
934
|
+
if (!map || !loaded || !mounted) return;
|
|
935
|
+
if (markerRef.current) return;
|
|
907
936
|
const markerOptions = {
|
|
908
937
|
color: children ? void 0 : color,
|
|
909
938
|
anchor,
|
|
@@ -920,6 +949,11 @@ var Marker = React6.forwardRef(
|
|
|
920
949
|
markerOptions.element = elementRef.current;
|
|
921
950
|
}
|
|
922
951
|
const marker = new maplibregl.Marker(markerOptions).setLngLat(coordinates).addTo(map);
|
|
952
|
+
const el = marker.getElement();
|
|
953
|
+
applyMarkerProtection(el);
|
|
954
|
+
if (children && elementRef.current) {
|
|
955
|
+
applyMarkerChildProtection(elementRef.current);
|
|
956
|
+
}
|
|
923
957
|
markerRef.current = marker;
|
|
924
958
|
if (ref) {
|
|
925
959
|
if (typeof ref === "function") {
|
|
@@ -928,12 +962,13 @@ var Marker = React6.forwardRef(
|
|
|
928
962
|
ref.current = marker;
|
|
929
963
|
}
|
|
930
964
|
}
|
|
931
|
-
|
|
965
|
+
{
|
|
932
966
|
const element = marker.getElement();
|
|
933
967
|
const handleClick = (e) => {
|
|
968
|
+
if (!onClickRef.current) return;
|
|
934
969
|
e.stopPropagation();
|
|
935
970
|
const lngLat = marker.getLngLat();
|
|
936
|
-
|
|
971
|
+
onClickRef.current({
|
|
937
972
|
type: "click",
|
|
938
973
|
markerId: id || "",
|
|
939
974
|
lngLat: [lngLat.lng, lngLat.lat],
|
|
@@ -949,37 +984,36 @@ var Marker = React6.forwardRef(
|
|
|
949
984
|
originalLngLatRef.current = [lngLat.lng, lngLat.lat];
|
|
950
985
|
});
|
|
951
986
|
marker.on("drag", () => {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
});
|
|
960
|
-
}
|
|
987
|
+
const lngLat = marker.getLngLat();
|
|
988
|
+
onDragRef.current?.({
|
|
989
|
+
type: "drag",
|
|
990
|
+
markerId: id || "",
|
|
991
|
+
lngLat: [lngLat.lng, lngLat.lat],
|
|
992
|
+
originalLngLat: originalLngLatRef.current
|
|
993
|
+
});
|
|
961
994
|
});
|
|
962
995
|
marker.on("dragend", () => {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
});
|
|
971
|
-
}
|
|
996
|
+
const lngLat = marker.getLngLat();
|
|
997
|
+
onDragEndRef.current?.({
|
|
998
|
+
type: "dragend",
|
|
999
|
+
markerId: id || "",
|
|
1000
|
+
lngLat: [lngLat.lng, lngLat.lat],
|
|
1001
|
+
originalLngLat: originalLngLatRef.current
|
|
1002
|
+
});
|
|
972
1003
|
});
|
|
973
1004
|
}
|
|
974
1005
|
return () => {
|
|
975
|
-
if (clickHandlerRef.current) {
|
|
976
|
-
|
|
1006
|
+
if (clickHandlerRef.current && markerRef.current) {
|
|
1007
|
+
markerRef.current.getElement().removeEventListener("click", clickHandlerRef.current);
|
|
977
1008
|
clickHandlerRef.current = null;
|
|
978
1009
|
}
|
|
979
|
-
|
|
980
|
-
|
|
1010
|
+
if (markerRef.current) {
|
|
1011
|
+
removeMarkerProtection(markerRef.current.getElement());
|
|
1012
|
+
markerRef.current.remove();
|
|
1013
|
+
markerRef.current = null;
|
|
1014
|
+
}
|
|
981
1015
|
};
|
|
982
|
-
}, [map, loaded]);
|
|
1016
|
+
}, [map, loaded, mounted]);
|
|
983
1017
|
React6.useEffect(() => {
|
|
984
1018
|
if (markerRef.current) {
|
|
985
1019
|
markerRef.current.setLngLat(coordinates);
|
|
@@ -1055,8 +1089,14 @@ var Popup = React6.forwardRef(
|
|
|
1055
1089
|
}, ref) => {
|
|
1056
1090
|
const { map, loaded } = useMap();
|
|
1057
1091
|
const popupRef = React6.useRef(null);
|
|
1092
|
+
const onOpenRef = React6.useRef(onOpen);
|
|
1093
|
+
onOpenRef.current = onOpen;
|
|
1094
|
+
const onCloseRef = React6.useRef(onClose);
|
|
1095
|
+
onCloseRef.current = onClose;
|
|
1096
|
+
const coordinatesRef = React6.useRef(coordinates);
|
|
1097
|
+
coordinatesRef.current = coordinates;
|
|
1058
1098
|
const containerRef = React6.useRef(null);
|
|
1059
|
-
if (!containerRef.current) {
|
|
1099
|
+
if (!containerRef.current && typeof document !== "undefined") {
|
|
1060
1100
|
containerRef.current = document.createElement("div");
|
|
1061
1101
|
containerRef.current.className = "maplibregl-popup-content-wrapper";
|
|
1062
1102
|
}
|
|
@@ -1079,23 +1119,16 @@ var Popup = React6.forwardRef(
|
|
|
1079
1119
|
});
|
|
1080
1120
|
popup.setDOMContent(containerRef.current);
|
|
1081
1121
|
popupRef.current = popup;
|
|
1082
|
-
if (ref) {
|
|
1083
|
-
if (typeof ref === "function") {
|
|
1084
|
-
ref(popup);
|
|
1085
|
-
} else {
|
|
1086
|
-
ref.current = popup;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
1122
|
popup.on("open", () => {
|
|
1090
|
-
|
|
1123
|
+
onOpenRef.current?.({
|
|
1091
1124
|
type: "open",
|
|
1092
|
-
lngLat:
|
|
1125
|
+
lngLat: coordinatesRef.current
|
|
1093
1126
|
});
|
|
1094
1127
|
});
|
|
1095
1128
|
popup.on("close", () => {
|
|
1096
|
-
|
|
1129
|
+
onCloseRef.current?.({
|
|
1097
1130
|
type: "close",
|
|
1098
|
-
lngLat:
|
|
1131
|
+
lngLat: coordinatesRef.current
|
|
1099
1132
|
});
|
|
1100
1133
|
});
|
|
1101
1134
|
return () => {
|
|
@@ -1111,12 +1144,16 @@ var Popup = React6.forwardRef(
|
|
|
1111
1144
|
anchor,
|
|
1112
1145
|
offset,
|
|
1113
1146
|
maxWidth,
|
|
1114
|
-
focusAfterOpen
|
|
1115
|
-
ref,
|
|
1116
|
-
onOpen,
|
|
1117
|
-
onClose,
|
|
1118
|
-
coordinates
|
|
1147
|
+
focusAfterOpen
|
|
1119
1148
|
]);
|
|
1149
|
+
React6.useEffect(() => {
|
|
1150
|
+
if (!popupRef.current || !ref) return;
|
|
1151
|
+
if (typeof ref === "function") {
|
|
1152
|
+
ref(popupRef.current);
|
|
1153
|
+
} else {
|
|
1154
|
+
ref.current = popupRef.current;
|
|
1155
|
+
}
|
|
1156
|
+
}, [ref]);
|
|
1120
1157
|
React6.useEffect(() => {
|
|
1121
1158
|
if (popupRef.current) {
|
|
1122
1159
|
popupRef.current.setLngLat(coordinates);
|
|
@@ -1124,10 +1161,11 @@ var Popup = React6.forwardRef(
|
|
|
1124
1161
|
}, [coordinates]);
|
|
1125
1162
|
React6.useEffect(() => {
|
|
1126
1163
|
if (!map || !popupRef.current || !contentReady) return;
|
|
1164
|
+
let rafHandle;
|
|
1127
1165
|
if (open) {
|
|
1128
1166
|
popupRef.current.setLngLat(coordinates).addTo(map);
|
|
1129
1167
|
if (autoPan) {
|
|
1130
|
-
requestAnimationFrame(() => {
|
|
1168
|
+
rafHandle = requestAnimationFrame(() => {
|
|
1131
1169
|
if (popupRef.current && map) {
|
|
1132
1170
|
panToFitPopup(map, popupRef.current, normalizePadding(autoPanPadding));
|
|
1133
1171
|
}
|
|
@@ -1136,7 +1174,13 @@ var Popup = React6.forwardRef(
|
|
|
1136
1174
|
} else {
|
|
1137
1175
|
popupRef.current.remove();
|
|
1138
1176
|
}
|
|
1177
|
+
return () => {
|
|
1178
|
+
if (rafHandle !== void 0) {
|
|
1179
|
+
cancelAnimationFrame(rafHandle);
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1139
1182
|
}, [map, open, coordinates, autoPan, autoPanPadding, contentReady]);
|
|
1183
|
+
if (!containerRef.current) return null;
|
|
1140
1184
|
return ReactDOM.createPortal(
|
|
1141
1185
|
/* @__PURE__ */ jsx("div", { ref: contentCallbackRef, children }),
|
|
1142
1186
|
containerRef.current
|
|
@@ -1255,7 +1299,7 @@ function useLayer({
|
|
|
1255
1299
|
}
|
|
1256
1300
|
addLayer();
|
|
1257
1301
|
function addLayer() {
|
|
1258
|
-
if (
|
|
1302
|
+
if (map.getLayer(id)) {
|
|
1259
1303
|
setLayerAdded(true);
|
|
1260
1304
|
return;
|
|
1261
1305
|
}
|
|
@@ -1289,7 +1333,7 @@ function useLayer({
|
|
|
1289
1333
|
}
|
|
1290
1334
|
}
|
|
1291
1335
|
return () => {
|
|
1292
|
-
if (map
|
|
1336
|
+
if (map) {
|
|
1293
1337
|
try {
|
|
1294
1338
|
if (map.getLayer(id)) {
|
|
1295
1339
|
map.removeLayer(id);
|
|
@@ -1299,29 +1343,23 @@ function useLayer({
|
|
|
1299
1343
|
setLayerAdded(false);
|
|
1300
1344
|
}
|
|
1301
1345
|
};
|
|
1302
|
-
}, [map, loaded, id, source, sourceLayer, type, beforeId
|
|
1346
|
+
}, [map, loaded, id, source, sourceLayer, type, beforeId]);
|
|
1303
1347
|
React6.useEffect(() => {
|
|
1304
1348
|
if (!map || !layerAdded) return;
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
} catch {
|
|
1308
|
-
}
|
|
1349
|
+
if (!map.getLayer(id)) return;
|
|
1350
|
+
map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
|
|
1309
1351
|
}, [map, id, visible, layerAdded]);
|
|
1310
1352
|
React6.useEffect(() => {
|
|
1311
1353
|
if (!map || !layerAdded) return;
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
} catch {
|
|
1317
|
-
}
|
|
1354
|
+
if (!map.getLayer(id)) return;
|
|
1355
|
+
Object.entries(paint).forEach(([key, value]) => {
|
|
1356
|
+
map.setPaintProperty(id, key, value);
|
|
1357
|
+
});
|
|
1318
1358
|
}, [map, id, paint, layerAdded]);
|
|
1319
1359
|
React6.useEffect(() => {
|
|
1320
1360
|
if (!map || !layerAdded || !filter) return;
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
} catch {
|
|
1324
|
-
}
|
|
1361
|
+
if (!map.getLayer(id)) return;
|
|
1362
|
+
map.setFilter(id, filter);
|
|
1325
1363
|
}, [map, id, filter, layerAdded]);
|
|
1326
1364
|
React6.useEffect(() => {
|
|
1327
1365
|
if (!map || !layerAdded) return;
|
|
@@ -1439,8 +1477,6 @@ function useLayer({
|
|
|
1439
1477
|
}, [map, id, source, sourceLayer, onClick, onHover, hoverThrottleMs, layerAdded]);
|
|
1440
1478
|
return { layerAdded };
|
|
1441
1479
|
}
|
|
1442
|
-
|
|
1443
|
-
// src/components/layers/FillLayer.tsx
|
|
1444
1480
|
var FillLayer = ({
|
|
1445
1481
|
id,
|
|
1446
1482
|
source,
|
|
@@ -1461,17 +1497,28 @@ var FillLayer = ({
|
|
|
1461
1497
|
fillTranslate,
|
|
1462
1498
|
fillAntialias
|
|
1463
1499
|
}) => {
|
|
1464
|
-
const paint = {
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1500
|
+
const paint = React6.useMemo(() => {
|
|
1501
|
+
const p = {};
|
|
1502
|
+
if (fillColor !== void 0) p["fill-color"] = fillColor;
|
|
1503
|
+
if (fillOpacity !== void 0) p["fill-opacity"] = fillOpacity;
|
|
1504
|
+
if (fillOutlineColor !== void 0) p["fill-outline-color"] = fillOutlineColor;
|
|
1505
|
+
if (fillPattern !== void 0) p["fill-pattern"] = fillPattern;
|
|
1506
|
+
if (fillTranslate !== void 0) p["fill-translate"] = fillTranslate;
|
|
1507
|
+
if (fillAntialias !== void 0) p["fill-antialias"] = fillAntialias;
|
|
1508
|
+
if (opacity !== void 0 && fillOpacity === void 0) {
|
|
1509
|
+
p["fill-opacity"] = opacity;
|
|
1510
|
+
}
|
|
1511
|
+
return p;
|
|
1512
|
+
}, [
|
|
1513
|
+
fillColor,
|
|
1514
|
+
fillOpacity,
|
|
1515
|
+
fillOutlineColor,
|
|
1516
|
+
fillPattern,
|
|
1517
|
+
fillTranslate,
|
|
1518
|
+
fillAntialias,
|
|
1519
|
+
opacity
|
|
1520
|
+
]);
|
|
1521
|
+
const layout = React6.useMemo(() => ({}), []);
|
|
1475
1522
|
useLayer({
|
|
1476
1523
|
id,
|
|
1477
1524
|
source,
|
|
@@ -1491,8 +1538,6 @@ var FillLayer = ({
|
|
|
1491
1538
|
return null;
|
|
1492
1539
|
};
|
|
1493
1540
|
FillLayer.displayName = "FillLayer";
|
|
1494
|
-
|
|
1495
|
-
// src/components/layers/LineLayer.tsx
|
|
1496
1541
|
var LineLayer = ({
|
|
1497
1542
|
id,
|
|
1498
1543
|
source,
|
|
@@ -1517,21 +1562,37 @@ var LineLayer = ({
|
|
|
1517
1562
|
lineOffset,
|
|
1518
1563
|
lineGradient
|
|
1519
1564
|
}) => {
|
|
1520
|
-
const paint = {
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
}
|
|
1565
|
+
const paint = React6.useMemo(() => {
|
|
1566
|
+
const p = {};
|
|
1567
|
+
if (lineColor !== void 0) p["line-color"] = lineColor;
|
|
1568
|
+
if (lineWidth !== void 0) p["line-width"] = lineWidth;
|
|
1569
|
+
if (lineOpacity !== void 0) p["line-opacity"] = lineOpacity;
|
|
1570
|
+
if (lineBlur !== void 0) p["line-blur"] = lineBlur;
|
|
1571
|
+
if (lineDasharray !== void 0) p["line-dasharray"] = lineDasharray;
|
|
1572
|
+
if (lineGapWidth !== void 0) p["line-gap-width"] = lineGapWidth;
|
|
1573
|
+
if (lineOffset !== void 0) p["line-offset"] = lineOffset;
|
|
1574
|
+
if (lineGradient !== void 0) p["line-gradient"] = lineGradient;
|
|
1575
|
+
if (opacity !== void 0 && lineOpacity === void 0) {
|
|
1576
|
+
p["line-opacity"] = opacity;
|
|
1577
|
+
}
|
|
1578
|
+
return p;
|
|
1579
|
+
}, [
|
|
1580
|
+
lineColor,
|
|
1581
|
+
lineWidth,
|
|
1582
|
+
lineOpacity,
|
|
1583
|
+
lineBlur,
|
|
1584
|
+
lineDasharray,
|
|
1585
|
+
lineGapWidth,
|
|
1586
|
+
lineOffset,
|
|
1587
|
+
lineGradient,
|
|
1588
|
+
opacity
|
|
1589
|
+
]);
|
|
1590
|
+
const layout = React6.useMemo(() => {
|
|
1591
|
+
const l = {};
|
|
1592
|
+
if (lineCap !== void 0) l["line-cap"] = lineCap;
|
|
1593
|
+
if (lineJoin !== void 0) l["line-join"] = lineJoin;
|
|
1594
|
+
return l;
|
|
1595
|
+
}, [lineCap, lineJoin]);
|
|
1535
1596
|
useLayer({
|
|
1536
1597
|
id,
|
|
1537
1598
|
source,
|
|
@@ -1551,8 +1612,6 @@ var LineLayer = ({
|
|
|
1551
1612
|
return null;
|
|
1552
1613
|
};
|
|
1553
1614
|
LineLayer.displayName = "LineLayer";
|
|
1554
|
-
|
|
1555
|
-
// src/components/layers/CircleLayer.tsx
|
|
1556
1615
|
var CircleLayer = ({
|
|
1557
1616
|
id,
|
|
1558
1617
|
source,
|
|
@@ -1577,21 +1636,36 @@ var CircleLayer = ({
|
|
|
1577
1636
|
circlePitchScale,
|
|
1578
1637
|
circleTranslate
|
|
1579
1638
|
}) => {
|
|
1580
|
-
const paint = {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1639
|
+
const paint = React6.useMemo(() => {
|
|
1640
|
+
const p = {};
|
|
1641
|
+
if (circleRadius !== void 0) p["circle-radius"] = circleRadius;
|
|
1642
|
+
if (circleColor !== void 0) p["circle-color"] = circleColor;
|
|
1643
|
+
if (circleOpacity !== void 0) p["circle-opacity"] = circleOpacity;
|
|
1644
|
+
if (circleStrokeWidth !== void 0) p["circle-stroke-width"] = circleStrokeWidth;
|
|
1645
|
+
if (circleStrokeColor !== void 0) p["circle-stroke-color"] = circleStrokeColor;
|
|
1646
|
+
if (circleStrokeOpacity !== void 0) p["circle-stroke-opacity"] = circleStrokeOpacity;
|
|
1647
|
+
if (circleBlur !== void 0) p["circle-blur"] = circleBlur;
|
|
1648
|
+
if (circlePitchAlignment !== void 0) p["circle-pitch-alignment"] = circlePitchAlignment;
|
|
1649
|
+
if (circlePitchScale !== void 0) p["circle-pitch-scale"] = circlePitchScale;
|
|
1650
|
+
if (circleTranslate !== void 0) p["circle-translate"] = circleTranslate;
|
|
1651
|
+
if (opacity !== void 0 && circleOpacity === void 0) {
|
|
1652
|
+
p["circle-opacity"] = opacity;
|
|
1653
|
+
}
|
|
1654
|
+
return p;
|
|
1655
|
+
}, [
|
|
1656
|
+
circleRadius,
|
|
1657
|
+
circleColor,
|
|
1658
|
+
circleOpacity,
|
|
1659
|
+
circleStrokeWidth,
|
|
1660
|
+
circleStrokeColor,
|
|
1661
|
+
circleStrokeOpacity,
|
|
1662
|
+
circleBlur,
|
|
1663
|
+
circlePitchAlignment,
|
|
1664
|
+
circlePitchScale,
|
|
1665
|
+
circleTranslate,
|
|
1666
|
+
opacity
|
|
1667
|
+
]);
|
|
1668
|
+
const layout = React6.useMemo(() => ({}), []);
|
|
1595
1669
|
useLayer({
|
|
1596
1670
|
id,
|
|
1597
1671
|
source,
|
|
@@ -1611,8 +1685,6 @@ var CircleLayer = ({
|
|
|
1611
1685
|
return null;
|
|
1612
1686
|
};
|
|
1613
1687
|
CircleLayer.displayName = "CircleLayer";
|
|
1614
|
-
|
|
1615
|
-
// src/components/layers/SymbolLayer.tsx
|
|
1616
1688
|
var SymbolLayer = ({
|
|
1617
1689
|
id,
|
|
1618
1690
|
source,
|
|
@@ -1653,34 +1725,68 @@ var SymbolLayer = ({
|
|
|
1653
1725
|
symbolSpacing,
|
|
1654
1726
|
symbolSortKey
|
|
1655
1727
|
}) => {
|
|
1656
|
-
const paint = {
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1728
|
+
const paint = React6.useMemo(() => {
|
|
1729
|
+
const p = {};
|
|
1730
|
+
if (iconOpacity !== void 0) p["icon-opacity"] = iconOpacity;
|
|
1731
|
+
if (iconColor !== void 0) p["icon-color"] = iconColor;
|
|
1732
|
+
if (iconHaloColor !== void 0) p["icon-halo-color"] = iconHaloColor;
|
|
1733
|
+
if (iconHaloWidth !== void 0) p["icon-halo-width"] = iconHaloWidth;
|
|
1734
|
+
if (textColor !== void 0) p["text-color"] = textColor;
|
|
1735
|
+
if (textOpacity !== void 0) p["text-opacity"] = textOpacity;
|
|
1736
|
+
if (textHaloColor !== void 0) p["text-halo-color"] = textHaloColor;
|
|
1737
|
+
if (textHaloWidth !== void 0) p["text-halo-width"] = textHaloWidth;
|
|
1738
|
+
return p;
|
|
1739
|
+
}, [
|
|
1740
|
+
iconOpacity,
|
|
1741
|
+
iconColor,
|
|
1742
|
+
iconHaloColor,
|
|
1743
|
+
iconHaloWidth,
|
|
1744
|
+
textColor,
|
|
1745
|
+
textOpacity,
|
|
1746
|
+
textHaloColor,
|
|
1747
|
+
textHaloWidth
|
|
1748
|
+
]);
|
|
1749
|
+
const layout = React6.useMemo(() => {
|
|
1750
|
+
const l = {};
|
|
1751
|
+
if (iconImage !== void 0) l["icon-image"] = iconImage;
|
|
1752
|
+
if (iconSize !== void 0) l["icon-size"] = iconSize;
|
|
1753
|
+
if (iconRotate !== void 0) l["icon-rotate"] = iconRotate;
|
|
1754
|
+
if (iconOffset !== void 0) l["icon-offset"] = iconOffset;
|
|
1755
|
+
if (iconAnchor !== void 0) l["icon-anchor"] = iconAnchor;
|
|
1756
|
+
if (iconAllowOverlap !== void 0) l["icon-allow-overlap"] = iconAllowOverlap;
|
|
1757
|
+
if (iconIgnorePlacement !== void 0) l["icon-ignore-placement"] = iconIgnorePlacement;
|
|
1758
|
+
if (textField !== void 0) l["text-field"] = textField;
|
|
1759
|
+
if (textFont !== void 0) l["text-font"] = textFont;
|
|
1760
|
+
if (textSize !== void 0) l["text-size"] = textSize;
|
|
1761
|
+
if (textAnchor !== void 0) l["text-anchor"] = textAnchor;
|
|
1762
|
+
if (textOffset !== void 0) l["text-offset"] = textOffset;
|
|
1763
|
+
if (textRotate !== void 0) l["text-rotate"] = textRotate;
|
|
1764
|
+
if (textAllowOverlap !== void 0) l["text-allow-overlap"] = textAllowOverlap;
|
|
1765
|
+
if (textIgnorePlacement !== void 0) l["text-ignore-placement"] = textIgnorePlacement;
|
|
1766
|
+
if (symbolPlacement !== void 0) l["symbol-placement"] = symbolPlacement;
|
|
1767
|
+
if (symbolSpacing !== void 0) l["symbol-spacing"] = symbolSpacing;
|
|
1768
|
+
if (symbolSortKey !== void 0) l["symbol-sort-key"] = symbolSortKey;
|
|
1769
|
+
return l;
|
|
1770
|
+
}, [
|
|
1771
|
+
iconImage,
|
|
1772
|
+
iconSize,
|
|
1773
|
+
iconRotate,
|
|
1774
|
+
iconOffset,
|
|
1775
|
+
iconAnchor,
|
|
1776
|
+
iconAllowOverlap,
|
|
1777
|
+
iconIgnorePlacement,
|
|
1778
|
+
textField,
|
|
1779
|
+
textFont,
|
|
1780
|
+
textSize,
|
|
1781
|
+
textAnchor,
|
|
1782
|
+
textOffset,
|
|
1783
|
+
textRotate,
|
|
1784
|
+
textAllowOverlap,
|
|
1785
|
+
textIgnorePlacement,
|
|
1786
|
+
symbolPlacement,
|
|
1787
|
+
symbolSpacing,
|
|
1788
|
+
symbolSortKey
|
|
1789
|
+
]);
|
|
1684
1790
|
useLayer({
|
|
1685
1791
|
id,
|
|
1686
1792
|
source,
|
|
@@ -1700,8 +1806,6 @@ var SymbolLayer = ({
|
|
|
1700
1806
|
return null;
|
|
1701
1807
|
};
|
|
1702
1808
|
SymbolLayer.displayName = "SymbolLayer";
|
|
1703
|
-
|
|
1704
|
-
// src/components/layers/FillExtrusionLayer.tsx
|
|
1705
1809
|
var FillExtrusionLayer = ({
|
|
1706
1810
|
id,
|
|
1707
1811
|
source,
|
|
@@ -1723,21 +1827,33 @@ var FillExtrusionLayer = ({
|
|
|
1723
1827
|
fillExtrusionTranslate,
|
|
1724
1828
|
fillExtrusionVerticalGradient
|
|
1725
1829
|
}) => {
|
|
1726
|
-
const paint = {
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1830
|
+
const paint = React6.useMemo(() => {
|
|
1831
|
+
const p = {};
|
|
1832
|
+
if (fillExtrusionHeight !== void 0) p["fill-extrusion-height"] = fillExtrusionHeight;
|
|
1833
|
+
if (fillExtrusionBase !== void 0) p["fill-extrusion-base"] = fillExtrusionBase;
|
|
1834
|
+
if (fillExtrusionColor !== void 0) p["fill-extrusion-color"] = fillExtrusionColor;
|
|
1835
|
+
if (fillExtrusionOpacity !== void 0) p["fill-extrusion-opacity"] = fillExtrusionOpacity;
|
|
1836
|
+
if (fillExtrusionPattern !== void 0) p["fill-extrusion-pattern"] = fillExtrusionPattern;
|
|
1837
|
+
if (fillExtrusionTranslate !== void 0)
|
|
1838
|
+
p["fill-extrusion-translate"] = fillExtrusionTranslate;
|
|
1839
|
+
if (fillExtrusionVerticalGradient !== void 0) {
|
|
1840
|
+
p["fill-extrusion-vertical-gradient"] = fillExtrusionVerticalGradient;
|
|
1841
|
+
}
|
|
1842
|
+
if (opacity !== void 0 && fillExtrusionOpacity === void 0) {
|
|
1843
|
+
p["fill-extrusion-opacity"] = opacity;
|
|
1844
|
+
}
|
|
1845
|
+
return p;
|
|
1846
|
+
}, [
|
|
1847
|
+
fillExtrusionHeight,
|
|
1848
|
+
fillExtrusionBase,
|
|
1849
|
+
fillExtrusionColor,
|
|
1850
|
+
fillExtrusionOpacity,
|
|
1851
|
+
fillExtrusionPattern,
|
|
1852
|
+
fillExtrusionTranslate,
|
|
1853
|
+
fillExtrusionVerticalGradient,
|
|
1854
|
+
opacity
|
|
1855
|
+
]);
|
|
1856
|
+
const layout = React6.useMemo(() => ({}), []);
|
|
1741
1857
|
useLayer({
|
|
1742
1858
|
id,
|
|
1743
1859
|
source,
|
|
@@ -1757,8 +1873,6 @@ var FillExtrusionLayer = ({
|
|
|
1757
1873
|
return null;
|
|
1758
1874
|
};
|
|
1759
1875
|
FillExtrusionLayer.displayName = "FillExtrusionLayer";
|
|
1760
|
-
|
|
1761
|
-
// src/components/layers/HeatmapLayer.tsx
|
|
1762
1876
|
var HeatmapLayer = ({
|
|
1763
1877
|
id,
|
|
1764
1878
|
source,
|
|
@@ -1778,16 +1892,19 @@ var HeatmapLayer = ({
|
|
|
1778
1892
|
heatmapRadius,
|
|
1779
1893
|
heatmapOpacity
|
|
1780
1894
|
}) => {
|
|
1781
|
-
const paint = {
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1895
|
+
const paint = React6.useMemo(() => {
|
|
1896
|
+
const p = {};
|
|
1897
|
+
if (heatmapIntensity !== void 0) p["heatmap-intensity"] = heatmapIntensity;
|
|
1898
|
+
if (heatmapWeight !== void 0) p["heatmap-weight"] = heatmapWeight;
|
|
1899
|
+
if (heatmapColor !== void 0) p["heatmap-color"] = heatmapColor;
|
|
1900
|
+
if (heatmapRadius !== void 0) p["heatmap-radius"] = heatmapRadius;
|
|
1901
|
+
if (heatmapOpacity !== void 0) p["heatmap-opacity"] = heatmapOpacity;
|
|
1902
|
+
if (opacity !== void 0 && heatmapOpacity === void 0) {
|
|
1903
|
+
p["heatmap-opacity"] = opacity;
|
|
1904
|
+
}
|
|
1905
|
+
return p;
|
|
1906
|
+
}, [heatmapIntensity, heatmapWeight, heatmapColor, heatmapRadius, heatmapOpacity, opacity]);
|
|
1907
|
+
const layout = React6.useMemo(() => ({}), []);
|
|
1791
1908
|
useLayer({
|
|
1792
1909
|
id,
|
|
1793
1910
|
source,
|
|
@@ -2235,9 +2352,11 @@ var DeckOverlay = ({
|
|
|
2235
2352
|
const MapboxOverlayRef = React6.useRef(null);
|
|
2236
2353
|
React6.useEffect(() => {
|
|
2237
2354
|
if (!map || !loaded) return;
|
|
2355
|
+
let cancelled = false;
|
|
2238
2356
|
const initOverlay = async () => {
|
|
2239
2357
|
try {
|
|
2240
2358
|
const deckMapbox = await import('@deck.gl/mapbox');
|
|
2359
|
+
if (cancelled) return;
|
|
2241
2360
|
const MapboxOverlay = deckMapbox.MapboxOverlay;
|
|
2242
2361
|
MapboxOverlayRef.current = MapboxOverlay;
|
|
2243
2362
|
const overlay = new MapboxOverlay({
|
|
@@ -2252,6 +2371,7 @@ var DeckOverlay = ({
|
|
|
2252
2371
|
map.addControl(overlay);
|
|
2253
2372
|
overlayRef.current = overlay;
|
|
2254
2373
|
} catch (err) {
|
|
2374
|
+
if (cancelled) return;
|
|
2255
2375
|
console.warn(
|
|
2256
2376
|
"[maps-react] Deck.gl is not available. Install @deck.gl/core, @deck.gl/layers, and @deck.gl/mapbox to use DeckOverlay.",
|
|
2257
2377
|
err
|
|
@@ -2260,6 +2380,7 @@ var DeckOverlay = ({
|
|
|
2260
2380
|
};
|
|
2261
2381
|
initOverlay();
|
|
2262
2382
|
return () => {
|
|
2383
|
+
cancelled = true;
|
|
2263
2384
|
if (overlayRef.current && map) {
|
|
2264
2385
|
try {
|
|
2265
2386
|
map.removeControl(overlayRef.current);
|