@page-speed/maps 0.1.8 → 0.1.9
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/components/geo-map.cjs +51 -15
- package/dist/components/geo-map.cjs.map +1 -1
- package/dist/components/geo-map.d.cts +5 -1
- package/dist/components/geo-map.d.ts +5 -1
- package/dist/components/geo-map.js +51 -15
- package/dist/components/geo-map.js.map +1 -1
- package/dist/components/index.cjs +51 -15
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +51 -15
- package/dist/components/index.js.map +1 -1
- package/dist/index.cjs +51 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/components/index.js
CHANGED
|
@@ -881,9 +881,25 @@ function GeoMap({
|
|
|
881
881
|
clearSelectionOnMapClick = true,
|
|
882
882
|
mapChildren,
|
|
883
883
|
optixFlowConfig,
|
|
884
|
+
mapSize,
|
|
884
885
|
IconComponent = FallbackIcon,
|
|
885
886
|
ImgComponent = FallbackImg
|
|
886
887
|
}) {
|
|
888
|
+
const [isMobile, setIsMobile] = React3.useState(false);
|
|
889
|
+
React3.useEffect(() => {
|
|
890
|
+
const checkMobile = () => {
|
|
891
|
+
setIsMobile(window.innerWidth < 768);
|
|
892
|
+
};
|
|
893
|
+
checkMobile();
|
|
894
|
+
window.addEventListener("resize", checkMobile);
|
|
895
|
+
return () => window.removeEventListener("resize", checkMobile);
|
|
896
|
+
}, []);
|
|
897
|
+
const calculatedHeight = React3.useMemo(() => {
|
|
898
|
+
if (mapSize) {
|
|
899
|
+
return isMobile ? mapSize.mobile : mapSize.desktop;
|
|
900
|
+
}
|
|
901
|
+
return isMobile ? 420 : 520;
|
|
902
|
+
}, [mapSize, isMobile]);
|
|
887
903
|
const normalizedStandaloneMarkers = React3.useMemo(
|
|
888
904
|
() => markers.map((marker, index) => ({
|
|
889
905
|
...marker,
|
|
@@ -992,14 +1008,17 @@ function GeoMap({
|
|
|
992
1008
|
const latDiff = Math.max(...lats) - Math.min(...lats);
|
|
993
1009
|
const lngDiff = Math.max(...lngs) - Math.min(...lngs);
|
|
994
1010
|
const maxDiff = Math.max(latDiff, lngDiff);
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
if (maxDiff >
|
|
998
|
-
if (maxDiff >
|
|
999
|
-
if (maxDiff >
|
|
1000
|
-
if (maxDiff >
|
|
1001
|
-
return
|
|
1002
|
-
|
|
1011
|
+
const heightFactor = calculatedHeight / 520;
|
|
1012
|
+
const paddingFactor = 0.85;
|
|
1013
|
+
if (maxDiff > 10) return Math.max(2, 3 * heightFactor * paddingFactor);
|
|
1014
|
+
if (maxDiff > 5) return Math.max(4, 5 * heightFactor * paddingFactor);
|
|
1015
|
+
if (maxDiff > 2) return Math.max(6, 7 * heightFactor * paddingFactor);
|
|
1016
|
+
if (maxDiff > 1) return Math.max(8, 9 * heightFactor * paddingFactor);
|
|
1017
|
+
if (maxDiff > 0.5) return Math.max(9, 10 * heightFactor * paddingFactor);
|
|
1018
|
+
if (maxDiff > 0.1) return Math.max(11, 12 * heightFactor * paddingFactor);
|
|
1019
|
+
if (maxDiff > 0.01) return Math.max(12, 13 * heightFactor * paddingFactor);
|
|
1020
|
+
return Math.max(11, 12 * heightFactor * paddingFactor);
|
|
1021
|
+
}, [normalizedClusters, normalizedStandaloneMarkers, markerFocusZoom, calculatedHeight]);
|
|
1003
1022
|
const [uncontrolledViewState, setUncontrolledViewState] = React3.useState({
|
|
1004
1023
|
latitude: defaultViewState?.latitude ?? firstCoordinate.latitude,
|
|
1005
1024
|
longitude: defaultViewState?.longitude ?? firstCoordinate.longitude,
|
|
@@ -1326,24 +1345,33 @@ function GeoMap({
|
|
|
1326
1345
|
"div",
|
|
1327
1346
|
{
|
|
1328
1347
|
className: cn(
|
|
1329
|
-
"relative
|
|
1348
|
+
"relative rounded-2xl border border-border bg-background",
|
|
1349
|
+
// Remove overflow-hidden from outer container to allow panel to overflow
|
|
1330
1350
|
className
|
|
1331
1351
|
),
|
|
1352
|
+
style: {
|
|
1353
|
+
// If className includes height settings, they'll override via CSS specificity
|
|
1354
|
+
height: className?.includes("h-[") || className?.includes("min-h-[") || className?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
|
|
1355
|
+
// Explicitly allow overflow for marker panels
|
|
1356
|
+
overflow: "visible"
|
|
1357
|
+
},
|
|
1332
1358
|
children: [
|
|
1333
1359
|
/* @__PURE__ */ jsx(
|
|
1334
1360
|
"div",
|
|
1335
1361
|
{
|
|
1336
1362
|
className: cn(
|
|
1337
|
-
"w-full",
|
|
1338
|
-
//
|
|
1339
|
-
mapWrapperClassName
|
|
1363
|
+
"w-full rounded-2xl",
|
|
1364
|
+
// Only apply default height class if mapWrapperClassName not provided
|
|
1365
|
+
!mapWrapperClassName && `h-[${calculatedHeight}px]`,
|
|
1366
|
+
mapWrapperClassName
|
|
1340
1367
|
),
|
|
1341
1368
|
style: {
|
|
1342
|
-
//
|
|
1343
|
-
height: mapWrapperClassName ? void 0 :
|
|
1369
|
+
// If mapWrapperClassName includes height, let it handle the height
|
|
1370
|
+
height: mapWrapperClassName?.includes("h-[") || mapWrapperClassName?.includes("min-h-[") || mapWrapperClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
|
|
1344
1371
|
maxHeight: "100vh",
|
|
1345
1372
|
// Prevent excessive growth
|
|
1346
1373
|
position: "relative",
|
|
1374
|
+
// Keep overflow hidden only on the map wrapper to contain the canvas
|
|
1347
1375
|
overflow: "hidden"
|
|
1348
1376
|
},
|
|
1349
1377
|
children: /* @__PURE__ */ jsx(
|
|
@@ -1369,6 +1397,10 @@ function GeoMap({
|
|
|
1369
1397
|
geolocateControlPosition,
|
|
1370
1398
|
flyToOptions,
|
|
1371
1399
|
className: cn("h-full w-full", mapClassName),
|
|
1400
|
+
style: {
|
|
1401
|
+
// Pass the calculated height to MapLibre for better zoom calculations
|
|
1402
|
+
height: mapClassName?.includes("h-[") || mapClassName?.includes("min-h-[") || mapClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`
|
|
1403
|
+
},
|
|
1372
1404
|
children: mapChildren
|
|
1373
1405
|
}
|
|
1374
1406
|
)
|
|
@@ -1378,9 +1410,13 @@ function GeoMap({
|
|
|
1378
1410
|
"div",
|
|
1379
1411
|
{
|
|
1380
1412
|
className: cn(
|
|
1381
|
-
"pointer-events-none absolute z-
|
|
1413
|
+
"pointer-events-none absolute z-30",
|
|
1382
1414
|
PANEL_POSITION_CLASS[panelPosition]
|
|
1383
1415
|
),
|
|
1416
|
+
style: {
|
|
1417
|
+
// Ensure panel can overflow and has higher z-index
|
|
1418
|
+
zIndex: 30
|
|
1419
|
+
},
|
|
1384
1420
|
children: /* @__PURE__ */ jsx("div", { className: "pointer-events-auto", children: renderMarkerPanel() })
|
|
1385
1421
|
}
|
|
1386
1422
|
) : null
|