diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 19 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FiksGataMi.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/FMS.pm (renamed from perllib/FixMyStreet/Map/BingOL.pm) | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/OSM.pm | 2 | ||||
-rw-r--r-- | t/app/uri_for.t | 6 | ||||
-rw-r--r-- | web/js/map-OpenLayers.js | 2 |
6 files changed, 29 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 2f0833a0a..4c7d7438a 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -396,9 +396,26 @@ sub extra_update_meta_text { '' } Given a URL ($_[1]), QUERY, EXTRA_DATA, return a URL with any extra params needed appended to it. +In the default case, if we're using an OpenLayers map, we need to make +sure zoom is always present if lat/lon are, to stop OpenLayers defaulting +to null/0. + =cut -sub uri { $_[1] } # passthrough unchanged +sub uri { + my ( $self, $uri ) = @_; + + (my $map_class = $FixMyStreet::Map::map_class) =~ s/^FixMyStreet::Map:://; + return $uri unless $map_class =~ /OSM|FMS/; + + $uri = URI->new( $uri ); + $uri->query_param( zoom => 3 ) + if $uri->query_param('lat') && !$uri->query_param('zoom'); + $uri->query_param( map => $map_class ); # FIXME Only on /around, /report? + + return $uri; +} + =head2 header_params diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm index adb044493..242c41cc8 100644 --- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm +++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm @@ -41,7 +41,7 @@ sub uri { my ( $self, $uri ) = @_; $uri = URI->new( $uri ); - $uri->query_param( zoom => 2 ) + $uri->query_param( zoom => 3 ) if $uri->query_param('lat') && !$uri->query_param('zoom'); return $uri; diff --git a/perllib/FixMyStreet/Map/BingOL.pm b/perllib/FixMyStreet/Map/FMS.pm index 94df6fff9..f4dd31b61 100644 --- a/perllib/FixMyStreet/Map/BingOL.pm +++ b/perllib/FixMyStreet/Map/FMS.pm @@ -1,12 +1,12 @@ #!/usr/bin/perl # -# FixMyStreet:Map::BingOL -# Bing maps on FixMyStreet, using OpenLayers. +# FixMyStreet:Map::FMS +# Bing and OS StreetView maps on FixMyStreet, using OpenLayers. # # Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ -package FixMyStreet::Map::BingOL; +package FixMyStreet::Map::FMS; use base 'FixMyStreet::Map::OSM'; use strict; diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm index 363f4b01e..862c618f8 100644 --- a/perllib/FixMyStreet/Map/OSM.pm +++ b/perllib/FixMyStreet/Map/OSM.pm @@ -166,7 +166,7 @@ sub click_to_wgs84 { my ($self, $c, $pin_tile_x, $pin_x, $pin_tile_y, $pin_y) = @_; my $tile_x = click_to_tile($pin_tile_x, $pin_x); my $tile_y = click_to_tile($pin_tile_y, $pin_y); - my $zoom = MIN_ZOOM_LEVEL + (defined $c->req->params->{zoom} ? $c->req->params->{zoom} : 2); + my $zoom = MIN_ZOOM_LEVEL + (defined $c->req->params->{zoom} ? $c->req->params->{zoom} : 3); my ($lat, $lon) = tile_to_latlon($tile_x, $tile_y, $zoom); return ( $lat, $lon ); } diff --git a/t/app/uri_for.t b/t/app/uri_for.t index 67acbc235..2362e6976 100644 --- a/t/app/uri_for.t +++ b/t/app/uri_for.t @@ -3,6 +3,10 @@ use warnings; use Test::More; +# FIXME Should this be here? A better way? uri_for varies by map. +use Test::WWW::Mechanize::Catalyst 'FixMyStreet::App'; +FixMyStreet::Map::set_map_class(); + # structure of these tests borrowed from '/t/aggregate/unit_core_uri_for.t' use strict; @@ -70,7 +74,7 @@ is( # fiksgatami is( $fgm_c->uri_for( '/foo', { lat => 1.23, } ) . "", - 'http://www.fiksgatami.no/foo?lat=1.23&zoom=2', + 'http://www.fiksgatami.no/foo?lat=1.23&zoom=3', 'FiksGataMi url with lat not zoom' ); diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index d912b4b5f..22492e400 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -24,7 +24,7 @@ YAHOO.util.Event.onContentReady('map', function() { new OpenLayers.Projection("EPSG:4326"), fixmystreet.map.getProjectionObject() ); - fixmystreet.map.setCenter(centre, fixmystreet.zoom || 2); + fixmystreet.map.setCenter(centre, fixmystreet.zoom || 3); } if (document.getElementById('mapForm')) { |