From aa7a7db2bcd6ae8cf0caef37d436bcb2ae162d5b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 31 Jan 2020 18:16:00 +0100 Subject: [PATCH] map: show polylines by default --- lib/Travelynx.pm | 1 - lib/Travelynx/Controller/Traveling.pm | 23 +++++++++++++++---- templates/_map.html.ep | 2 +- templates/history_map.html.ep | 32 ++++++++++++++++++++++++--- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index f44bb8a..117724f 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -3641,7 +3641,6 @@ sub startup { $authed_r->post('/account/privacy')->to('account#privacy'); $authed_r->post('/account/hooks')->to('account#webhook'); $authed_r->post('/account/insight')->to('account#insight'); - $authed_r->post('/history/map')->to('traveling#map_history'); $authed_r->post('/journey/add')->to('traveling#add_journey_form'); $authed_r->post('/journey/comment')->to('traveling#comment_form'); $authed_r->post('/journey/edit')->to('traveling#edit_journey'); diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 4d3c7d5..e294c8c 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -439,7 +439,12 @@ sub map_history { my $location = $self->app->coordinates_by_station; - my $with_polyline = $self->param('poly') ? 1 : 0; + if ( not $self->param('route_type') ) { + $self->param( route_type => 'polybee' ); + } + + my $route_type = $self->param('route_type'); + my $with_polyline = $route_type eq 'beeline' ? 0 : 1; my @journeys = $self->get_user_travels( with_polyline => $with_polyline ); @@ -470,8 +475,18 @@ sub map_history { my %seen; my @skipped_journeys; + my @polyline_journeys = grep { $_->{polyline} } @journeys; + my @beeline_journeys = grep { not $_->{polyline} } @journeys; - for my $journey ( grep { $_->{polyline} } @journeys ) { + if ( $route_type eq 'polyline' ) { + @beeline_journeys = (); + } + elsif ( $route_type eq 'beeline' ) { + push( @beeline_journeys, @polyline_journeys ); + @polyline_journeys = (); + } + + for my $journey (@polyline_journeys) { my @polyline = @{ $journey->{polyline} }; my $from_eva = $journey->{from_eva}; my $to_eva = $journey->{to_eva}; @@ -514,7 +529,7 @@ sub map_history { } } - for my $journey ( grep { not $_->{polyline} } @journeys ) { + for my $journey (@beeline_journeys) { my @route = map { $_->[0] } @{ $journey->{route} }; @@ -612,7 +627,7 @@ sub map_history { { polylines => \@coord_pairs, color => '#673ab7', - opacity => 0.9, + opacity => 0.8, } ], bounds => [ [ $min_lat, $min_lon ], [ $max_lat, $max_lon ] ], diff --git a/templates/_map.html.ep b/templates/_map.html.ep index 3918b4a..2e6dad8 100644 --- a/templates/_map.html.ep +++ b/templates/_map.html.ep @@ -8,7 +8,7 @@
Ein-/Ausstiegsstation
- Luftlinie zwischen Unterwegshalten + Streckenverlauf oder Luftlinie
diff --git a/templates/history_map.html.ep b/templates/history_map.html.ep index c0eea4c..51f002e 100644 --- a/templates/history_map.html.ep +++ b/templates/history_map.html.ep @@ -11,8 +11,34 @@ %= include '_map', station_coordinates => $station_coordinates, polyline_groups => $polyline_groups -%= form_for '/history/map' => (method => 'POST') => begin - %= csrf_field +%= form_for '/history/map' => begin +

+ Detailgrad und Filter: +

+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
-