Support for map.options.keyboardPanOffset and map.options.keyboardZoomOffset. Use these to configure how far the keyboard controls will pan/zoom the map (respectively).
This commit is contained in:
parent
aaa0721073
commit
20bec613ec
@ -1,5 +1,7 @@
|
||||
L.Map.mergeOptions({
|
||||
keyboard: true
|
||||
keyboard: true,
|
||||
keyboardPanOffset: 50,
|
||||
keyboardZoomOffset: 1
|
||||
});
|
||||
|
||||
L.Map.Keyboard = L.Handler.extend({
|
||||
@ -27,15 +29,32 @@ L.Map.Keyboard = L.Handler.extend({
|
||||
panKeys: {},
|
||||
zoomKeys: {},
|
||||
|
||||
initialize: function (map, pan, zoom) {
|
||||
initialize: function (map) {
|
||||
this._map = map;
|
||||
this._container = map._container;
|
||||
var panOffset = map.options.keyboardPanOffset;
|
||||
var zoomOffset = map.options.keyboardZoomOffset;
|
||||
|
||||
this.setPanOffset(pan);
|
||||
this.setZoomOffset(zoom);
|
||||
if (typeof panOffset !== 'number') {
|
||||
panOffset = 50;
|
||||
}
|
||||
if (typeof zoomOffset !== 'number') {
|
||||
zoomOffset = 1;
|
||||
}
|
||||
|
||||
this._setPanOffset(panOffset);
|
||||
this._setZoomOffset(zoomOffset);
|
||||
},
|
||||
|
||||
setPanOffset: function (pan) {
|
||||
addHooks: function () {
|
||||
L.DomEvent.addListener(this._container, 'click', this._onClick, this);
|
||||
},
|
||||
|
||||
removeHooks: function () {
|
||||
L.DomEvent.removeListener(this._container, 'click', this._onClick, this);
|
||||
},
|
||||
|
||||
_setPanOffset: function (pan) {
|
||||
var panKeys = {},
|
||||
keyCode = null,
|
||||
i = 0;
|
||||
@ -71,7 +90,7 @@ L.Map.Keyboard = L.Handler.extend({
|
||||
this.panKeys = panKeys;
|
||||
},
|
||||
|
||||
setZoomOffset: function (zoom) {
|
||||
_setZoomOffset: function (zoom) {
|
||||
var zoomKeys = {},
|
||||
keyCode = null,
|
||||
i = 0;
|
||||
@ -95,14 +114,6 @@ L.Map.Keyboard = L.Handler.extend({
|
||||
this.zoomKeys = zoomKeys;
|
||||
},
|
||||
|
||||
addHooks: function () {
|
||||
L.DomEvent.addListener(this._container, 'click', this._onClick, this);
|
||||
},
|
||||
|
||||
removeHooks: function () {
|
||||
L.DomEvent.removeListener(this._container, 'click', this._onClick, this);
|
||||
},
|
||||
|
||||
_onClick: function (e) {
|
||||
this._addHooks();
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user