@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
|
@@ -106,6 +106,10 @@ interface GeoMapProps {
|
|
|
106
106
|
clearSelectionOnMapClick?: boolean;
|
|
107
107
|
mapChildren?: React.ReactNode;
|
|
108
108
|
optixFlowConfig?: any;
|
|
109
|
+
mapSize?: {
|
|
110
|
+
desktop: number;
|
|
111
|
+
mobile: number;
|
|
112
|
+
};
|
|
109
113
|
IconComponent?: IconComponent;
|
|
110
114
|
ImgComponent?: ImgComponent;
|
|
111
115
|
}
|
|
@@ -133,6 +137,6 @@ interface GeoMapProps {
|
|
|
133
137
|
* />
|
|
134
138
|
* ```
|
|
135
139
|
*/
|
|
136
|
-
declare function GeoMap({ className, mapWrapperClassName, mapClassName, panelClassName, panelPosition, stadiaApiKey, mapStyle, styleUrl, mapLibreCssHref, markers, clusters, viewState, defaultViewState, onViewStateChange, onMapClick, onMarkerDrag, showNavigationControl, showGeolocateControl, navigationControlPosition, geolocateControlPosition, flyToOptions, markerFocusZoom, clusterFocusZoom, selectedMarkerId, initialSelectedMarkerId, onSelectionChange, clearSelectionOnMapClick, mapChildren, optixFlowConfig, IconComponent, ImgComponent, }: GeoMapProps): React.JSX.Element;
|
|
140
|
+
declare function GeoMap({ className, mapWrapperClassName, mapClassName, panelClassName, panelPosition, stadiaApiKey, mapStyle, styleUrl, mapLibreCssHref, markers, clusters, viewState, defaultViewState, onViewStateChange, onMapClick, onMarkerDrag, showNavigationControl, showGeolocateControl, navigationControlPosition, geolocateControlPosition, flyToOptions, markerFocusZoom, clusterFocusZoom, selectedMarkerId, initialSelectedMarkerId, onSelectionChange, clearSelectionOnMapClick, mapChildren, optixFlowConfig, mapSize, IconComponent, ImgComponent, }: GeoMapProps): React.JSX.Element;
|
|
137
141
|
|
|
138
142
|
export { type ActionConfig, GeoMap, type GeoMapCluster, type GeoMapMarker, type GeoMapMediaItem, type GeoMapMediaType, type GeoMapProps, type GeoMapSelection };
|
|
@@ -106,6 +106,10 @@ interface GeoMapProps {
|
|
|
106
106
|
clearSelectionOnMapClick?: boolean;
|
|
107
107
|
mapChildren?: React.ReactNode;
|
|
108
108
|
optixFlowConfig?: any;
|
|
109
|
+
mapSize?: {
|
|
110
|
+
desktop: number;
|
|
111
|
+
mobile: number;
|
|
112
|
+
};
|
|
109
113
|
IconComponent?: IconComponent;
|
|
110
114
|
ImgComponent?: ImgComponent;
|
|
111
115
|
}
|
|
@@ -133,6 +137,6 @@ interface GeoMapProps {
|
|
|
133
137
|
* />
|
|
134
138
|
* ```
|
|
135
139
|
*/
|
|
136
|
-
declare function GeoMap({ className, mapWrapperClassName, mapClassName, panelClassName, panelPosition, stadiaApiKey, mapStyle, styleUrl, mapLibreCssHref, markers, clusters, viewState, defaultViewState, onViewStateChange, onMapClick, onMarkerDrag, showNavigationControl, showGeolocateControl, navigationControlPosition, geolocateControlPosition, flyToOptions, markerFocusZoom, clusterFocusZoom, selectedMarkerId, initialSelectedMarkerId, onSelectionChange, clearSelectionOnMapClick, mapChildren, optixFlowConfig, IconComponent, ImgComponent, }: GeoMapProps): React.JSX.Element;
|
|
140
|
+
declare function GeoMap({ className, mapWrapperClassName, mapClassName, panelClassName, panelPosition, stadiaApiKey, mapStyle, styleUrl, mapLibreCssHref, markers, clusters, viewState, defaultViewState, onViewStateChange, onMapClick, onMarkerDrag, showNavigationControl, showGeolocateControl, navigationControlPosition, geolocateControlPosition, flyToOptions, markerFocusZoom, clusterFocusZoom, selectedMarkerId, initialSelectedMarkerId, onSelectionChange, clearSelectionOnMapClick, mapChildren, optixFlowConfig, mapSize, IconComponent, ImgComponent, }: GeoMapProps): React.JSX.Element;
|
|
137
141
|
|
|
138
142
|
export { type ActionConfig, GeoMap, type GeoMapCluster, type GeoMapMarker, type GeoMapMediaItem, type GeoMapMediaType, type GeoMapProps, type GeoMapSelection };
|
|
@@ -762,9 +762,25 @@ function GeoMap({
|
|
|
762
762
|
clearSelectionOnMapClick = true,
|
|
763
763
|
mapChildren,
|
|
764
764
|
optixFlowConfig,
|
|
765
|
+
mapSize,
|
|
765
766
|
IconComponent = FallbackIcon,
|
|
766
767
|
ImgComponent = FallbackImg
|
|
767
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]);
|
|
768
784
|
const normalizedStandaloneMarkers = React3.useMemo(
|
|
769
785
|
() => markers.map((marker, index) => ({
|
|
770
786
|
...marker,
|
|
@@ -873,14 +889,17 @@ function GeoMap({
|
|
|
873
889
|
const latDiff = Math.max(...lats) - Math.min(...lats);
|
|
874
890
|
const lngDiff = Math.max(...lngs) - Math.min(...lngs);
|
|
875
891
|
const maxDiff = Math.max(latDiff, lngDiff);
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
if (maxDiff >
|
|
879
|
-
if (maxDiff >
|
|
880
|
-
if (maxDiff >
|
|
881
|
-
if (maxDiff >
|
|
882
|
-
return
|
|
883
|
-
|
|
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]);
|
|
884
903
|
const [uncontrolledViewState, setUncontrolledViewState] = React3.useState({
|
|
885
904
|
latitude: defaultViewState?.latitude ?? firstCoordinate.latitude,
|
|
886
905
|
longitude: defaultViewState?.longitude ?? firstCoordinate.longitude,
|
|
@@ -1207,24 +1226,33 @@ function GeoMap({
|
|
|
1207
1226
|
"div",
|
|
1208
1227
|
{
|
|
1209
1228
|
className: cn(
|
|
1210
|
-
"relative
|
|
1229
|
+
"relative rounded-2xl border border-border bg-background",
|
|
1230
|
+
// Remove overflow-hidden from outer container to allow panel to overflow
|
|
1211
1231
|
className
|
|
1212
1232
|
),
|
|
1233
|
+
style: {
|
|
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"
|
|
1238
|
+
},
|
|
1213
1239
|
children: [
|
|
1214
1240
|
/* @__PURE__ */ jsx(
|
|
1215
1241
|
"div",
|
|
1216
1242
|
{
|
|
1217
1243
|
className: cn(
|
|
1218
|
-
"w-full",
|
|
1219
|
-
//
|
|
1220
|
-
mapWrapperClassName
|
|
1244
|
+
"w-full rounded-2xl",
|
|
1245
|
+
// Only apply default height class if mapWrapperClassName not provided
|
|
1246
|
+
!mapWrapperClassName && `h-[${calculatedHeight}px]`,
|
|
1247
|
+
mapWrapperClassName
|
|
1221
1248
|
),
|
|
1222
1249
|
style: {
|
|
1223
|
-
//
|
|
1224
|
-
height: mapWrapperClassName ? void 0 :
|
|
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`,
|
|
1225
1252
|
maxHeight: "100vh",
|
|
1226
1253
|
// Prevent excessive growth
|
|
1227
1254
|
position: "relative",
|
|
1255
|
+
// Keep overflow hidden only on the map wrapper to contain the canvas
|
|
1228
1256
|
overflow: "hidden"
|
|
1229
1257
|
},
|
|
1230
1258
|
children: /* @__PURE__ */ jsx(
|
|
@@ -1250,6 +1278,10 @@ function GeoMap({
|
|
|
1250
1278
|
geolocateControlPosition,
|
|
1251
1279
|
flyToOptions,
|
|
1252
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
|
+
},
|
|
1253
1285
|
children: mapChildren
|
|
1254
1286
|
}
|
|
1255
1287
|
)
|
|
@@ -1259,9 +1291,13 @@ function GeoMap({
|
|
|
1259
1291
|
"div",
|
|
1260
1292
|
{
|
|
1261
1293
|
className: cn(
|
|
1262
|
-
"pointer-events-none absolute z-
|
|
1294
|
+
"pointer-events-none absolute z-30",
|
|
1263
1295
|
PANEL_POSITION_CLASS[panelPosition]
|
|
1264
1296
|
),
|
|
1297
|
+
style: {
|
|
1298
|
+
// Ensure panel can overflow and has higher z-index
|
|
1299
|
+
zIndex: 30
|
|
1300
|
+
},
|
|
1265
1301
|
children: /* @__PURE__ */ jsx("div", { className: "pointer-events-auto", children: renderMarkerPanel() })
|
|
1266
1302
|
}
|
|
1267
1303
|
) : null
|