aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Map/Bing.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2015-08-26 13:43:10 +0200
committerMarius Halden <marius.h@lden.org>2015-08-26 13:43:10 +0200
commitcc0acdd34052e79f3df368ac1f524de31df19a1b (patch)
tree505f561b5f16c5b78f07514e8c2b2bdc18fef51d /perllib/FixMyStreet/Map/Bing.pm
parent1c5c685d0b0904e7ddc6e764e58e8fae08632d1d (diff)
parent6b84622fb7d58531baa7943abdcc7620999c34ee (diff)
Merge tag 'v1.6.1' into fiksgatami-dev
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..4c1887641 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=3467";
+}
+
+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;