mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-02 09:43:12 +00:00
Vendors and Sites now build the keyless embed URL and the Open in Google Maps link through one helper. The Site map shows the placeholder only in the Add/Edit forms; view mode and the Work Order Site dialog always render it for the saved address, the dialog in its compact form.
28 lines
1.1 KiB
TypeScript
28 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` : "";
|
|
}
|