jakubb-hugo/layouts/shortcodes/maps.html

35 lines
1.1 KiB
HTML
Raw Normal View History

2024-02-05 11:39:47 +00:00
<div class="location" >
<link rel="stylesheet" href="{{ "/css/maps.css" | relURL }}" />
<div class="map" >
{{ $apiKey := .Site.Params.apiKey }}
{{ $label := .Get "label" }}
{{ $adr := .Get "address" }}
{{ $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&center=lonlat:%f,%f&zoom=12&marker=lonlat:%f,%f;color:%%23ff0000;size:medium&scaleFactor=2&apiKey=%s" $lon $lat $lon $lat $apiKey }}
<img src="{{ $MapApiUrl }}" width=350px />
<div class="map-txt-grid">
<div class="grid-item"><p><b>{{ $label }}</b></p></div>
<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">
<a class="map-button" href="{{ .Get "url" }}" target="_blank">See on Google Maps</a>
</div>
</div>
</div>
</div>
</div>