mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-05 03:42:08 +00:00
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
|
|
/**
|
||
|
|
* Google Maps URLs shared by every address preview and address link.
|
||
|
|
*
|
||
|
|
* Each caller composes its own one-line address (Vendors join the parts with
|
||
|
|
* spaces, Sites use the same line as their Street Address link); these helpers
|
||
|
|
* only encode it into the URL shape Google expects. Both return an empty string
|
||
|
|
* for a blank query, so callers can skip rendering instead of pointing at an
|
||
|
|
* empty search.
|
||
|
|
*/
|
||
|
|
|
||
|
|
/** Link target that opens full Google Maps in a new tab. */
|
||
|
|
export function googleMapsSearchUrl(query: string): string {
|
||
|
|
const trimmed = query.trim();
|
||
|
|
return trimmed
|
||
|
|
? `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(trimmed)}`
|
||
|
|
: "";
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Iframe source for the read-only inline preview.
|
||
|
|
*
|
||
|
|
* `output=embed` is Google's keyless form: no API key, no billing account and
|
||
|
|
* no Places request, and the embed brings its own "View larger map" link.
|
||
|
|
*/
|
||
|
|
export function googleMapsEmbedUrl(query: string): string {
|
||
|
|
const trimmed = query.trim();
|
||
|
|
return trimmed ? `https://www.google.com/maps?q=${encodeURIComponent(trimmed)}&output=embed` : "";
|
||
|
|
}
|