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.js43
1 files changed, 42 insertions, 1 deletions
diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js
index a99fdd849..bbaf22940 100644
--- a/web/js/map-bing-ol.js
+++ b/web/js/map-bing-ol.js
@@ -10,9 +10,21 @@ 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}',
@@ -100,3 +112,32 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
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 }
+];