diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-07-09 17:38:00 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-07-10 19:13:29 +0100 |
commit | 196e3cafcfcec0cc1a050a9d07aad81156ee794e (patch) | |
tree | b77ed78b82637df17284b9fdd3f5f874e372c0d5 | |
parent | 76b2704d4e9a0b0d2c8af704a68652d7b4d81780 (diff) |
Use up-to-date Bing map URLs.
-rw-r--r-- | perllib/FixMyStreet/Map/Bing.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/FMS.pm | 15 | ||||
-rw-r--r-- | web/js/map-bing-ol.js | 15 | ||||
-rw-r--r-- | web/js/map-fms.js | 25 |
4 files changed, 30 insertions, 31 deletions
diff --git a/perllib/FixMyStreet/Map/Bing.pm b/perllib/FixMyStreet/Map/Bing.pm index 97a0d229f..97b947902 100644 --- a/perllib/FixMyStreet/Map/Bing.pm +++ b/perllib/FixMyStreet/Map/Bing.pm @@ -29,14 +29,12 @@ sub get_quadkey { return $key; } -sub map_tile_base { - '', "//ecn.%s.tiles.virtualearth.net/tiles/r%s.png?g=6570"; -} +my $road_base = '//t%s.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/%s?mkt=en-US&it=G,L&src=t&shading=hill&og=969&n=z'; 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; + my $tile_base = $road_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)), diff --git a/perllib/FixMyStreet/Map/FMS.pm b/perllib/FixMyStreet/Map/FMS.pm index 0cb1de553..246d04bc0 100644 --- a/perllib/FixMyStreet/Map/FMS.pm +++ b/perllib/FixMyStreet/Map/FMS.pm @@ -32,16 +32,17 @@ sub map_tiles { sprintf($tile_base, 'c-', $z, $x-1, $y), sprintf($tile_base, '', $z, $x, $y), ]; - } else { + } elsif (!$ni && $z > 11) { my $key = FixMyStreet->config('BING_MAPS_API_KEY'); - my $url = "g=6570"; - $url .= "&productSet=mmOS&key=$key" if $z > 11 && !$ni; + my $base = "//ecn.%s.tiles.virtualearth.net/tiles/r%s?g=8702&lbl=l1&productSet=mmOS&key=$key"; return [ - "//ecn.t0.tiles.virtualearth.net/tiles/r" . $self->get_quadkey($x-1, $y-1, $z) . ".png?$url", - "//ecn.t1.tiles.virtualearth.net/tiles/r" . $self->get_quadkey($x, $y-1, $z) . ".png?$url", - "//ecn.t2.tiles.virtualearth.net/tiles/r" . $self->get_quadkey($x-1, $y, $z) . ".png?$url", - "//ecn.t3.tiles.virtualearth.net/tiles/r" . $self->get_quadkey($x, $y, $z) . ".png?$url", + sprintf($base, "t0", $self->get_quadkey($x-1, $y-1, $z)), + sprintf($base, "t1", $self->get_quadkey($x, $y-1, $z)), + sprintf($base, "t2", $self->get_quadkey($x-1, $y, $z)), + sprintf($base, "t3", $self->get_quadkey($x, $y, $z)), ]; + } else { + return $self->SUPER::map_tiles(%params); } } diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js index 4e01ff58b..a99fdd849 100644 --- a/web/js/map-bing-ol.js +++ b/web/js/map-bing-ol.js @@ -14,6 +14,7 @@ fixmystreet.maps.config = function() { }; OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { + tile_base: '//t{S}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/${id}?mkt=en-US&it=G,L&src=t&shading=hill&og=969&n=z', attributionTemplate: '${logo}${copyrights}', setMap: function() { @@ -35,7 +36,8 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { }, updateAttribution: function() { - var copyrights = '© 2011 <a href="https://www.bing.com/maps/">Microsoft</a>. © AND, Navteq'; + var year = (new Date()).getFullYear(); + var copyrights = '© ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>, HERE'; var logo = '<a href="https://www.bing.com/maps/"><img border=0 src="//dev.virtualearth.net/Branding/logo_powered_by.png"></a>'; this._updateAttribution(copyrights, logo); }, @@ -89,12 +91,11 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { }, get_urls: function(bounds, z) { - return [ - "//ecn.t0.tiles.virtualearth.net/tiles/r${id}.png?g=6570", - "//ecn.t1.tiles.virtualearth.net/tiles/r${id}.png?g=6570", - "//ecn.t2.tiles.virtualearth.net/tiles/r${id}.png?g=6570", - "//ecn.t3.tiles.virtualearth.net/tiles/r${id}.png?g=6570" - ]; + var urls = []; + for (var i=0; i<4; i++) { + urls.push(this.tile_base.replace('{S}', i)); + } + return urls; }, CLASS_NAME: "OpenLayers.Layer.Bing" diff --git a/web/js/map-fms.js b/web/js/map-fms.js index 0e263c0a5..8af6adec3 100644 --- a/web/js/map-fms.js +++ b/web/js/map-fms.js @@ -44,9 +44,9 @@ OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.Bing, { } else { logo = '<a href="https://www.bing.com/maps/"><img border=0 src="//dev.virtualearth.net/Branding/logo_powered_by.png"></a>'; if (in_uk) { - copyrights = '© ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>. © AND, Navteq, Highways England, Ordnance Survey'; + copyrights = '© ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>, HERE, Highways England, Ordnance Survey'; } else { - copyrights = '© ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>. © AND, Navteq, Ordnance Survey'; + copyrights = '© ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>, HERE, Ordnance Survey'; } } this._updateAttribution(copyrights, logo); @@ -55,24 +55,23 @@ OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.Bing, { tile_prefix: [ '', 'a-', 'b-', 'c-' ], get_urls: function(bounds, z) { - var urls; + var urls = [], i; var in_uk = this.in_uk(bounds.getCenterLonLat()); if (z >= 16 && in_uk) { urls = []; - for (var i=0; i< this.tile_prefix.length; i++) { + for (i=0; i< this.tile_prefix.length; i++) { urls.push( fixmystreet.maps.tile_base.replace('{S}', this.tile_prefix[i]) + "/${z}/${x}/${y}.png" ); } + } else if (z > 11 && in_uk) { + var type = 'g=8702&lbl=l1&productSet=mmOS&key=' + fixmystreet.key; + var tile_base = "//ecn.t{S}.tiles.virtualearth.net/tiles/r${id}?" + type; + for (i=0; i<4; i++) { + urls.push(tile_base.replace('{S}', i)); + } } else { - var type = ''; - if (z > 11 && in_uk) { - type = '&productSet=mmOS&key=' + fixmystreet.key; + for (i=0; i<4; i++) { + urls.push(this.tile_base.replace('{S}', i)); } - urls = [ - "//ecn.t0.tiles.virtualearth.net/tiles/r${id}.png?g=6570" + type, - "//ecn.t1.tiles.virtualearth.net/tiles/r${id}.png?g=6570" + type, - "//ecn.t2.tiles.virtualearth.net/tiles/r${id}.png?g=6570" + type, - "//ecn.t3.tiles.virtualearth.net/tiles/r${id}.png?g=6570" + type - ]; } return urls; }, |