@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/index.js
CHANGED
|
@@ -987,9 +987,25 @@ function GeoMap({
|
|
|
987
987
|
clearSelectionOnMapClick = true,
|
|
988
988
|
mapChildren,
|
|
989
989
|
optixFlowConfig,
|
|
990
|
+
mapSize,
|
|
990
991
|
IconComponent = FallbackIcon,
|
|
991
992
|
ImgComponent = FallbackImg
|
|
992
993
|
}) {
|
|
994
|
+
const [isMobile, setIsMobile] = React3.useState(false);
|
|
995
|
+
React3.useEffect(() => {
|
|
996
|
+
const checkMobile = () => {
|
|
997
|
+
setIsMobile(window.innerWidth < 768);
|
|
998
|
+
};
|
|
999
|
+
checkMobile();
|
|
1000
|
+
window.addEventListener("resize", checkMobile);
|
|
1001
|
+
return () => window.removeEventListener("resize", checkMobile);
|
|
1002
|
+
}, []);
|
|
1003
|
+
const calculatedHeight = React3.useMemo(() => {
|
|
1004
|
+
if (mapSize) {
|
|
1005
|
+
return isMobile ? mapSize.mobile : mapSize.desktop;
|
|
1006
|
+
}
|
|
1007
|
+
return isMobile ? 420 : 520;
|
|
1008
|
+
}, [mapSize, isMobile]);
|
|
993
1009
|
const normalizedStandaloneMarkers = React3.useMemo(
|
|
994
1010
|
() => markers.map((marker, index) => ({
|
|
995
1011
|
...marker,
|
|
@@ -1098,14 +1114,17 @@ function GeoMap({
|
|
|
1098
1114
|
const latDiff = Math.max(...lats) - Math.min(...lats);
|
|
1099
1115
|
const lngDiff = Math.max(...lngs) - Math.min(...lngs);
|
|
1100
1116
|
const maxDiff = Math.max(latDiff, lngDiff);
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
if (maxDiff >
|
|
1104
|
-
if (maxDiff >
|
|
1105
|
-
if (maxDiff >
|
|
1106
|
-
if (maxDiff >
|
|
1107
|
-
return
|
|
1108
|
-
|
|
1117
|
+
const heightFactor = calculatedHeight / 520;
|
|
1118
|
+
const paddingFactor = 0.85;
|
|
1119
|
+
if (maxDiff > 10) return Math.max(2, 3 * heightFactor * paddingFactor);
|
|
1120
|
+
if (maxDiff > 5) return Math.max(4, 5 * heightFactor * paddingFactor);
|
|
1121
|
+
if (maxDiff > 2) return Math.max(6, 7 * heightFactor * paddingFactor);
|
|
1122
|
+
if (maxDiff > 1) return Math.max(8, 9 * heightFactor * paddingFactor);
|
|
1123
|
+
if (maxDiff > 0.5) return Math.max(9, 10 * heightFactor * paddingFactor);
|
|
1124
|
+
if (maxDiff > 0.1) return Math.max(11, 12 * heightFactor * paddingFactor);
|
|
1125
|
+
if (maxDiff > 0.01) return Math.max(12, 13 * heightFactor * paddingFactor);
|
|
1126
|
+
return Math.max(11, 12 * heightFactor * paddingFactor);
|
|
1127
|
+
}, [normalizedClusters, normalizedStandaloneMarkers, markerFocusZoom, calculatedHeight]);
|
|
1109
1128
|
const [uncontrolledViewState, setUncontrolledViewState] = React3.useState({
|
|
1110
1129
|
latitude: defaultViewState?.latitude ?? firstCoordinate.latitude,
|
|
1111
1130
|
longitude: defaultViewState?.longitude ?? firstCoordinate.longitude,
|
|
@@ -1432,24 +1451,33 @@ function GeoMap({
|
|
|
1432
1451
|
"div",
|
|
1433
1452
|
{
|
|
1434
1453
|
className: cn(
|
|
1435
|
-
"relative
|
|
1454
|
+
"relative rounded-2xl border border-border bg-background",
|
|
1455
|
+
// Remove overflow-hidden from outer container to allow panel to overflow
|
|
1436
1456
|
className
|
|
1437
1457
|
),
|
|
1458
|
+
style: {
|
|
1459
|
+
// If className includes height settings, they'll override via CSS specificity
|
|
1460
|
+
height: className?.includes("h-[") || className?.includes("min-h-[") || className?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
|
|
1461
|
+
// Explicitly allow overflow for marker panels
|
|
1462
|
+
overflow: "visible"
|
|
1463
|
+
},
|
|
1438
1464
|
children: [
|
|
1439
1465
|
/* @__PURE__ */ jsx(
|
|
1440
1466
|
"div",
|
|
1441
1467
|
{
|
|
1442
1468
|
className: cn(
|
|
1443
|
-
"w-full",
|
|
1444
|
-
//
|
|
1445
|
-
mapWrapperClassName
|
|
1469
|
+
"w-full rounded-2xl",
|
|
1470
|
+
// Only apply default height class if mapWrapperClassName not provided
|
|
1471
|
+
!mapWrapperClassName && `h-[${calculatedHeight}px]`,
|
|
1472
|
+
mapWrapperClassName
|
|
1446
1473
|
),
|
|
1447
1474
|
style: {
|
|
1448
|
-
//
|
|
1449
|
-
height: mapWrapperClassName ? void 0 :
|
|
1475
|
+
// If mapWrapperClassName includes height, let it handle the height
|
|
1476
|
+
height: mapWrapperClassName?.includes("h-[") || mapWrapperClassName?.includes("min-h-[") || mapWrapperClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
|
|
1450
1477
|
maxHeight: "100vh",
|
|
1451
1478
|
// Prevent excessive growth
|
|
1452
1479
|
position: "relative",
|
|
1480
|
+
// Keep overflow hidden only on the map wrapper to contain the canvas
|
|
1453
1481
|
overflow: "hidden"
|
|
1454
1482
|
},
|
|
1455
1483
|
children: /* @__PURE__ */ jsx(
|
|
@@ -1475,6 +1503,10 @@ function GeoMap({
|
|
|
1475
1503
|
geolocateControlPosition,
|
|
1476
1504
|
flyToOptions,
|
|
1477
1505
|
className: cn("h-full w-full", mapClassName),
|
|
1506
|
+
style: {
|
|
1507
|
+
// Pass the calculated height to MapLibre for better zoom calculations
|
|
1508
|
+
height: mapClassName?.includes("h-[") || mapClassName?.includes("min-h-[") || mapClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`
|
|
1509
|
+
},
|
|
1478
1510
|
children: mapChildren
|
|
1479
1511
|
}
|
|
1480
1512
|
)
|
|
@@ -1484,9 +1516,13 @@ function GeoMap({
|
|
|
1484
1516
|
"div",
|
|
1485
1517
|
{
|
|
1486
1518
|
className: cn(
|
|
1487
|
-
"pointer-events-none absolute z-
|
|
1519
|
+
"pointer-events-none absolute z-30",
|
|
1488
1520
|
PANEL_POSITION_CLASS[panelPosition]
|
|
1489
1521
|
),
|
|
1522
|
+
style: {
|
|
1523
|
+
// Ensure panel can overflow and has higher z-index
|
|
1524
|
+
zIndex: 30
|
|
1525
|
+
},
|
|
1490
1526
|
children: /* @__PURE__ */ jsx("div", { className: "pointer-events-auto", children: renderMarkerPanel() })
|
|
1491
1527
|
}
|
|
1492
1528
|
) : null
|