@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
|
@@ -468,53 +468,50 @@ function MapLibre({
|
|
|
468
468
|
}
|
|
469
469
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
470
470
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
471
|
-
const
|
|
472
|
-
if (typeof window === "undefined") return false;
|
|
473
|
-
try {
|
|
474
|
-
return window.self !== window.top;
|
|
475
|
-
} catch {
|
|
476
|
-
return true;
|
|
477
|
-
}
|
|
478
|
-
}, []);
|
|
471
|
+
const containerRef = React3__namespace.default.useRef(null);
|
|
479
472
|
React3__namespace.default.useEffect(() => {
|
|
480
|
-
if (!
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
lastHeight = height;
|
|
494
|
-
resizeTimeout = setTimeout(() => {
|
|
495
|
-
mapRef.current?.resize();
|
|
496
|
-
}, 250);
|
|
473
|
+
if (!mapRef.current || !containerRef.current) return;
|
|
474
|
+
const enforceContainerHeight = () => {
|
|
475
|
+
const container = containerRef.current;
|
|
476
|
+
const map = mapRef.current;
|
|
477
|
+
if (!container || !map) return;
|
|
478
|
+
const rect = container.getBoundingClientRect();
|
|
479
|
+
const maxHeight = Math.min(rect.height, window.innerHeight);
|
|
480
|
+
const canvas = map.getCanvas();
|
|
481
|
+
if (canvas && canvas.style.height) {
|
|
482
|
+
const canvasHeight = parseInt(canvas.style.height);
|
|
483
|
+
if (canvasHeight > maxHeight || canvasHeight > 2e3) {
|
|
484
|
+
map.resize();
|
|
485
|
+
}
|
|
497
486
|
}
|
|
498
487
|
};
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
resizeObserver
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
};
|
|
488
|
+
const interval = setInterval(enforceContainerHeight, 1e3);
|
|
489
|
+
let resizeObserver = null;
|
|
490
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
491
|
+
resizeObserver = new ResizeObserver(() => {
|
|
492
|
+
enforceContainerHeight();
|
|
493
|
+
});
|
|
494
|
+
resizeObserver.observe(containerRef.current);
|
|
507
495
|
}
|
|
508
|
-
|
|
496
|
+
return () => {
|
|
497
|
+
clearInterval(interval);
|
|
498
|
+
if (resizeObserver) {
|
|
499
|
+
resizeObserver.disconnect();
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
}, []);
|
|
509
503
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
510
504
|
"div",
|
|
511
505
|
{
|
|
506
|
+
ref: containerRef,
|
|
512
507
|
className: joinClassNames("relative w-full h-full", className),
|
|
513
508
|
style: {
|
|
514
509
|
width: "100%",
|
|
515
510
|
height: "100%",
|
|
516
|
-
|
|
517
|
-
|
|
511
|
+
maxHeight: "100vh",
|
|
512
|
+
// Prevent excessive height
|
|
513
|
+
overflow: "hidden",
|
|
514
|
+
position: "relative",
|
|
518
515
|
...style
|
|
519
516
|
},
|
|
520
517
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -528,7 +525,7 @@ function MapLibre({
|
|
|
528
525
|
onMoveEnd: handleMoveEnd,
|
|
529
526
|
onClick: handleMapClick,
|
|
530
527
|
attributionControl: false,
|
|
531
|
-
trackResize:
|
|
528
|
+
trackResize: true,
|
|
532
529
|
dragRotate: false,
|
|
533
530
|
touchZoomRotate: false,
|
|
534
531
|
children: [
|
|
@@ -786,9 +783,25 @@ function GeoMap({
|
|
|
786
783
|
clearSelectionOnMapClick = true,
|
|
787
784
|
mapChildren,
|
|
788
785
|
optixFlowConfig,
|
|
786
|
+
mapSize,
|
|
789
787
|
IconComponent = FallbackIcon,
|
|
790
788
|
ImgComponent = FallbackImg
|
|
791
789
|
}) {
|
|
790
|
+
const [isMobile, setIsMobile] = React3__namespace.useState(false);
|
|
791
|
+
React3__namespace.useEffect(() => {
|
|
792
|
+
const checkMobile = () => {
|
|
793
|
+
setIsMobile(window.innerWidth < 768);
|
|
794
|
+
};
|
|
795
|
+
checkMobile();
|
|
796
|
+
window.addEventListener("resize", checkMobile);
|
|
797
|
+
return () => window.removeEventListener("resize", checkMobile);
|
|
798
|
+
}, []);
|
|
799
|
+
const calculatedHeight = React3__namespace.useMemo(() => {
|
|
800
|
+
if (mapSize) {
|
|
801
|
+
return isMobile ? mapSize.mobile : mapSize.desktop;
|
|
802
|
+
}
|
|
803
|
+
return isMobile ? 420 : 520;
|
|
804
|
+
}, [mapSize, isMobile]);
|
|
792
805
|
const normalizedStandaloneMarkers = React3__namespace.useMemo(
|
|
793
806
|
() => markers.map((marker, index) => ({
|
|
794
807
|
...marker,
|
|
@@ -897,14 +910,17 @@ function GeoMap({
|
|
|
897
910
|
const latDiff = Math.max(...lats) - Math.min(...lats);
|
|
898
911
|
const lngDiff = Math.max(...lngs) - Math.min(...lngs);
|
|
899
912
|
const maxDiff = Math.max(latDiff, lngDiff);
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
if (maxDiff >
|
|
903
|
-
if (maxDiff >
|
|
904
|
-
if (maxDiff >
|
|
905
|
-
if (maxDiff >
|
|
906
|
-
return
|
|
907
|
-
|
|
913
|
+
const heightFactor = calculatedHeight / 520;
|
|
914
|
+
const paddingFactor = 0.85;
|
|
915
|
+
if (maxDiff > 10) return Math.max(2, 3 * heightFactor * paddingFactor);
|
|
916
|
+
if (maxDiff > 5) return Math.max(4, 5 * heightFactor * paddingFactor);
|
|
917
|
+
if (maxDiff > 2) return Math.max(6, 7 * heightFactor * paddingFactor);
|
|
918
|
+
if (maxDiff > 1) return Math.max(8, 9 * heightFactor * paddingFactor);
|
|
919
|
+
if (maxDiff > 0.5) return Math.max(9, 10 * heightFactor * paddingFactor);
|
|
920
|
+
if (maxDiff > 0.1) return Math.max(11, 12 * heightFactor * paddingFactor);
|
|
921
|
+
if (maxDiff > 0.01) return Math.max(12, 13 * heightFactor * paddingFactor);
|
|
922
|
+
return Math.max(11, 12 * heightFactor * paddingFactor);
|
|
923
|
+
}, [normalizedClusters, normalizedStandaloneMarkers, markerFocusZoom, calculatedHeight]);
|
|
908
924
|
const [uncontrolledViewState, setUncontrolledViewState] = React3__namespace.useState({
|
|
909
925
|
latitude: defaultViewState?.latitude ?? firstCoordinate.latitude,
|
|
910
926
|
longitude: defaultViewState?.longitude ?? firstCoordinate.longitude,
|
|
@@ -1227,37 +1243,38 @@ function GeoMap({
|
|
|
1227
1243
|
}
|
|
1228
1244
|
return null;
|
|
1229
1245
|
};
|
|
1230
|
-
const isInIframe = React3__namespace.useMemo(() => {
|
|
1231
|
-
if (typeof window === "undefined") return false;
|
|
1232
|
-
try {
|
|
1233
|
-
return window.self !== window.top;
|
|
1234
|
-
} catch {
|
|
1235
|
-
return true;
|
|
1236
|
-
}
|
|
1237
|
-
}, []);
|
|
1238
1246
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1239
1247
|
"div",
|
|
1240
1248
|
{
|
|
1241
1249
|
className: cn(
|
|
1242
|
-
"relative
|
|
1250
|
+
"relative rounded-2xl border border-border bg-background",
|
|
1251
|
+
// Remove overflow-hidden from outer container to allow panel to overflow
|
|
1243
1252
|
className
|
|
1244
1253
|
),
|
|
1245
1254
|
style: {
|
|
1246
|
-
//
|
|
1247
|
-
|
|
1255
|
+
// If className includes height settings, they'll override via CSS specificity
|
|
1256
|
+
height: className?.includes("h-[") || className?.includes("min-h-[") || className?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
|
|
1257
|
+
// Explicitly allow overflow for marker panels
|
|
1258
|
+
overflow: "visible"
|
|
1248
1259
|
},
|
|
1249
1260
|
children: [
|
|
1250
1261
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1251
1262
|
"div",
|
|
1252
1263
|
{
|
|
1253
1264
|
className: cn(
|
|
1254
|
-
"w-full",
|
|
1255
|
-
//
|
|
1256
|
-
mapWrapperClassName
|
|
1265
|
+
"w-full rounded-2xl",
|
|
1266
|
+
// Only apply default height class if mapWrapperClassName not provided
|
|
1267
|
+
!mapWrapperClassName && `h-[${calculatedHeight}px]`,
|
|
1268
|
+
mapWrapperClassName
|
|
1257
1269
|
),
|
|
1258
1270
|
style: {
|
|
1259
|
-
//
|
|
1260
|
-
|
|
1271
|
+
// If mapWrapperClassName includes height, let it handle the height
|
|
1272
|
+
height: mapWrapperClassName?.includes("h-[") || mapWrapperClassName?.includes("min-h-[") || mapWrapperClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
|
|
1273
|
+
maxHeight: "100vh",
|
|
1274
|
+
// Prevent excessive growth
|
|
1275
|
+
position: "relative",
|
|
1276
|
+
// Keep overflow hidden only on the map wrapper to contain the canvas
|
|
1277
|
+
overflow: "hidden"
|
|
1261
1278
|
},
|
|
1262
1279
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1263
1280
|
MapLibre,
|
|
@@ -1282,6 +1299,10 @@ function GeoMap({
|
|
|
1282
1299
|
geolocateControlPosition,
|
|
1283
1300
|
flyToOptions,
|
|
1284
1301
|
className: cn("h-full w-full", mapClassName),
|
|
1302
|
+
style: {
|
|
1303
|
+
// Pass the calculated height to MapLibre for better zoom calculations
|
|
1304
|
+
height: mapClassName?.includes("h-[") || mapClassName?.includes("min-h-[") || mapClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`
|
|
1305
|
+
},
|
|
1285
1306
|
children: mapChildren
|
|
1286
1307
|
}
|
|
1287
1308
|
)
|
|
@@ -1291,9 +1312,13 @@ function GeoMap({
|
|
|
1291
1312
|
"div",
|
|
1292
1313
|
{
|
|
1293
1314
|
className: cn(
|
|
1294
|
-
"pointer-events-none absolute z-
|
|
1315
|
+
"pointer-events-none absolute z-30",
|
|
1295
1316
|
PANEL_POSITION_CLASS[panelPosition]
|
|
1296
1317
|
),
|
|
1318
|
+
style: {
|
|
1319
|
+
// Ensure panel can overflow and has higher z-index
|
|
1320
|
+
zIndex: 30
|
|
1321
|
+
},
|
|
1297
1322
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-auto", children: renderMarkerPanel() })
|
|
1298
1323
|
}
|
|
1299
1324
|
) : null
|