only use localStorage if available
This commit is contained in:
parent
a87f5632bc
commit
df6eed44cf
1 changed files with 3 additions and 3 deletions
|
@ -1472,7 +1472,7 @@ SquareGridControl = L.Control.extend({
|
||||||
this._button.href = '#';
|
this._button.href = '#';
|
||||||
this._button.style.color = '#BBBBBB';
|
this._button.style.color = '#BBBBBB';
|
||||||
this.gridActive = false;
|
this.gridActive = false;
|
||||||
if (localStorage.getItem('showGrid')) {
|
if (localStorage && localStorage.getItem('showGrid')) {
|
||||||
this.showGrid()
|
this.showGrid()
|
||||||
}
|
}
|
||||||
return this._container;
|
return this._container;
|
||||||
|
@ -1493,7 +1493,7 @@ SquareGridControl = L.Control.extend({
|
||||||
this._button.innerHTML = 'grid_on';
|
this._button.innerHTML = 'grid_on';
|
||||||
this._button.style.color = '';
|
this._button.style.color = '';
|
||||||
this.gridActive = true;
|
this.gridActive = true;
|
||||||
localStorage.setItem('showGrid', true);
|
if (localStorage) localStorage.setItem('showGrid', true);
|
||||||
},
|
},
|
||||||
|
|
||||||
hideGrid: function() {
|
hideGrid: function() {
|
||||||
|
@ -1502,7 +1502,7 @@ SquareGridControl = L.Control.extend({
|
||||||
this._button.innerHTML = 'grid_off';
|
this._button.innerHTML = 'grid_off';
|
||||||
this._button.style.color = '#BBBBBB';
|
this._button.style.color = '#BBBBBB';
|
||||||
this.gridActive = false;
|
this.gridActive = false;
|
||||||
localStorage.removeItem('showGrid');
|
if (localStorage) localStorage.removeItem('showGrid');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue