@page-speed/maps 0.1.7 → 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 +87 -62
- 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 +87 -62
- package/dist/components/geo-map.js.map +1 -1
- package/dist/components/index.cjs +87 -62
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +87 -62
- package/dist/components/index.js.map +1 -1
- package/dist/core/MapLibre.cjs +34 -37
- package/dist/core/MapLibre.cjs.map +1 -1
- package/dist/core/MapLibre.js +34 -37
- package/dist/core/MapLibre.js.map +1 -1
- package/dist/core/index.cjs +34 -37
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +34 -37
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +87 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +87 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -457,53 +457,50 @@ function MapLibre({
|
|
|
457
457
|
}
|
|
458
458
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
459
459
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
460
|
-
const
|
|
461
|
-
if (typeof window === "undefined") return false;
|
|
462
|
-
try {
|
|
463
|
-
return window.self !== window.top;
|
|
464
|
-
} catch {
|
|
465
|
-
return true;
|
|
466
|
-
}
|
|
467
|
-
}, []);
|
|
460
|
+
const containerRef = React3__default.useRef(null);
|
|
468
461
|
React3__default.useEffect(() => {
|
|
469
|
-
if (!
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
lastHeight = height;
|
|
483
|
-
resizeTimeout = setTimeout(() => {
|
|
484
|
-
mapRef.current?.resize();
|
|
485
|
-
}, 250);
|
|
462
|
+
if (!mapRef.current || !containerRef.current) return;
|
|
463
|
+
const enforceContainerHeight = () => {
|
|
464
|
+
const container = containerRef.current;
|
|
465
|
+
const map = mapRef.current;
|
|
466
|
+
if (!container || !map) return;
|
|
467
|
+
const rect = container.getBoundingClientRect();
|
|
468
|
+
const maxHeight = Math.min(rect.height, window.innerHeight);
|
|
469
|
+
const canvas = map.getCanvas();
|
|
470
|
+
if (canvas && canvas.style.height) {
|
|
471
|
+
const canvasHeight = parseInt(canvas.style.height);
|
|
472
|
+
if (canvasHeight > maxHeight || canvasHeight > 2e3) {
|
|
473
|
+
map.resize();
|
|
474
|
+
}
|
|
486
475
|
}
|
|
487
476
|
};
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
resizeObserver
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
};
|
|
477
|
+
const interval = setInterval(enforceContainerHeight, 1e3);
|
|
478
|
+
let resizeObserver = null;
|
|
479
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
480
|
+
resizeObserver = new ResizeObserver(() => {
|
|
481
|
+
enforceContainerHeight();
|
|
482
|
+
});
|
|
483
|
+
resizeObserver.observe(containerRef.current);
|
|
496
484
|
}
|
|
497
|
-
|
|
485
|
+
return () => {
|
|
486
|
+
clearInterval(interval);
|
|
487
|
+
if (resizeObserver) {
|
|
488
|
+
resizeObserver.disconnect();
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
}, []);
|
|
498
492
|
return /* @__PURE__ */ jsx(
|
|
499
493
|
"div",
|
|
500
494
|
{
|
|
495
|
+
ref: containerRef,
|
|
501
496
|
className: joinClassNames("relative w-full h-full", className),
|
|
502
497
|
style: {
|
|
503
498
|
width: "100%",
|
|
504
499
|
height: "100%",
|
|
505
|
-
|
|
506
|
-
|
|
500
|
+
maxHeight: "100vh",
|
|
501
|
+
// Prevent excessive height
|
|
502
|
+
overflow: "hidden",
|
|
503
|
+
position: "relative",
|
|
507
504
|
...style
|
|
508
505
|
},
|
|
509
506
|
children: /* @__PURE__ */ jsxs(
|
|
@@ -517,7 +514,7 @@ function MapLibre({
|
|
|
517
514
|
onMoveEnd: handleMoveEnd,
|
|
518
515
|
onClick: handleMapClick,
|
|
519
516
|
attributionControl: false,
|
|
520
|
-
trackResize:
|
|
517
|
+
trackResize: true,
|
|
521
518
|
dragRotate: false,
|
|
522
519
|
touchZoomRotate: false,
|
|
523
520
|
children: [
|
|
@@ -990,9 +987,25 @@ function GeoMap({
|
|
|
990
987
|
clearSelectionOnMapClick = true,
|
|
991
988
|
mapChildren,
|
|
992
989
|
optixFlowConfig,
|
|
990
|
+
mapSize,
|
|
993
991
|
IconComponent = FallbackIcon,
|
|
994
992
|
ImgComponent = FallbackImg
|
|
995
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]);
|
|
996
1009
|
const normalizedStandaloneMarkers = React3.useMemo(
|
|
997
1010
|
() => markers.map((marker, index) => ({
|
|
998
1011
|
...marker,
|
|
@@ -1101,14 +1114,17 @@ function GeoMap({
|
|
|
1101
1114
|
const latDiff = Math.max(...lats) - Math.min(...lats);
|
|
1102
1115
|
const lngDiff = Math.max(...lngs) - Math.min(...lngs);
|
|
1103
1116
|
const maxDiff = Math.max(latDiff, lngDiff);
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
if (maxDiff >
|
|
1107
|
-
if (maxDiff >
|
|
1108
|
-
if (maxDiff >
|
|
1109
|
-
if (maxDiff >
|
|
1110
|
-
return
|
|
1111
|
-
|
|
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]);
|
|
1112
1128
|
const [uncontrolledViewState, setUncontrolledViewState] = React3.useState({
|
|
1113
1129
|
latitude: defaultViewState?.latitude ?? firstCoordinate.latitude,
|
|
1114
1130
|
longitude: defaultViewState?.longitude ?? firstCoordinate.longitude,
|
|
@@ -1431,37 +1447,38 @@ function GeoMap({
|
|
|
1431
1447
|
}
|
|
1432
1448
|
return null;
|
|
1433
1449
|
};
|
|
1434
|
-
const isInIframe = React3.useMemo(() => {
|
|
1435
|
-
if (typeof window === "undefined") return false;
|
|
1436
|
-
try {
|
|
1437
|
-
return window.self !== window.top;
|
|
1438
|
-
} catch {
|
|
1439
|
-
return true;
|
|
1440
|
-
}
|
|
1441
|
-
}, []);
|
|
1442
1450
|
return /* @__PURE__ */ jsxs(
|
|
1443
1451
|
"div",
|
|
1444
1452
|
{
|
|
1445
1453
|
className: cn(
|
|
1446
|
-
"relative
|
|
1454
|
+
"relative rounded-2xl border border-border bg-background",
|
|
1455
|
+
// Remove overflow-hidden from outer container to allow panel to overflow
|
|
1447
1456
|
className
|
|
1448
1457
|
),
|
|
1449
1458
|
style: {
|
|
1450
|
-
//
|
|
1451
|
-
|
|
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"
|
|
1452
1463
|
},
|
|
1453
1464
|
children: [
|
|
1454
1465
|
/* @__PURE__ */ jsx(
|
|
1455
1466
|
"div",
|
|
1456
1467
|
{
|
|
1457
1468
|
className: cn(
|
|
1458
|
-
"w-full",
|
|
1459
|
-
//
|
|
1460
|
-
mapWrapperClassName
|
|
1469
|
+
"w-full rounded-2xl",
|
|
1470
|
+
// Only apply default height class if mapWrapperClassName not provided
|
|
1471
|
+
!mapWrapperClassName && `h-[${calculatedHeight}px]`,
|
|
1472
|
+
mapWrapperClassName
|
|
1461
1473
|
),
|
|
1462
1474
|
style: {
|
|
1463
|
-
//
|
|
1464
|
-
|
|
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`,
|
|
1477
|
+
maxHeight: "100vh",
|
|
1478
|
+
// Prevent excessive growth
|
|
1479
|
+
position: "relative",
|
|
1480
|
+
// Keep overflow hidden only on the map wrapper to contain the canvas
|
|
1481
|
+
overflow: "hidden"
|
|
1465
1482
|
},
|
|
1466
1483
|
children: /* @__PURE__ */ jsx(
|
|
1467
1484
|
MapLibre,
|
|
@@ -1486,6 +1503,10 @@ function GeoMap({
|
|
|
1486
1503
|
geolocateControlPosition,
|
|
1487
1504
|
flyToOptions,
|
|
1488
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
|
+
},
|
|
1489
1510
|
children: mapChildren
|
|
1490
1511
|
}
|
|
1491
1512
|
)
|
|
@@ -1495,9 +1516,13 @@ function GeoMap({
|
|
|
1495
1516
|
"div",
|
|
1496
1517
|
{
|
|
1497
1518
|
className: cn(
|
|
1498
|
-
"pointer-events-none absolute z-
|
|
1519
|
+
"pointer-events-none absolute z-30",
|
|
1499
1520
|
PANEL_POSITION_CLASS[panelPosition]
|
|
1500
1521
|
),
|
|
1522
|
+
style: {
|
|
1523
|
+
// Ensure panel can overflow and has higher z-index
|
|
1524
|
+
zIndex: 30
|
|
1525
|
+
},
|
|
1501
1526
|
children: /* @__PURE__ */ jsx("div", { className: "pointer-events-auto", children: renderMarkerPanel() })
|
|
1502
1527
|
}
|
|
1503
1528
|
) : null
|