Add option to configure the default base layer

This commit is contained in:
Norbert Renner 2018-09-07 12:53:57 +02:00
parent 2a6437116a
commit 8db4120ec8
2 changed files with 7 additions and 4 deletions

View file

@ -79,6 +79,9 @@
//'Mapsforge Tile Server': 'http://localhost:6090/{z}/{x}/{y}.png'
};
// Base layer to show on start, as position number in the layer switcher, starting from 0, default is first
BR.conf.defaultBaseLayerIndex = 0;
// Initial route line transparency (0-1, overridden by stored slider setting)
BR.conf.defaultOpacity = 0.67;

View file

@ -120,10 +120,10 @@ BR.Map = {
overlays[i] = L.tileLayer(BR.conf.overlays[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);
// after applying custom base layer configurations, add configured base layer to map
var defaultLayer = baseLayers[Object.keys(baseLayers)[BR.conf.defaultBaseLayerIndex || 0]];
if (defaultLayer) {
map.addLayer(defaultLayer);
}
layersControl = BR.layersTab(baseLayers, overlays).addTo(map);