@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
|
@@ -447,53 +447,50 @@ function MapLibre({
|
|
|
447
447
|
}
|
|
448
448
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
449
449
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
450
|
-
const
|
|
451
|
-
if (typeof window === "undefined") return false;
|
|
452
|
-
try {
|
|
453
|
-
return window.self !== window.top;
|
|
454
|
-
} catch {
|
|
455
|
-
return true;
|
|
456
|
-
}
|
|
457
|
-
}, []);
|
|
450
|
+
const containerRef = React3__default.useRef(null);
|
|
458
451
|
React3__default.useEffect(() => {
|
|
459
|
-
if (!
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
lastHeight = height;
|
|
473
|
-
resizeTimeout = setTimeout(() => {
|
|
474
|
-
mapRef.current?.resize();
|
|
475
|
-
}, 250);
|
|
452
|
+
if (!mapRef.current || !containerRef.current) return;
|
|
453
|
+
const enforceContainerHeight = () => {
|
|
454
|
+
const container = containerRef.current;
|
|
455
|
+
const map = mapRef.current;
|
|
456
|
+
if (!container || !map) return;
|
|
457
|
+
const rect = container.getBoundingClientRect();
|
|
458
|
+
const maxHeight = Math.min(rect.height, window.innerHeight);
|
|
459
|
+
const canvas = map.getCanvas();
|
|
460
|
+
if (canvas && canvas.style.height) {
|
|
461
|
+
const canvasHeight = parseInt(canvas.style.height);
|
|
462
|
+
if (canvasHeight > maxHeight || canvasHeight > 2e3) {
|
|
463
|
+
map.resize();
|
|
464
|
+
}
|
|
476
465
|
}
|
|
477
466
|
};
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
resizeObserver
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
};
|
|
467
|
+
const interval = setInterval(enforceContainerHeight, 1e3);
|
|
468
|
+
let resizeObserver = null;
|
|
469
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
470
|
+
resizeObserver = new ResizeObserver(() => {
|
|
471
|
+
enforceContainerHeight();
|
|
472
|
+
});
|
|
473
|
+
resizeObserver.observe(containerRef.current);
|
|
486
474
|
}
|
|
487
|
-
|
|
475
|
+
return () => {
|
|
476
|
+
clearInterval(interval);
|
|
477
|
+
if (resizeObserver) {
|
|
478
|
+
resizeObserver.disconnect();
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}, []);
|
|
488
482
|
return /* @__PURE__ */ jsx(
|
|
489
483
|
"div",
|
|
490
484
|
{
|
|
485
|
+
ref: containerRef,
|
|
491
486
|
className: joinClassNames("relative w-full h-full", className),
|
|
492
487
|
style: {
|
|
493
488
|
width: "100%",
|
|
494
489
|
height: "100%",
|
|
495
|
-
|
|
496
|
-
|
|
490
|
+
maxHeight: "100vh",
|
|
491
|
+
// Prevent excessive height
|
|
492
|
+
overflow: "hidden",
|
|
493
|
+
position: "relative",
|
|
497
494
|
...style
|
|
498
495
|
},
|
|
499
496
|
children: /* @__PURE__ */ jsxs(
|
|
@@ -507,7 +504,7 @@ function MapLibre({
|
|
|
507
504
|
onMoveEnd: handleMoveEnd,
|
|
508
505
|
onClick: handleMapClick,
|
|
509
506
|
attributionControl: false,
|
|
510
|
-
trackResize:
|
|
507
|
+
trackResize: true,
|
|
511
508
|
dragRotate: false,
|
|
512
509
|
touchZoomRotate: false,
|
|
513
510
|
children: [
|
|
@@ -765,9 +762,25 @@ function GeoMap({
|
|
|
765
762
|
clearSelectionOnMapClick = true,
|
|
766
763
|
mapChildren,
|
|
767
764
|
optixFlowConfig,
|
|
765
|
+
mapSize,
|
|
768
766
|
IconComponent = FallbackIcon,
|
|
769
767
|
ImgComponent = FallbackImg
|
|
770
768
|
}) {
|
|
769
|
+
const [isMobile, setIsMobile] = React3.useState(false);
|
|
770
|
+
React3.useEffect(() => {
|
|
771
|
+
const checkMobile = () => {
|
|
772
|
+
setIsMobile(window.innerWidth < 768);
|
|
773
|
+
};
|
|
774
|
+
checkMobile();
|
|
775
|
+
window.addEventListener("resize", checkMobile);
|
|
776
|
+
return () => window.removeEventListener("resize", checkMobile);
|
|
777
|
+
}, []);
|
|
778
|
+
const calculatedHeight = React3.useMemo(() => {
|
|
779
|
+
if (mapSize) {
|
|
780
|
+
return isMobile ? mapSize.mobile : mapSize.desktop;
|
|
781
|
+
}
|
|
782
|
+
return isMobile ? 420 : 520;
|
|
783
|
+
}, [mapSize, isMobile]);
|
|
771
784
|
const normalizedStandaloneMarkers = React3.useMemo(
|
|
772
785
|
() => markers.map((marker, index) => ({
|
|
773
786
|
...marker,
|
|
@@ -876,14 +889,17 @@ function GeoMap({
|
|
|
876
889
|
const latDiff = Math.max(...lats) - Math.min(...lats);
|
|
877
890
|
const lngDiff = Math.max(...lngs) - Math.min(...lngs);
|
|
878
891
|
const maxDiff = Math.max(latDiff, lngDiff);
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
if (maxDiff >
|
|
882
|
-
if (maxDiff >
|
|
883
|
-
if (maxDiff >
|
|
884
|
-
if (maxDiff >
|
|
885
|
-
return
|
|
886
|
-
|
|
892
|
+
const heightFactor = calculatedHeight / 520;
|
|
893
|
+
const paddingFactor = 0.85;
|
|
894
|
+
if (maxDiff > 10) return Math.max(2, 3 * heightFactor * paddingFactor);
|
|
895
|
+
if (maxDiff > 5) return Math.max(4, 5 * heightFactor * paddingFactor);
|
|
896
|
+
if (maxDiff > 2) return Math.max(6, 7 * heightFactor * paddingFactor);
|
|
897
|
+
if (maxDiff > 1) return Math.max(8, 9 * heightFactor * paddingFactor);
|
|
898
|
+
if (maxDiff > 0.5) return Math.max(9, 10 * heightFactor * paddingFactor);
|
|
899
|
+
if (maxDiff > 0.1) return Math.max(11, 12 * heightFactor * paddingFactor);
|
|
900
|
+
if (maxDiff > 0.01) return Math.max(12, 13 * heightFactor * paddingFactor);
|
|
901
|
+
return Math.max(11, 12 * heightFactor * paddingFactor);
|
|
902
|
+
}, [normalizedClusters, normalizedStandaloneMarkers, markerFocusZoom, calculatedHeight]);
|
|
887
903
|
const [uncontrolledViewState, setUncontrolledViewState] = React3.useState({
|
|
888
904
|
latitude: defaultViewState?.latitude ?? firstCoordinate.latitude,
|
|
889
905
|
longitude: defaultViewState?.longitude ?? firstCoordinate.longitude,
|
|
@@ -1206,37 +1222,38 @@ function GeoMap({
|
|
|
1206
1222
|
}
|
|
1207
1223
|
return null;
|
|
1208
1224
|
};
|
|
1209
|
-
const isInIframe = React3.useMemo(() => {
|
|
1210
|
-
if (typeof window === "undefined") return false;
|
|
1211
|
-
try {
|
|
1212
|
-
return window.self !== window.top;
|
|
1213
|
-
} catch {
|
|
1214
|
-
return true;
|
|
1215
|
-
}
|
|
1216
|
-
}, []);
|
|
1217
1225
|
return /* @__PURE__ */ jsxs(
|
|
1218
1226
|
"div",
|
|
1219
1227
|
{
|
|
1220
1228
|
className: cn(
|
|
1221
|
-
"relative
|
|
1229
|
+
"relative rounded-2xl border border-border bg-background",
|
|
1230
|
+
// Remove overflow-hidden from outer container to allow panel to overflow
|
|
1222
1231
|
className
|
|
1223
1232
|
),
|
|
1224
1233
|
style: {
|
|
1225
|
-
//
|
|
1226
|
-
|
|
1234
|
+
// If className includes height settings, they'll override via CSS specificity
|
|
1235
|
+
height: className?.includes("h-[") || className?.includes("min-h-[") || className?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
|
|
1236
|
+
// Explicitly allow overflow for marker panels
|
|
1237
|
+
overflow: "visible"
|
|
1227
1238
|
},
|
|
1228
1239
|
children: [
|
|
1229
1240
|
/* @__PURE__ */ jsx(
|
|
1230
1241
|
"div",
|
|
1231
1242
|
{
|
|
1232
1243
|
className: cn(
|
|
1233
|
-
"w-full",
|
|
1234
|
-
//
|
|
1235
|
-
mapWrapperClassName
|
|
1244
|
+
"w-full rounded-2xl",
|
|
1245
|
+
// Only apply default height class if mapWrapperClassName not provided
|
|
1246
|
+
!mapWrapperClassName && `h-[${calculatedHeight}px]`,
|
|
1247
|
+
mapWrapperClassName
|
|
1236
1248
|
),
|
|
1237
1249
|
style: {
|
|
1238
|
-
//
|
|
1239
|
-
|
|
1250
|
+
// If mapWrapperClassName includes height, let it handle the height
|
|
1251
|
+
height: mapWrapperClassName?.includes("h-[") || mapWrapperClassName?.includes("min-h-[") || mapWrapperClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
|
|
1252
|
+
maxHeight: "100vh",
|
|
1253
|
+
// Prevent excessive growth
|
|
1254
|
+
position: "relative",
|
|
1255
|
+
// Keep overflow hidden only on the map wrapper to contain the canvas
|
|
1256
|
+
overflow: "hidden"
|
|
1240
1257
|
},
|
|
1241
1258
|
children: /* @__PURE__ */ jsx(
|
|
1242
1259
|
MapLibre,
|
|
@@ -1261,6 +1278,10 @@ function GeoMap({
|
|
|
1261
1278
|
geolocateControlPosition,
|
|
1262
1279
|
flyToOptions,
|
|
1263
1280
|
className: cn("h-full w-full", mapClassName),
|
|
1281
|
+
style: {
|
|
1282
|
+
// Pass the calculated height to MapLibre for better zoom calculations
|
|
1283
|
+
height: mapClassName?.includes("h-[") || mapClassName?.includes("min-h-[") || mapClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`
|
|
1284
|
+
},
|
|
1264
1285
|
children: mapChildren
|
|
1265
1286
|
}
|
|
1266
1287
|
)
|
|
@@ -1270,9 +1291,13 @@ function GeoMap({
|
|
|
1270
1291
|
"div",
|
|
1271
1292
|
{
|
|
1272
1293
|
className: cn(
|
|
1273
|
-
"pointer-events-none absolute z-
|
|
1294
|
+
"pointer-events-none absolute z-30",
|
|
1274
1295
|
PANEL_POSITION_CLASS[panelPosition]
|
|
1275
1296
|
),
|
|
1297
|
+
style: {
|
|
1298
|
+
// Ensure panel can overflow and has higher z-index
|
|
1299
|
+
zIndex: 30
|
|
1300
|
+
},
|
|
1276
1301
|
children: /* @__PURE__ */ jsx("div", { className: "pointer-events-auto", children: renderMarkerPanel() })
|
|
1277
1302
|
}
|
|
1278
1303
|
) : null
|