diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-02-23 19:04:05 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-02-23 19:04:05 +0100 |
commit | 5c05ed609f3033fa97ec00089ed6885034ad9405 (patch) | |
tree | d0b1edf39cd4f0bbccca70d48e00d4db3cd17a9e /lib | |
parent | 82f043e734cfbe1f166a4864afc5db5eb19080f9 (diff) |
journey details: show route on map if available1.15.1
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/Travelynx.pm | 25 | ||||
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 16 |
2 files changed, 28 insertions, 13 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 9ab597d..538ec29 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -3726,16 +3726,7 @@ sub startup { = map { [ $location->{ $_->[0] }, $location->{ $_->[1] } ] } @station_pairs; - my @routes; - - my @lats = map { $_->[0][0] } @station_coordinates; - my @lons = map { $_->[0][1] } @station_coordinates; - my $min_lat = List::Util::min @lats; - my $max_lat = List::Util::max @lats; - my $min_lon = List::Util::min @lons; - my $max_lon = List::Util::max @lons; - - return { + my $ret = { skipped_journeys => \@skipped_journeys, station_coordinates => \@station_coordinates, polyline_groups => [ @@ -3750,8 +3741,20 @@ sub startup { opacity => 0.8, } ], - bounds => [ [ $min_lat, $min_lon ], [ $max_lat, $max_lon ] ], }; + + if (@station_coordinates) { + my @lats = map { $_->[0][0] } @station_coordinates; + my @lons = map { $_->[0][1] } @station_coordinates; + my $min_lat = List::Util::min @lats; + my $max_lat = List::Util::max @lats; + my $min_lon = List::Util::min @lons; + my $max_lon = List::Util::max @lons; + $ret->{bounds} + = [ [ $min_lat, $min_lon ], [ $max_lat, $max_lon ] ]; + } + + return $ret; } ); diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index d830d2b..37fad09 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -119,12 +119,18 @@ sub user_status { if ( not $user->{public_level} & 0x04 ) { delete $journey->{user_data}{comment}; } + my $map_data = $self->journeys_to_map_data( + journeys => [$journey], + include_manual => 1, + ); $self->render( 'journey', error => undef, + with_map => 1, readonly => 1, journey => $journey, twitter => \%tw_data, + %{$map_data}, ); } else { @@ -665,10 +671,16 @@ sub journey_details { ); if ($journey) { + my $map_data = $self->journeys_to_map_data( + journeys => [$journey], + include_manual => 1, + ); $self->render( 'journey', - error => undef, - journey => $journey, + error => undef, + journey => $journey, + with_map => 1, + %{$map_data}, ); } else { |