diff options
author | Struan Donald <struan@exo.org.uk> | 2011-08-17 22:56:37 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-08-17 22:56:37 +0100 |
commit | 3b5d561700b184c20e63111d4cbc1daab78e16c6 (patch) | |
tree | f0c53c6bf8d4ebf12e5388053ad856fb0d0e7b86 /perllib/FixMyStreet/App/Controller/Around.pm | |
parent | 390f8e8ad1e10f832c4323c39bed2c883744a03f (diff) | |
parent | f38b8e985697c35a62374a2f02dce2d681ef58cd (diff) |
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet into new_statuses
Conflicts:
db/schema.sql
perllib/FixMyStreet/App/Controller/Admin.pm
perllib/FixMyStreet/DB/Result/User.pm
t/app/controller/admin.t
templates/web/default/admin/update_edit.html
web/css/core.css
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Around.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 660585454..d3a4500c6 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -172,7 +172,7 @@ sub display_location : Private { # get the map features my ( $on_map_all, $on_map, $around_map, $distance ) = - FixMyStreet::Map::map_features( $c, $latitude, $longitude, + FixMyStreet::Map::map_features( $c, $short_latitude, $short_longitude, $interval ); # copy the found reports to the stash @@ -199,8 +199,8 @@ sub display_location : Private { $c->stash->{page} = 'around'; # So the map knows to make clickable pins, update on pan FixMyStreet::Map::display_map( $c, - latitude => $latitude, - longitude => $longitude, + latitude => $short_latitude, + longitude => $short_longitude, clickable => 1, pins => \@pins, ); @@ -235,14 +235,23 @@ the map. sub ajax : Path('/ajax') { my ( $self, $c ) = @_; + $c->res->content_type('text/javascript; charset=utf-8'); + + unless ( $c->req->param('bbox') ) { + $c->res->status(404); + $c->res->body(''); + return; + } + + # assume this is not cacheable - may need to be more fine-grained later + $c->res->header( 'Cache_Control' => 'max-age=0' ); + # how far back should we go? my $all_pins = $c->req->param('all_pins') ? 1 : undef; my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age; # Need to be the class that can handle it - if ($c->req->param('bbox')) { - FixMyStreet::Map::set_map_class( 'OSM' ); - } + FixMyStreet::Map::set_map_class( 'OSM' ); # extract the data from the map my ( $pins, $on_map, $around_map, $dist ) = @@ -260,7 +269,7 @@ sub ajax : Path('/ajax') { ); # JSON encode the response - my $body = JSON->new->utf8(1)->pretty(1)->encode( + my $body = JSON->new->utf8(1)->encode( { pins => $pins, current => $on_map_list_html, @@ -268,16 +277,7 @@ sub ajax : Path('/ajax') { } ); - # assume this is not cacheable - may need to be more fine-grained later - $c->res->content_type('text/javascript; charset=utf-8'); - $c->res->header( 'Cache_Control' => 'max-age=0' ); - - if ( $c->req->param('bbox') ) { - $c->res->body($body); - } else { - # The JS needs the surrounding brackets for Tilma - $c->res->body("($body)"); - } + $c->res->body($body); } __PACKAGE__->meta->make_immutable; |