@jackbernnie/hiyf 0.3.4 → 0.3.5
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.
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
* Raw <iframe> map embeds are an off-system escape hatch: every provider URL,
|
|
5
5
|
* viewport shape, loading behavior, and frame treatment would be up for grabs.
|
|
6
6
|
* This wrapper closes it:
|
|
7
|
-
* - Location is expressed only as decimal latitude/longitude with
|
|
8
|
-
*
|
|
7
|
+
* - Location is expressed only as decimal latitude/longitude with a
|
|
8
|
+
* clamped zoom.
|
|
9
9
|
* - The embed always uses the approved responsive 16:9 frame, rounded
|
|
10
|
-
* corners, muted loading surface, and
|
|
10
|
+
* corners, muted loading surface, and a keyless OpenStreetMap embed with
|
|
11
|
+
* a marker pin — reliable for every coordinate (Google's keyless embed is
|
|
12
|
+
* deprecated and renders inconsistently).
|
|
11
13
|
* - NO `className`/`style` escape hatch. Need a new map affordance? Add it
|
|
12
14
|
* here so every map stays on-system.
|
|
13
15
|
*/
|
|
@@ -16,12 +18,10 @@ export interface MapEmbedProps {
|
|
|
16
18
|
lat: number;
|
|
17
19
|
/** Longitude in decimal degrees. */
|
|
18
20
|
lon: number;
|
|
19
|
-
/** Zoom level 1-21. Defaults to 14. */
|
|
21
|
+
/** Zoom level 1-21. Defaults to 14. Controls the size of the map window. */
|
|
20
22
|
zoom?: number;
|
|
21
|
-
/** 'satellite' (default) or 'map'. */
|
|
22
|
-
view?: 'map' | 'satellite';
|
|
23
23
|
/** Accessible title for the embed. Defaults to 'Map'. */
|
|
24
24
|
title?: string;
|
|
25
25
|
}
|
|
26
26
|
/** Closed responsive map embed — no className/style. */
|
|
27
|
-
export declare function MapEmbed({ lat, lon, zoom,
|
|
27
|
+
export declare function MapEmbed({ lat, lon, zoom, title, }: MapEmbedProps): import("react").JSX.Element | null;
|
|
@@ -5,7 +5,6 @@ function MapEmbed({
|
|
|
5
5
|
lat,
|
|
6
6
|
lon,
|
|
7
7
|
zoom = 14,
|
|
8
|
-
view = "satellite",
|
|
9
8
|
title = "Map"
|
|
10
9
|
}) {
|
|
11
10
|
if (!Number.isFinite(lat) || !Number.isFinite(lon)) {
|
|
@@ -13,7 +12,9 @@ function MapEmbed({
|
|
|
13
12
|
}
|
|
14
13
|
const zoomValue = Number.isNaN(zoom) ? 14 : zoom;
|
|
15
14
|
const clampedZoom = Math.min(21, Math.max(1, zoomValue));
|
|
16
|
-
const
|
|
15
|
+
const half = Math.min(20, Math.max(4e-3, 40 / 2 ** clampedZoom));
|
|
16
|
+
const bbox = `${lon - half},${lat - half},${lon + half},${lat + half}`;
|
|
17
|
+
const src = `https://www.openstreetmap.org/export/embed.html?bbox=${bbox}&layer=mapnik&marker=${lat},${lon}`;
|
|
17
18
|
return /* @__PURE__ */ jsx("div", { className: "w-full overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsx(AspectRatio, { ratio: 16 / 9, children: /* @__PURE__ */ jsx(
|
|
18
19
|
"iframe",
|
|
19
20
|
{
|
package/package.json
CHANGED