nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 419c6e9a40accb7eb38d6fbd99eff7ead5e80bb0
parent bfa359ebdb4a3c6d24ba06133d7761a47cf63c40
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Wed,  4 Jul 2018 02:20:38 +0300

[panoramas] enable/disable panoramas control using hotkey (Alt-P) #80

Diffstat:
Msrc/lib/leaflet.control.panoramas/index.js | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/lib/leaflet.control.panoramas/index.js b/src/lib/leaflet.control.panoramas/index.js @@ -92,6 +92,7 @@ L.Control.Panoramas = L.Control.extend({ 'leaflet-contol-panoramas', 'Show panoramas', 'icon-panoramas'); this._container = container; L.DomEvent.on(link, 'click', this.onButtonClick, this); + L.DomEvent.on(document, 'keyup', this.onKeyUp, this); barContainer.innerHTML = ` <div class="panoramas-list" data-bind="foreach: providers"> <div> @@ -108,6 +109,11 @@ L.Control.Panoramas = L.Control.extend({ }, onButtonClick: function() { + this.switchControl(); + }, + + switchControl: function() { + if (this.controlEnabled) { this.disableControl(); } else { @@ -115,6 +121,12 @@ L.Control.Panoramas = L.Control.extend({ } }, + onKeyUp: function(e) { + if (e.keyCode === 'P'.codePointAt(0) && e.altKey) { + this.switchControl(); + } + }, + enableControl: function() { if (this.controlEnabled) { return;