aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-bing-ol.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/js/map-bing-ol.js')
-rw-r--r--web/js/map-bing-ol.js67
1 files changed, 58 insertions, 9 deletions
diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js
index 4e01ff58b..c44cf96f8 100644
--- a/web/js/map-bing-ol.js
+++ b/web/js/map-bing-ol.js
@@ -10,10 +10,30 @@ 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').click(function(e) {
+ e.preventDefault();
+ var $this = $(this);
+ if ($this.text() == translation_strings.map_aerial) {
+ $this.text(translation_strings.map_roads);
+ fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]);
+ } else {
+ $this.text(translation_strings.map_aerial);
+ fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]);
+ }
+ });
+ // If page loaded with Aerial as starting, rather than default road
+ if ($('#map_layer_toggle').text() == translation_strings.map_roads) {
+ fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]);
+ }
+ });
+})();
+
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 +55,8 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
},
updateAttribution: function() {
- var copyrights = '&copy; 2011 <a href="https://www.bing.com/maps/">Microsoft</a>. &copy; AND, Navteq';
+ var year = (new Date()).getFullYear();
+ var copyrights = '&copy; ' + 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);
},
@@ -45,7 +66,7 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
options = OpenLayers.Util.extend({
/* Below line added to OSM's file in order to allow minimum zoom level */
maxResolution: 156543.03390625/Math.pow(2, options.zoomOffset || 0),
- numZoomLevels: 19,
+ numZoomLevels: 20,
sphericalMercator: true,
buffer: 0
}, options);
@@ -89,13 +110,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 = '&copy; ' + 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 }
+];