Added ability to specify custom overlays in configuration

Analogous to adding base layers, custom overlays can be added in
the `config.js` file:

```javascript
BR.conf.overlays = {
    'Hill shading': 'http://{s}.tiles.wmflabs.org/hillshading/{z}/{x}/{y}.png'
};
```
This commit is contained in:
Sascha Hagedorn 2016-06-29 20:37:54 +02:00
parent 42d04e52c2
commit ffff29dfcc
3 changed files with 61 additions and 55 deletions

94
dist/brouter-web.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
/* /*
BRouter web - web client for BRouter bike routing engine BRouter web - web client for BRouter bike routing engine
Licensed under the MIT license. Licensed under the MIT license.
*/ */
@ -11,7 +11,7 @@
function initMap() { function initMap() {
L.Icon.Default.imagePath = 'dist/images'; L.Icon.Default.imagePath = 'dist/images';
var osmAttribution = '&copy; <a target="_blank" href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'; var osmAttribution = '&copy; <a target="_blank" href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
var maxZoom = 19; var maxZoom = 19;
@ -74,7 +74,7 @@
}); });
map = new L.Map('map', { map = new L.Map('map', {
center: new L.LatLng(50.99, 9.86), center: new L.LatLng(50.99, 9.86),
zoom: 6, zoom: 6,
worldCopyJump: true worldCopyJump: true
}); });
@ -104,6 +104,12 @@
baseLayers[i] = L.tileLayer(BR.conf.baseLayers[i]); baseLayers[i] = L.tileLayer(BR.conf.baseLayers[i]);
} }
} }
for (i in BR.conf.overlays) {
if (BR.conf.overlays.hasOwnProperty(i)) {
overlays[i] = L.tileLayer(BR.conf.overlays[i]);
}
}
// after applying custom base layer configurations, add first base layer to map // after applying custom base layer configurations, add first base layer to map
var firstLayer = baseLayers[Object.keys(baseLayers)[0]]; var firstLayer = baseLayers[Object.keys(baseLayers)[0]];
if (firstLayer) { if (firstLayer) {
@ -121,9 +127,9 @@
var search, var search,
router, router,
routing, routing,
routesLayer, routesLayer,
routingOptions, routingOptions,
nogos, nogos,
stats, stats,
itinerary, itinerary,
elevation, elevation,
@ -182,7 +188,7 @@
function requestUpdate(updatable) { function requestUpdate(updatable) {
var track = routing.toPolyline(), var track = routing.toPolyline(),
segments = routing.getSegments(); segments = routing.getSegments();
updatable.update(track, segments); updatable.update(track, segments);
} }