diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-11-16 15:57:09 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-11-16 15:57:09 +0100 |
commit | 733fe2d853cc2aa4f759d2454171e17409551dfb (patch) | |
tree | 9fb64d2f26d87e203234c7da8ed722f8f8608158 /templates/_map.html.ep | |
parent | 77e4998708a31d38e4d04f185c9fc12e26245d2c (diff) |
map: add legend, link to history map from history page
Diffstat (limited to 'templates/_map.html.ep')
-rw-r--r-- | templates/_map.html.ep | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/templates/_map.html.ep b/templates/_map.html.ep new file mode 100644 index 0000000..cceec01 --- /dev/null +++ b/templates/_map.html.ep @@ -0,0 +1,48 @@ +<div class="row"> + <div class="col s12"> + <div id="map" style="height: 500px;"> + </div> + </div> +</div> + +<div class="row"> + <div class="col s12"> + <span style="color: #f03;">●</span> Ein-/Ausstiegsstation<br/> + <span style="color: #f09;">—</span> Luftlinie zwischen Unterwegshalten + </div> +</div> + +<script> +var map = L.map('map').setView([51.306, 9.712], 6); + +L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' +}).addTo(map); + +var stations = [ +% for my $station ( @{stash('station_coordinates') // [] } ) { +[[<%= $station->[0][0] %>,<%= $station->[0][1] %>],'<%= $station->[1] %>'], +% } +]; + +var routes = [ +% for my $pair ( @{stash('station_pairs') // [] } ) { +[[<%= $pair->[0][0] %>,<%= $pair->[0][1] %>],[<%= $pair->[1][0] %>,<%= $pair->[1][1] %>]], +% } +]; + +for (var station_id in stations) { + L.circle(stations[station_id][0], { + color: '#f03', + fillColor: '#f03', + fillOpacity: 0.5, + radius: 250 + }).bindPopup(stations[station_id][1]).addTo(map); +} + +var pl = L.polyline(routes, {color: '#f09', opacity: 0.5}).addTo(map); +if (routes.length) { + map.fitBounds(pl.getBounds()); +} + +</script> |