Add shortcut to toggle elevation chart
Press 'E' to show/hide the elevation chart.
This commit is contained in:
parent
844a9038ee
commit
b8b1e436e6
3 changed files with 15 additions and 1 deletions
|
|
@ -7,7 +7,10 @@ BR.Elevation = L.Control.Elevation.extend({
|
|||
bottom: 30,
|
||||
left: 60
|
||||
},
|
||||
theme: 'steelblue-theme'
|
||||
theme: 'steelblue-theme',
|
||||
shortcut: {
|
||||
toggle: 69 // char code for 'e'
|
||||
}
|
||||
},
|
||||
|
||||
onAdd: function(map) {
|
||||
|
|
@ -30,6 +33,8 @@ BR.Elevation = L.Control.Elevation.extend({
|
|||
L.DomEvent.on(this._container, 'mouseup', this._dragEndHandler, this);
|
||||
}
|
||||
|
||||
L.DomEvent.addListener(document, 'keydown', this._keydownListener, this);
|
||||
|
||||
return container;
|
||||
},
|
||||
|
||||
|
|
@ -64,5 +69,11 @@ BR.Elevation = L.Control.Elevation.extend({
|
|||
|
||||
layer.on('mouseout', this._hidePositionMarker.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
_keydownListener: function(e) {
|
||||
if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.toggle) {
|
||||
$('#elevation-btn').click();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue