Hide map on trip page when there are no coordinates or routes
Closes #205 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
76360c25f3
commit
3ba18f9019
2 changed files with 16 additions and 4 deletions
|
|
@ -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: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue