Files
gokarna/layouts/partials/leaflet-map.html
2022-10-07 18:31:03 +02:00

24 lines
971 B
HTML

{{ $mapLat := default "" .mapLat }}
{{ $mapLon := default "" .mapLon }}
{{ $zoom := default "13" .zoom }}
{{ $mapWidth := default "100%" .mapWidth }}
{{ $mapHeight := default "400px" .mapHeight }}
{{ $mapId := default (md5 (printf "%s%s" $mapLat $mapLon)) .mapId }}
{{ $scrollWheelZoom := default "true" .scrollWheelZoom }}
<!--Container-->
<div id='mapid_{{ $mapId }}' class="leaflet-map" style='width: {{ $mapWidth }}; height: {{ $mapHeight}};'></div>
<script>
//Create Map
leafletMapsObj[{{ $mapId }}] = L.map('mapid_{{ $mapId }}').setView([{{ $mapLat }}, {{ $mapLon }}], {{ $zoom }});
{{ if eq $scrollWheelZoom "false" }}
leafletMapsObj[{{ $mapId }}].scrollWheelZoom.disable();
{{ end }}
//Add tiles
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(leafletMapsObj[{{ $mapId }}]);
</script>