{{/* Required params. Fail if missing. */}} {{ $apiKey := .Site.Params.geoapifyApiKey }} {{ if not $apiKey }} {{ errorf "Error: 'geoapifyApiKey' is a required site parameter for this shortcode." }} {{ end }} {{ $adr := .Get "address" }} {{ if not $adr }} {{ errorf "Error: 'address' is a required parameter for this shortcode." }} {{ end }} {{ $path := .Get "path" }} {{ if not $path }} {{ errorf "Error: 'path' is a required parameter for this shortcode." }} {{ end }} {{/* Optional params. No error checking. */}} {{ $label := .Get "label" }} {{ $url := .Get "url" }} {{ $adrURL := urlquery $adr }} {{ $LLapiURL := printf "https://api.geoapify.com/v1/geocode/search?text=%s&format=json&apiKey=%s" $adrURL $apiKey }} {{ $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 }}
{{ with resources.GetRemote $MapApiUrl }} {{ with resources.Copy $path . }} {{ with .Err }} {{ errorf "%s" . }} {{ else }} {{ end }} {{ else }} {{ errorf "Unable to get remote resource %q" $MapApiUrl }} {{ end }} {{ end }}
{{ with $label }}

{{ $label }}

{{ end }}

{{ .address_line1 }}
{{ replaceRE `, United States of America$` "" .address_line2 }}

{{end}}
{{ with $url }} See on Google Maps {{ end }}