Option to remove default base layers (#27)
This commit is contained in:
parent
e7fb105df7
commit
052a79cc0b
2 changed files with 11 additions and 1 deletions
|
|
@ -66,6 +66,9 @@
|
||||||
// External URL for key retrieval, does not work locally on desktop
|
// External URL for key retrieval, does not work locally on desktop
|
||||||
BR.conf.bingKeyUrl = 'http://norbertrenner.de/key/bing.php';
|
BR.conf.bingKeyUrl = 'http://norbertrenner.de/key/bing.php';
|
||||||
|
|
||||||
|
// Removes default base layers when 'true'. Useful for only having custom layers (see below).
|
||||||
|
BR.conf.clearBaseLayers = false;
|
||||||
|
|
||||||
// Add custom tile layers
|
// Add custom tile layers
|
||||||
// URL template see http://leafletjs.com/reference.html#tilelayer
|
// URL template see http://leafletjs.com/reference.html#tilelayer
|
||||||
// Multiple entries separated by comma (,)
|
// Multiple entries separated by comma (,)
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
map = new L.Map('map', {
|
map = new L.Map('map', {
|
||||||
layers: [osm],
|
|
||||||
center: new L.LatLng(50.99, 9.86),
|
center: new L.LatLng(50.99, 9.86),
|
||||||
zoom: 6,
|
zoom: 6,
|
||||||
worldCopyJump: true
|
worldCopyJump: true
|
||||||
|
|
@ -97,11 +96,19 @@
|
||||||
'Hiking (Waymarked Trails)': hiking
|
'Hiking (Waymarked Trails)': hiking
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (BR.conf.clearBaseLayers) {
|
||||||
|
baseLayers = {};
|
||||||
|
}
|
||||||
for (i in BR.conf.baseLayers) {
|
for (i in BR.conf.baseLayers) {
|
||||||
if (BR.conf.baseLayers.hasOwnProperty(i)) {
|
if (BR.conf.baseLayers.hasOwnProperty(i)) {
|
||||||
baseLayers[i] = L.tileLayer(BR.conf.baseLayers[i]);
|
baseLayers[i] = L.tileLayer(BR.conf.baseLayers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// after applying custom base layer configurations, add first base layer to map
|
||||||
|
var firstLayer = baseLayers[Object.keys(baseLayers)[0]];
|
||||||
|
if (firstLayer) {
|
||||||
|
map.addLayer(firstLayer);
|
||||||
|
}
|
||||||
|
|
||||||
layersControl = L.control.layers(baseLayers, overlays).addTo(map);
|
layersControl = L.control.layers(baseLayers, overlays).addTo(map);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue