diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-05-10 12:21:32 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-05-10 12:21:32 +0200 |
commit | 6c37dec8ed54a987acb6665fb6525a39fc6ca5da (patch) | |
tree | 290e831d119697ff4dd84468e256766c63fd57f2 /index.pl | |
parent | e09a676a9fac68feca73caffea792c4f0f8eef38 (diff) |
geolocation playground
Diffstat (limited to 'index.pl')
-rw-r--r-- | index.pl | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -810,6 +810,28 @@ get '/_redirect' => sub { } }; +get '/_auto' => sub { + my $self = shift; + + $self->render('geolocation', with_geolocation => 1, hide_opts => 1); +}; + +post '/_geolocation' => sub { + my $self = shift; + + my $lon = $self->param('lon'); + my $lat = $self->param('lat'); + + if (not $lon or not $lat) { + $self->render(json => {error => 'Invalid lon/lat received'}); + } + else { + $self->render(json => { + candidates => [ Travel::Status::DE::IRIS::Stations::get_stations_by_location($lon, $lat, 10) ], + }); + } +}; + app->defaults( layout => 'default' ); get '/' => \&handle_request; |