{{- /* Renders a post's locations on a map. @params pc Page context. @params locations_data Site data of locations. @params locations Post locations. */ -}} {{- if ( not ( isset . "pc" ) ) -}} {{- errorf "No page context passed" -}} {{- end -}} {{- if ( not ( isset . "locations_data" ) ) -}} {{- errorf "No location site data defined" -}} {{- end -}} {{- if ( not ( isset . "locations" ) ) -}} {{- errorf "No post locations defined" -}} {{- end -}} var map = L.map('map').setView([55, -3], 13); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© OpenStreetMap' }).addTo(map); var latLons = []; {{ $locations_leaf_nodes := partialCached "util/get_location_leaf_nodes.html" .locations_data -}} {{- range .locations -}} {{- with ( index $locations_leaf_nodes ( replaceRE `, [A-Z]+` "" . ) ) -}} L.marker([{{ .lat }}, {{ .lon }}]).addTo(map); latLons.push([{{ .lat }}, {{ .lon }}]); {{- else -}} {{- erroridf "missing-lat-lon" "Could not find lat-lon for %q" . -}} {{- end -}} {{- end }} map.fitBounds(latLons);