diff --git a/static/js/map.js b/static/js/map.js index a527585..7bd9a02 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -56,7 +56,16 @@ function emojiIcon(emoji, zoom) { function build_map(map_id, coordinates, routes) { - var map = L.map(map_id).fitBounds(coordinates.map(function(station) { return [station.latitude, station.longitude]; })); + var bounds = coordinates.map(function(station) { return [station.latitude, station.longitude]; }); + if (bounds.length === 0) { + routes.forEach(function(r) { + if (r.from) bounds.push(r.from); + if (r.to) bounds.push(r.to); + }); + } + var map = bounds.length > 0 + ? L.map(map_id).fitBounds(bounds) + : L.map(map_id).setView([20, 0], 2); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' diff --git a/templates/trip_page.html b/templates/trip_page.html index 6b51dee..109449a 100644 --- a/templates/trip_page.html +++ b/templates/trip_page.html @@ -27,7 +27,7 @@ {% block style %} -{% if coordinates %} +{% if coordinates or routes %} {% endif %} @@ -101,7 +101,7 @@ {% block content %}