Add function to store layer control status (overlay only) in cookie for using in next session.
This commit is contained in:
21
code/boot.js
21
code/boot.js
@ -83,6 +83,26 @@ window.setupLayerChooserSelectOne = function() {
|
||||
});
|
||||
}
|
||||
|
||||
// Setup the function to record the on/off status of overlay layerGroups
|
||||
window.setupLayerChooserStatusRecorder = function() {
|
||||
// Record already added layerGroups
|
||||
$.each(window.layerChooser._layers, function(ind, chooserEntry) {
|
||||
if(!chooserEntry.overlay) return true;
|
||||
var display = window.map.hasLayer(chooserEntry.layer);
|
||||
window.updateDisplayedLayerGroup(chooserEntry.name, display);
|
||||
});
|
||||
|
||||
// Record layerGroups change
|
||||
window.map.on('layeradd layerremove', function(e) {
|
||||
var id = L.stamp(e.layer);
|
||||
var layerGroup = this._layers[id];
|
||||
if (layerGroup && layerGroup.overlay) {
|
||||
var display = (e.type === 'layeradd');
|
||||
window.updateDisplayedLayerGroup(layerGroup.name, display);
|
||||
}
|
||||
}, window.layerChooser);
|
||||
}
|
||||
|
||||
window.setupStyles = function() {
|
||||
$('head').append('<style>' +
|
||||
[ '#largepreview.enl img { border:2px solid '+COLORS[TEAM_ENL]+'; } ',
|
||||
@ -370,6 +390,7 @@ function boot() {
|
||||
window.chat.setup();
|
||||
window.setupQRLoadLib();
|
||||
window.setupLayerChooserSelectOne();
|
||||
window.setupLayerChooserStatusRecorder();
|
||||
window.setupBackButton();
|
||||
// read here ONCE, so the URL is only evaluated one time after the
|
||||
// necessary data has been loaded.
|
||||
|
Reference in New Issue
Block a user