summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-01-08 21:27:32 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-01-08 21:27:32 +0100
commit240976e8056624ee93f858829b75e33993561c24 (patch)
treefd032ce45ef20187be2ee5023b0aa965365e8102
parent8af56f340b6af2684fe4365bc33b478e56654a2b (diff)
show station location in map2.5.9
-rw-r--r--lib/DBInfoscreen/Controller/Map.pm26
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm1
-rw-r--r--public/static/leaflet/images/marker-icon-2x-gold.pngbin0 -> 4274 bytes
-rw-r--r--public/static/leaflet/images/marker-icon-2x-green.pngbin0 -> 4203 bytes
-rw-r--r--templates/_train_details.html.ep2
-rw-r--r--templates/route_map.html.ep25
6 files changed, 52 insertions, 2 deletions
diff --git a/lib/DBInfoscreen/Controller/Map.pm b/lib/DBInfoscreen/Controller/Map.pm
index 70b2644..6ab2c32 100644
--- a/lib/DBInfoscreen/Controller/Map.pm
+++ b/lib/DBInfoscreen/Controller/Map.pm
@@ -68,6 +68,9 @@ sub route {
my $trip_id = $self->stash('tripid');
my $line_no = $self->stash('lineno');
+ my $from_name = $self->param('from');
+ my $to_name = $self->param('to');
+
$self->render_later;
$self->get_hafas_polyline_p( $trip_id, $line_no )->then(
@@ -102,6 +105,29 @@ sub route {
my @stop_lines = ( $stop->{stop}{name} );
my ( $platform, $arr, $dep, $arr_delay, $dep_delay );
+ if ( $from_name and $stop->{stop}{name} eq $from_name ) {
+ push(
+ @markers,
+ {
+ lon => $stop->{stop}{location}{longitude},
+ lat => $stop->{stop}{location}{latitude},
+ title => $stop->{stop}{name},
+ icon => 'greenIcon',
+ }
+ );
+ }
+ if ( $to_name and $stop->{stop}{name} eq $to_name ) {
+ push(
+ @markers,
+ {
+ lon => $stop->{stop}{location}{longitude},
+ lat => $stop->{stop}{location}{latitude},
+ title => $stop->{stop}{name},
+ icon => 'goldIcon',
+ }
+ );
+ }
+
if ( $stop->{arrival}
and $arr = $strp->parse_datetime( $stop->{arrival} ) )
{
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 797cde9..59ee48d 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -1273,6 +1273,7 @@ sub handle_request {
linetype => $linetype,
icetype => $self->app->ice_type_map->{ $departure->{train_no} },
dt_now => DateTime->now( time_zone => 'Europe/Berlin' ),
+ station_name => $data->{station_name} // $station,
);
}
else {
diff --git a/public/static/leaflet/images/marker-icon-2x-gold.png b/public/static/leaflet/images/marker-icon-2x-gold.png
new file mode 100644
index 0000000..6992d65
--- /dev/null
+++ b/public/static/leaflet/images/marker-icon-2x-gold.png
Binary files differ
diff --git a/public/static/leaflet/images/marker-icon-2x-green.png b/public/static/leaflet/images/marker-icon-2x-green.png
new file mode 100644
index 0000000..c359abb
--- /dev/null
+++ b/public/static/leaflet/images/marker-icon-2x-green.png
Binary files differ
diff --git a/templates/_train_details.html.ep b/templates/_train_details.html.ep
index 0ace74c..4a4738d 100644
--- a/templates/_train_details.html.ep
+++ b/templates/_train_details.html.ep
@@ -85,7 +85,7 @@
% }
% if ($departure->{trip_id}) {
<div class="verbose">
- <a href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>">Karte</a>
+ <a href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>?from=<%= $station_name %>">Karte</a>
</div>
% }
diff --git a/templates/route_map.html.ep b/templates/route_map.html.ep
index 6fc4201..8cdf630 100644
--- a/templates/route_map.html.ep
+++ b/templates/route_map.html.ep
@@ -98,9 +98,32 @@ for (var station_id in stations) {
}).bindPopup(stations[station_id][1].join('<br/>')).addTo(map);
}
+var greenIcon = new L.Icon({
+ iconUrl: '/static/leaflet/images/marker-icon-2x-green.png',
+ shadowUrl: '/static/leaflet/images/marker-shadow.png',
+ iconSize: [25, 41],
+ iconAnchor: [12, 41],
+ popupAnchor: [1, -34],
+ shadowSize: [41, 41]
+});
+
+var goldIcon = new L.Icon({
+ iconUrl: '/static/leaflet/images/marker-icon-2x-gold.png',
+ shadowUrl: '/static/leaflet/images/marker-shadow.png',
+ iconSize: [25, 41],
+ iconAnchor: [12, 41],
+ popupAnchor: [1, -34],
+ shadowSize: [41, 41]
+});
+
var marker;
% for my $marker (@{stash('markers') // [] } ) {
- marker = L.marker([<%= $marker->{lat} %>,<%= $marker->{lon} %>]).addTo(map);
+ % if ($marker->{icon}) {
+ marker = L.marker([<%= $marker->{lat} %>,<%= $marker->{lon} %>], {icon: <%= $marker->{icon} %>}).addTo(map);
+ % }
+ % else {
+ marker = L.marker([<%= $marker->{lat} %>,<%= $marker->{lon} %>]).addTo(map);
+ % }
% if ($marker->{title}) {
marker.bindPopup('<%= $marker->{title} %>');
% }