From 6c37dec8ed54a987acb6665fb6525a39fc6ca5da Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 10 May 2016 12:21:32 +0200 Subject: geolocation playground --- index.pl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'index.pl') diff --git a/index.pl b/index.pl index 543bcd1..155fd18 100644 --- a/index.pl +++ b/index.pl @@ -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; -- cgit v1.2.3