aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Map.pm')
-rw-r--r--perllib/FixMyStreet/Map.pm18
1 files changed, 12 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index 46a098117..e0e3c3128 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -88,15 +88,21 @@ sub map_features {
$p{latitude} = ($p{max_lat} + $p{min_lat} ) / 2;
}
- my $on_map = $c->cobrand->problems_on_map->around_map( %p );
+ $p{page} = $c->get_param('p') || 1;
+ my $on_map = $c->cobrand->problems_on_map->around_map( $c, %p );
+ my $pager = $c->stash->{pager} = $on_map->pager;
+ $on_map = [ $on_map->all ];
my $dist = FixMyStreet::Gaze::get_radius_containing_population( $p{latitude}, $p{longitude} );
- my $limit = 20;
- my @ids = map { $_->id } @$on_map;
- my $nearby = $c->model('DB::Nearby')->nearby(
- $c, $dist, \@ids, $limit, @p{"latitude", "longitude", "categories", "states"}
- );
+ my $nearby;
+ if (@$on_map < $pager->entries_per_page && $pager->current_page == 1) {
+ my $limit = 20;
+ my @ids = map { $_->id } @$on_map;
+ $nearby = $c->model('DB::Nearby')->nearby(
+ $c, $dist, \@ids, $limit, @p{"latitude", "longitude", "categories", "states"}
+ );
+ }
return ( $on_map, $nearby, $dist );
}