aboutsummaryrefslogtreecommitdiffstats
path: root/web/js
diff options
context:
space:
mode:
Diffstat (limited to 'web/js')
-rw-r--r--web/js/map-OpenLayers.js2
-rw-r--r--web/js/map-bing-ol.js58
-rw-r--r--web/js/map-fms.js43
-rw-r--r--web/js/map-mastermap.js5
4 files changed, 78 insertions, 30 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index d5fd36e97..3db59f218 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -958,6 +958,8 @@ $.extend(fixmystreet.utils, {
);
} else if (layer_options.matrixIds) {
layer = new fixmystreet.map_type(layer_options);
+ } else if (fixmystreet.layer_options[i].map_type) {
+ layer = new fixmystreet.layer_options[i].map_type(fixmystreet.layer_name, layer_options);
} else {
layer = new fixmystreet.map_type(fixmystreet.layer_name, layer_options);
}
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 = '&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);
},
@@ -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 = '&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 }
+];
diff --git a/web/js/map-fms.js b/web/js/map-fms.js
index 925fe1fa2..bb51467a7 100644
--- a/web/js/map-fms.js
+++ b/web/js/map-fms.js
@@ -1,11 +1,4 @@
-fixmystreet.maps.tile_base = [ [ '', 'a-', 'b-', 'c-' ], '//{S}tilma.mysociety.org/oml' ];
-
-fixmystreet.maps.config = (function(original) {
- return function(){
- original();
- fixmystreet.map_type = OpenLayers.Layer.BingUK;
- };
-})(fixmystreet.maps.config);
+fixmystreet.maps.tile_base = '//{S}tilma.mysociety.org/oml';
OpenLayers.Layer.BingUK = OpenLayers.Class(OpenLayers.Layer.Bing, {
uk_bounds: [
@@ -44,36 +37,42 @@ 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 = '&copy; ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>. &copy; AND, Navteq, Highways England, Ordnance Survey';
+ copyrights = '&copy; ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>, HERE, Highways England, Ordnance Survey';
} else {
- copyrights = '&copy; ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>. &copy; AND, Navteq, Ordnance Survey';
+ copyrights = '&copy; ' + year + ' <a href="https://www.bing.com/maps/">Microsoft</a>, HERE, Ordnance Survey';
}
}
this._updateAttribution(copyrights, logo);
},
+ 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< fixmystreet.maps.tile_base[0].length; i++) {
- urls.push( fixmystreet.maps.tile_base[1].replace('{S}', fixmystreet.maps.tile_base[0][i]) + "/${z}/${x}/${y}.png" );
+ 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;
},
CLASS_NAME: "OpenLayers.Layer.BingUK"
});
+
+fixmystreet.layer_options = [
+ { map_type: OpenLayers.Layer.BingUK },
+ { map_type: OpenLayers.Layer.BingAerial }
+];
diff --git a/web/js/map-mastermap.js b/web/js/map-mastermap.js
index bb9adf532..663ccbdfb 100644
--- a/web/js/map-mastermap.js
+++ b/web/js/map-mastermap.js
@@ -23,3 +23,8 @@ OpenLayers.Layer.MasterMap = OpenLayers.Class(OpenLayers.Layer.BingUK, {
CLASS_NAME: "OpenLayers.Layer.MasterMap"
});
+
+fixmystreet.layer_options = [
+ { map_type: OpenLayers.Layer.MasterMap },
+ { map_type: OpenLayers.Layer.BingAerial }
+];