Omphaloskepsis-2/layouts/partials/cv/locations/heatmap.js

51 lines
1.4 KiB
JavaScript
Raw Normal View History

2025-02-20 01:23:36 +01:00
{{/*
2025-01-05 17:28:42 +01:00
Recursively render an ordered or unordered list from a set of arbitrarily-
deeply-nested items.
@params all_pages All site pages
2025-02-20 01:23:36 +01:00
@params locations All locations
*/}}
2025-01-05 17:28:42 +01:00
2025-02-20 01:23:36 +01:00
<script>
var map = L.map('map', {
fullscreenControl: true
}).setView([55, -3], 3);
2025-01-05 17:28:42 +01:00
2025-02-20 01:23:36 +01:00
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
2025-01-05 17:28:42 +01:00
2025-02-20 01:23:36 +01:00
{{- $locations := partialCached "util/get_location_leaf_nodes.html" .locations -}}
2025-01-05 17:28:42 +01:00
2025-02-20 01:23:36 +01:00
{{/*
{{- range .Site.AllPages -}}
2025-01-05 17:28:42 +01:00
{{- with .Params.locations -}}
{{- range . -}}
{{- with ( index $locations ( replaceRE `, [A-Z]+` "" . ) ) -}}
2025-02-20 01:23:36 +01:00
L.marker([{{ .lat }}, {{ .lon }}]).addTo(map);
{{- end -}}
2025-01-05 17:28:42 +01:00
{{- end -}}
{{- end -}}
{{- end -}}
2025-02-20 01:23:36 +01:00
*/}}
L.heatLayer(
[
{{- range .all_pages -}}
{{- with .Params.locations -}}
{{- range . -}}
{{- with ( index $locations ( replaceRE `, [A-Z]+` "" . ) ) -}}
[ {{ .lat }}, {{ .lon }} ],
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
],
{
minOpacity: 0.5,
gradient: {0.1: 'blue', 0.3: 'lime', 0.8: 'orange', 1: 'red'}
}
).addTo(map);
</script>