diff options
author | Dave Arter <davea@mysociety.org> | 2020-05-20 17:50:01 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-06-17 18:33:05 +0100 |
commit | cbe3e9a5af21cef3774585dd489aaedbe7a564bc (patch) | |
tree | f4e5b8f9bfd68b06ec42d883d5ab70a9d356c231 | |
parent | 9553c8daac73f06af704a87ace7294f751a77b8f (diff) |
Map should respect cobrand default zoom, if set.
This brings the behaviour of the code in line with the comment
on Cobrand:Default::default_map_zoom
-rw-r--r-- | perllib/FixMyStreet/Map/OSM.pm | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm index ef465d7dc..417fdca0b 100644 --- a/perllib/FixMyStreet/Map/OSM.pm +++ b/perllib/FixMyStreet/Map/OSM.pm @@ -77,11 +77,16 @@ sub generate_map_data { $zoomOffset = 0; } - # Adjust zoom level dependent upon population density - my $dist = $data->{distance} - || FixMyStreet::Gaze::get_radius_containing_population( $params{latitude}, $params{longitude} ); - my $default_zoom = $data->{cobrand}->default_map_zoom() || ($numZoomLevels - 4); - $default_zoom = $numZoomLevels - 3 if $dist < 10; + # Adjust zoom level dependent upon population density if cobrand hasn't + # specified a default zoom. + my $default_zoom; + if (my $cobrand_default_zoom = $data->{cobrand}->default_map_zoom) { + $default_zoom = $cobrand_default_zoom; + } else { + my $dist = $data->{distance} + || FixMyStreet::Gaze::get_radius_containing_population( $params{latitude}, $params{longitude} ); + $default_zoom = $dist < 10 ? $numZoomLevels - 3 : $numZoomLevels - 4; + } my $zoom = $data->{zoom} || $default_zoom; $zoom = $numZoomLevels - 1 if $zoom >= $numZoomLevels; |