2024-02-06 04:24:17 +00:00
|
|
|
{{/* Required params. Fail if missing. */}}
|
2024-02-05 11:39:47 +00:00
|
|
|
|
2024-02-12 18:00:10 +00:00
|
|
|
{{ $apiKey := .Site.Params.geoapifyApiKey }}
|
2024-02-06 04:24:17 +00:00
|
|
|
{{ if not $apiKey }}
|
2024-02-12 18:00:10 +00:00
|
|
|
{{ errorf "Error: 'geoapifyApiKey' is a required site parameter for this shortcode." }}
|
2024-02-06 04:24:17 +00:00
|
|
|
{{ end }}
|
2024-02-05 11:39:47 +00:00
|
|
|
|
2024-02-06 04:24:17 +00:00
|
|
|
{{ $adr := .Get "address" }}
|
|
|
|
{{ if not $adr }}
|
|
|
|
{{ errorf "Error: 'address' is a required parameter for this shortcode." }}
|
|
|
|
{{ end }}
|
2024-02-05 11:39:47 +00:00
|
|
|
|
2024-02-06 04:24:17 +00:00
|
|
|
{{ $path := .Get "path" }}
|
|
|
|
{{ if not $path }}
|
|
|
|
{{ errorf "Error: 'path' is a required parameter for this shortcode." }}
|
|
|
|
{{ end }}
|
2024-02-05 11:39:47 +00:00
|
|
|
|
2024-02-06 04:24:17 +00:00
|
|
|
{{/* Optional params. No error checking. */}}
|
2024-02-05 11:39:47 +00:00
|
|
|
{{ $label := .Get "label" }}
|
2024-02-05 21:11:28 +00:00
|
|
|
{{ $url := .Get "url" }}
|
2024-02-05 11:39:47 +00:00
|
|
|
|
2024-02-06 04:24:17 +00:00
|
|
|
|
|
|
|
{{ $adrURL := urlquery $adr }}
|
|
|
|
{{ $LLapiURL := printf "https://api.geoapify.com/v1/geocode/search?text=%s&format=json&apiKey=%s" $adrURL $apiKey }}
|
2024-02-05 11:39:47 +00:00
|
|
|
{{ $data := getJSON $LLapiURL }}
|
|
|
|
{{ with index $data.results 0 }}
|
|
|
|
{{ $lon := .lon }}
|
|
|
|
{{ $lat := .lat }}
|
|
|
|
{{ $MapApiUrl := printf "https://maps.geoapify.com/v1/staticmap?style=osm-bright&width=500&height=500¢er=lonlat:%f,%f&zoom=12&marker=lonlat:%f,%f;color:%%23ff0000;size:medium&scaleFactor=2&apiKey=%s" $lon $lat $lon $lat $apiKey }}
|
2024-02-07 05:16:34 +00:00
|
|
|
<blockquote class="location">
|
2024-02-06 04:24:17 +00:00
|
|
|
<div class="map" >
|
|
|
|
{{ with resources.GetRemote $MapApiUrl }}
|
|
|
|
{{ with resources.Copy $path . }}
|
|
|
|
{{ with .Err }}
|
|
|
|
{{ errorf "%s" . }}
|
|
|
|
{{ else }}
|
|
|
|
<img src="{{ .RelPermalink }}" width=350px />
|
|
|
|
{{ end }}
|
|
|
|
{{ else }}
|
|
|
|
{{ errorf "Unable to get remote resource %q" $MapApiUrl }}
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
2024-02-05 11:39:47 +00:00
|
|
|
|
|
|
|
<div class="map-txt-grid">
|
2024-02-05 21:11:28 +00:00
|
|
|
<div class="grid-item">
|
|
|
|
{{ with $label }}
|
|
|
|
<p><b>{{ $label }}</b></p>
|
|
|
|
{{ end }}
|
|
|
|
</div>
|
2024-02-05 11:39:47 +00:00
|
|
|
<div class="grid-item"><p>{{ .address_line1 }}<br/>{{ replaceRE `, United States of America$` "" .address_line2 }}</p></div>
|
|
|
|
{{end}}
|
|
|
|
<div class="grid-item">
|
|
|
|
<div class="child-element">
|
2024-02-05 21:11:28 +00:00
|
|
|
{{ with $url }}
|
2024-03-02 02:34:32 +00:00
|
|
|
<a class="button" href="{{ $url }}" target="_blank">See on Google Maps</a>
|
2024-02-05 21:11:28 +00:00
|
|
|
{{ end }}
|
2024-02-05 11:39:47 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-02-06 21:02:29 +00:00
|
|
|
</blockquote>
|