add keys.js to configure API keys instead of specific ajax loading
This commit is contained in:
parent
0e471bade0
commit
a9f2b0cb18
6 changed files with 23 additions and 18 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -3,3 +3,5 @@ node_modules/
|
||||||
nbproject/
|
nbproject/
|
||||||
.idea/
|
.idea/
|
||||||
bingkey.txt
|
bingkey.txt
|
||||||
|
/.project
|
||||||
|
/keys.js
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ set ``BR.conf.profilesUrl`` in [config.js](config.js), e.g. uncomment:
|
||||||
|
|
||||||
BR.conf.profilesUrl = 'http://localhost:8000/profiles2/';
|
BR.conf.profilesUrl = 'http://localhost:8000/profiles2/';
|
||||||
|
|
||||||
|
3. add your API keys (optional)
|
||||||
|
copy ``keys.js.template`` to ``keys.js`` and edit to add your keys
|
||||||
|
|
||||||
### Run
|
### Run
|
||||||
|
|
||||||
1. start BRouter server in the ``standalone`` directory with ``./server.sh`` or ``server.cmd`` (Windows)
|
1. start BRouter server in the ``standalone`` directory with ``./server.sh`` or ``server.cmd`` (Windows)
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,6 @@
|
||||||
//BR.conf.profilesUrl = 'file://YOUR_PATH_TO/profiles2/';
|
//BR.conf.profilesUrl = 'file://YOUR_PATH_TO/profiles2/';
|
||||||
}
|
}
|
||||||
|
|
||||||
// COPYING: Please get your own Bing maps key at http://www.microsoft.com/maps/default.aspx
|
|
||||||
//BR.conf.bingKeyUrl = 'bingkey.txt';
|
|
||||||
// External URL for key retrieval, does not work locally on desktop
|
|
||||||
BR.conf.bingKeyUrl = 'http://norbertrenner.de/key/bing.php';
|
|
||||||
|
|
||||||
// Removes default base layers when 'true'. Useful for only having custom layers (see below).
|
// Removes default base layers when 'true'. Useful for only having custom layers (see below).
|
||||||
BR.conf.clearBaseLayers = false;
|
BR.conf.clearBaseLayers = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@
|
||||||
|
|
||||||
<script src="dist/url-search-params.js"></script>
|
<script src="dist/url-search-params.js"></script>
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
|
<script src="keys.js"></script>
|
||||||
|
|
||||||
<!-- "gulp inject" for debugging -->
|
<!-- "gulp inject" for debugging -->
|
||||||
<!-- inject:js -->
|
<!-- inject:js -->
|
||||||
|
|
|
||||||
20
js/Map.js
20
js/Map.js
|
|
@ -6,6 +6,8 @@ BR.Map = {
|
||||||
|
|
||||||
L.Icon.Default.imagePath = 'dist/images';
|
L.Icon.Default.imagePath = 'dist/images';
|
||||||
|
|
||||||
|
BR.keys = BR.keys || {};
|
||||||
|
|
||||||
var osmAttribution = '© <a target="_blank" href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
|
var osmAttribution = '© <a target="_blank" href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
|
||||||
var maxZoom = 19;
|
var maxZoom = 19;
|
||||||
|
|
||||||
|
|
@ -55,17 +57,6 @@ BR.Map = {
|
||||||
+ '(<a target="_blank" href="http://creativecommons.org/licenses/by-sa/3.0/de/deed.en">CC-BY-SA 3.0 DE</a>)'
|
+ '(<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;
|
|
||||||
});
|
|
||||||
|
|
||||||
map = new L.Map('map', {
|
map = new L.Map('map', {
|
||||||
worldCopyJump: true
|
worldCopyJump: true
|
||||||
});
|
});
|
||||||
|
|
@ -82,14 +73,17 @@ BR.Map = {
|
||||||
'OpenStreetMap.de': osmde,
|
'OpenStreetMap.de': osmde,
|
||||||
'OpenTopoMap': topo,
|
'OpenTopoMap': topo,
|
||||||
'OpenCycleMap (Thunderf.)': cycle,
|
'OpenCycleMap (Thunderf.)': cycle,
|
||||||
'Outdoors (Thunderforest)': outdoors,
|
'Outdoors (Thunderforest)': outdoors
|
||||||
'Bing Aerial': bing
|
|
||||||
};
|
};
|
||||||
var overlays = {
|
var overlays = {
|
||||||
'Cycling (Waymarked Trails)': cycling,
|
'Cycling (Waymarked Trails)': cycling,
|
||||||
'Hiking (Waymarked Trails)': hiking
|
'Hiking (Waymarked Trails)': hiking
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (BR.keys.bing) {
|
||||||
|
baseLayers['Bing Aerial'] = new BR.BingLayer(BR.keys.bing);
|
||||||
|
}
|
||||||
|
|
||||||
if (BR.conf.clearBaseLayers) {
|
if (BR.conf.clearBaseLayers) {
|
||||||
baseLayers = {};
|
baseLayers = {};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
keys.js.template
Normal file
10
keys.js.template
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
// COPYING: Please get your own API keys from the sites listed below
|
||||||
|
|
||||||
|
BR.keys = {
|
||||||
|
// Bing maps, http://www.microsoft.com/maps/default.aspx
|
||||||
|
bing: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue