aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Around.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Around.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm46
1 files changed, 25 insertions, 21 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 6af780c35..d1bf2d950 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -33,19 +33,24 @@ If no search redirect back to the homepage.
sub index : Path : Args(0) {
my ( $self, $c ) = @_;
- # handle old coord systems
- $c->forward('redirect_en_or_xy_to_latlon');
-
- # Check if we have a partial report
- my $partial_report = $c->forward('load_partial');
+ if ($c->get_param('ajax')) {
+ $c->detach('ajax');
+ }
# Check if the user is searching for a report by ID
if ( $c->get_param('pc') && $c->get_param('pc') =~ $c->cobrand->lookup_by_ref_regex ) {
$c->go('lookup_by_ref', [ $1 ]);
}
+ # handle old coord systems
+ $c->forward('redirect_en_or_xy_to_latlon');
+
+ # Check if we have a partial report
+ my $partial_report = $c->forward('load_partial');
+
# Try to create a location for whatever we have
- my $ret = $c->forward('/location/determine_location_from_coords')
+ my $ret = $c->forward('/location/determine_location_from_bbox')
+ || $c->forward('/location/determine_location_from_coords')
|| $c->forward('/location/determine_location_from_pc');
unless ($ret) {
return $c->res->redirect('/') unless $c->get_param('pc') || $partial_report;
@@ -170,7 +175,11 @@ sub display_location : Private {
my $latitude = $c->stash->{latitude};
my $longitude = $c->stash->{longitude};
- $c->forward('map_features', [ { latitude => $latitude, longitude => $longitude } ] );
+ if (my $bbox = $c->stash->{bbox}) {
+ $c->forward('map_features', [ { bbox => $bbox } ]);
+ } else {
+ $c->forward('map_features', [ { latitude => $latitude, longitude => $longitude } ]);
+ }
FixMyStreet::Map::display_map(
$c,
@@ -245,16 +254,11 @@ sub map_features : Private {
$c->forward( '/reports/stash_report_filter_status' );
$c->forward( '/reports/stash_report_sort', [ 'created-desc' ]);
- # Deal with pin hiding/age
- my $all_pins = $c->get_param('all_pins') ? 1 : undef;
- $c->stash->{all_pins} = $all_pins;
- my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age;
-
return if $c->get_param('js'); # JS will request the same (or more) data client side
- my ( $on_map_all, $on_map_list, $nearby, $distance ) =
+ my ( $on_map, $nearby, $distance ) =
FixMyStreet::Map::map_features(
- $c, interval => $interval, %$extra,
+ $c, %$extra,
categories => [ keys %{$c->stash->{filter_category}} ],
states => $c->stash->{filter_problem_states},
order => $c->stash->{sort_order},
@@ -266,16 +270,16 @@ sub map_features : Private {
# Here we might have a DB::Problem or a DB::Result::Nearby, we always want the problem.
my $p = (ref $_ eq 'FixMyStreet::DB::Result::Nearby') ? $_->problem : $_;
$p->pin_data($c, 'around');
- } @$on_map_all, @$nearby;
+ } @$on_map, @$nearby;
}
$c->stash->{pins} = \@pins;
- $c->stash->{on_map} = $on_map_list;
+ $c->stash->{on_map} = $on_map;
$c->stash->{around_map} = $nearby;
$c->stash->{distance} = $distance;
}
-=head2 /ajax
+=head2 ajax
Handle the ajax calls that the map makes when it is dragged. The info returned
is used to update the pins on the map and the text descriptions on the side of
@@ -283,11 +287,11 @@ the map.
=cut
-sub ajax : Path('/ajax') {
+sub ajax : Private {
my ( $self, $c ) = @_;
- my $bbox = $c->get_param('bbox');
- unless ($bbox) {
+ my $ret = $c->forward('/location/determine_location_from_bbox');
+ unless ($ret) {
$c->res->status(404);
$c->res->body('');
return;
@@ -296,7 +300,7 @@ sub ajax : Path('/ajax') {
my %valid_categories = map { $_ => 1 } $c->get_param_list('filter_category', 1);
$c->stash->{filter_category} = \%valid_categories;
- $c->forward('map_features', [ { bbox => $bbox } ]);
+ $c->forward('map_features', [ { bbox => $c->stash->{bbox} } ]);
$c->forward('/reports/ajax', [ 'around/on_map_list_items.html' ]);
}