Add Map in Posts
This commit is contained in:
23
layouts/partials/leaflet-map.html
Normal file
23
layouts/partials/leaflet-map.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{{ $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: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(leafletMapsObj[{{ $mapId }}]);
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user