diff options
Diffstat (limited to 'perllib/FixMyStreet/Map/BingOL.pm')
-rw-r--r-- | perllib/FixMyStreet/Map/BingOL.pm | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/perllib/FixMyStreet/Map/BingOL.pm b/perllib/FixMyStreet/Map/BingOL.pm index 70f9dbda1..94df6fff9 100644 --- a/perllib/FixMyStreet/Map/BingOL.pm +++ b/perllib/FixMyStreet/Map/BingOL.pm @@ -7,9 +7,12 @@ # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ package FixMyStreet::Map::BingOL; +use base 'FixMyStreet::Map::OSM'; use strict; -use mySociety::Gaze; + +use constant ZOOM_LEVELS => 5; +use constant MIN_ZOOM_LEVEL => 13; sub header_js { return ' @@ -20,25 +23,45 @@ sub header_js { '; } -# display_map C PARAMS -# PARAMS include: -# latitude, longitude for the centre point of the map -# CLICKABLE is set if the map is clickable -# PINS is array of pins to show, location and colour -sub display_map { - my ($self, $c, %params) = @_; - - my $dist = mySociety::Gaze::get_radius_containing_population( $params{latitude}, $params{longitude}, 200_000 ); - my $zoom = 2; - $zoom = 3 if $dist < 10; - - $c->stash->{map} = { - %params, - type => 'osm', - zoom => $zoom, - map_type => '""', # Is set by the JavaScript - copyright => _('Map contains Ordnance Survey data © Crown copyright and database right 2010. Microsoft'), - }; +# Is set by the JavaScript +sub map_type { + return '""'; +} + +sub copyright { + return _('Map contains Ordnance Survey data © Crown copyright and database right 2010. Microsoft'); +} + +sub get_quadkey { + my ($x, $y, $z) = @_; + my $key = ''; + for (my $i = $z; $i > 0; $i--) { + my $digit = 0; + my $mask = 1 << ($i - 1); + $digit++ if ($x & $mask) != 0; + $digit += 2 if ($y & $mask) != 0; + $key .= $digit; + } + return $key; +} + +sub map_tiles { + my ($self, $x, $y, $z) = @_; + if ($z >= 16) { + return [ + "http://a.os.openstreetmap.org/sv/$z/" . ($x-1) . "/" . ($y-1) . ".png", + "http://b.os.openstreetmap.org/sv/$z/$x/" . ($y-1) . ".png", + "http://c.os.openstreetmap.org/sv/$z/" . ($x-1) . "/$y.png", + "http://os.openstreetmap.org/sv/$z/$x/$y.png", + ]; + } else { + return [ + "http://ecn.t0.tiles.virtualearth.net/tiles/r" . get_quadkey($x-1, $y-1, $z) . ".png?g=587&productSet=mmOS", + "http://ecn.t1.tiles.virtualearth.net/tiles/r" . get_quadkey($x, $y-1, $z) . ".png?g=587&productSet=mmOS", + "http://ecn.t2.tiles.virtualearth.net/tiles/r" . get_quadkey($x-1, $y, $z) . ".png?g=587&productSet=mmOS", + "http://ecn.t3.tiles.virtualearth.net/tiles/r" . get_quadkey($x, $y, $z) . ".png?g=587&productSet=mmOS", + ]; + } } 1; |