Bing maps aerial layer

This commit is contained in:
Norbert Renner 2015-03-20 12:38:31 +01:00
parent 93d0b7f7df
commit c3b07eb576
5 changed files with 60 additions and 1 deletions

View file

@ -53,6 +53,18 @@
+ '(<a target="_blank" href="http://creativecommons.org/licenses/by-sa/3.0/de/deed.en">CC-BY-SA 3.0 DE</a>)'
});
// COPYING: Please get your own Bing maps key at http://www.microsoft.com/maps/default.aspx
var bing = new BR.BingLayer();
BR.Util.get(BR.conf.bingKeyUrl, function (err, key) {
if (err) {
layersControl.removeLayer(bing);
return;
}
bing._key = key;
bing.loadMetadata();
});
map = new L.Map('map', {
layers: [osm],
center: new L.LatLng(50.99, 9.86),
@ -69,7 +81,8 @@
'OpenStreetMap.de': osmde,
'OpenTopoMap': topo,
'OpenCycleMap (Thunderf.)': cycle,
'Outdoors (Thunderforest)': outdoors
'Outdoors (Thunderforest)': outdoors,
'Bing Aerial': bing
}, {
'Cycling (Waymarked Trails)': cycling,
'Hiking (Waymarked Trails)': hiking

34
js/plugin/Bing.js Normal file
View file

@ -0,0 +1,34 @@
BR.BingLayer = L.BingLayer.extend({
options: {
maxZoom: 19,
attribution: '<a target="_blank" href="http://www.bing.com/maps/">Bing Maps</a>'
+ ' (<a target="_blank" href="http://go.microsoft.com/?linkid=9710837">TOU</a>)'
},
initialize: function(key, options) {
// override super to disable loadMetadata until async key load (called explicitly then)
L.Util.setOptions(this, options);
this._key = key;
this._url = null;
this.meta = {};
//this.loadMetadata();
this._logo = L.control({position: 'bottomleft'});
this._logo.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'bing-logo');
this._div.innerHTML = '<img src="http://www.microsoft.com/maps/images/branding/Bing%20logo%20white_50px-19px.png">';
return this._div;
};
},
onAdd: function(map) {
L.BingLayer.prototype.onAdd.call(this, map);
map.addControl(this._logo);
},
onRemove: function(map) {
L.BingLayer.prototype.onRemove.call(this, map);
map.removeControl(this._logo);
}
});