Add function to store layer control status (overlay only) in cookie for using in next session.

This commit is contained in:
Xelio
2013-04-28 23:47:50 +08:00
parent 4d0ca06836
commit 2556a1ab8d
3 changed files with 47 additions and 0 deletions

View File

@ -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.