aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map/Bing.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/Map/Bing.pm')
-rw-r--r--perllib/FixMyStreet/Map/Bing.pm52
1 files changed, 36 insertions, 16 deletions
diff --git a/perllib/FixMyStreet/Map/Bing.pm b/perllib/FixMyStreet/Map/Bing.pm
index 09c951a5f..46b8f68cd 100644
--- a/perllib/FixMyStreet/Map/Bing.pm
+++ b/perllib/FixMyStreet/Map/Bing.pm
@@ -1,25 +1,45 @@
# FixMyStreet:Map::Bing
-# Bing maps on FixMyStreet.
-#
-# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+# Bing maps on FixMyStreet, using OpenLayers.
package FixMyStreet::Map::Bing;
+use base 'FixMyStreet::Map::OSM';
use strict;
-# 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) = @_;
- $c->stash->{map} = {
- %params,
- type => 'bing',
- key => mySociety::Config::get('BING_MAPS_API_KEY'),
- };
+# Is set by the JavaScript
+sub map_type { '""' }
+
+sub map_template { 'bing' }
+
+sub copyright { '' }
+
+sub get_quadkey {
+ my ($self, $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_tile_base {
+ '', "//ecn.%s.tiles.virtualearth.net/tiles/r%s.png?g=3293";
+}
+
+sub map_tiles {
+ my ( $self, %params ) = @_;
+ my ( $x, $y, $z ) = ( $params{x_tile}, $params{y_tile}, $params{zoom_act} );
+ my ($tile_sep, $tile_base) = $self->map_tile_base;
+ return [
+ sprintf($tile_base, 't0', $self->get_quadkey($x-1, $y-1, $z)),
+ sprintf($tile_base, 't1', $self->get_quadkey($x, $y-1, $z)),
+ sprintf($tile_base, 't2', $self->get_quadkey($x-1, $y, $z)),
+ sprintf($tile_base, 't3', $self->get_quadkey($x, $y, $z)),
+ ];
}
1;