Fix mute shortcut not working for color coded routes
The mute shortcut would only work for regular routes before. Note that no-go areas, POIs and tracks continue to be unaffected by muting, so e.g. peeking at a track below the route is still possible.
This commit is contained in:
parent
08c8cfa8be
commit
d6c648d3eb
1 changed files with 26 additions and 0 deletions
|
|
@ -1,4 +1,10 @@
|
|||
BR.RoutingPathQuality = L.Control.extend({
|
||||
options: {
|
||||
shortcut: {
|
||||
muteKeyCode: 77 // char code for 'm'
|
||||
}
|
||||
},
|
||||
|
||||
initialize: function(map, layersControl, options) {
|
||||
L.setOptions(this, options);
|
||||
|
||||
|
|
@ -78,6 +84,7 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
this.selectedProvider = this._initialProvider;
|
||||
|
||||
this._active = false;
|
||||
this._muted = false;
|
||||
},
|
||||
|
||||
onAdd: function(map) {
|
||||
|
|
@ -133,6 +140,11 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
});
|
||||
}
|
||||
|
||||
if (this.options.shortcut.muteKeyCode) {
|
||||
L.DomEvent.addListener(document, 'keydown', this._keydownListener, this);
|
||||
L.DomEvent.addListener(document, 'keyup', this._keyupListener, this);
|
||||
}
|
||||
|
||||
this.routingPathButton = new L.easyButton({
|
||||
states: states
|
||||
}).addTo(map);
|
||||
|
|
@ -177,6 +189,20 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
this._routingSegments.addLayer(layers[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_keydownListener: function(e) {
|
||||
if (BR.Util.keyboardShortcutsAllowed(e) && this._active && e.keyCode === this.options.shortcut.muteKeyCode) {
|
||||
this._muted = true;
|
||||
this._deactivate(this.routingPathButton);
|
||||
}
|
||||
},
|
||||
|
||||
_keyupListener: function(e) {
|
||||
if (BR.Util.keyboardShortcutsAllowed(e) && this._muted && e.keyCode === this.options.shortcut.muteKeyCode) {
|
||||
this._muted = false;
|
||||
this._activate(this.routingPathButton);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue