diff options
Diffstat (limited to 'web/js/map-bing-ol.js')
-rw-r--r-- | web/js/map-bing-ol.js | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js index 4e01ff58b..bbaf22940 100644 --- a/web/js/map-bing-ol.js +++ b/web/js/map-bing-ol.js @@ -10,10 +10,23 @@ fixmystreet.maps.config = function() { if ( fixmystreet.page == 'report' ) { fixmystreet.controls.push( new OpenLayers.Control.PermalinkFMS('key-tool-problems-nearby', '/around') ); } - fixmystreet.map_type = OpenLayers.Layer.Bing; }; +(function() { + $(function(){ + $('#map_layer_toggle').toggle(function(){ + $(this).text('Roads'); + fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]); + }, function(){ + $(this).text('Aerial'); + fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]); + }); + }); + +})(); + 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 +48,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,13 +103,41 @@ 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" }); + +OpenLayers.Layer.BingAerial = OpenLayers.Class(OpenLayers.Layer.Bing, { + tile_base: '//t{S}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/${id}?mkt=en-US&it=A,G,L&src=t&og=969&n=z', + + setMap: function() { + OpenLayers.Layer.Bing.prototype.setMap.apply(this, arguments); + this.map.events.register("moveend", this, this.updateAttribution); + }, + + updateAttribution: function() { + var z = this.map.getZoom() + this.zoomOffset; + var year = (new Date()).getFullYear(); + var copyrights = '© ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>, HERE, '; + if (z >= 13) { + copyrights += 'Maxar, CNES Distribution Airbus DS'; + } else { + copyrights += 'Earthstar Geographics SIO'; + } + 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); + }, + + CLASS_NAME: "OpenLayers.Layer.BingAerial" +}); + +fixmystreet.layer_options = [ + { map_type: OpenLayers.Layer.Bing }, + { map_type: OpenLayers.Layer.BingAerial } +]; |