Accept string for keyboardEventTarget option
This commit is contained in:
@@ -30,7 +30,8 @@
|
|||||||
* then it gets set by using `window.devicePixelRatio`.
|
* then it gets set by using `window.devicePixelRatio`.
|
||||||
* @property {ol.Collection|Array.<ol.interaction.Interaction>|undefined} interactions
|
* @property {ol.Collection|Array.<ol.interaction.Interaction>|undefined} interactions
|
||||||
* Interactions that are initially added to the map.
|
* Interactions that are initially added to the map.
|
||||||
* @property {Element|Document|undefined} keyboardEventTarget The element to listen to keyboard events on.
|
* @property {Element|Document|string|undefined} keyboardEventTarget
|
||||||
|
* The element to listen to keyboard events on.
|
||||||
* This determines when the `KeyboardPan` and `KeyboardZoom` interactions trigger. For example, if
|
* This determines when the `KeyboardPan` and `KeyboardZoom` interactions trigger. For example, if
|
||||||
* this option is set to `document` the keyboard interactions will always trigger. If this option
|
* this option is set to `document` the keyboard interactions will always trigger. If this option
|
||||||
* is not specified, the element the library listens to keyboard events on is the map target (i.e.
|
* is not specified, the element the library listens to keyboard events on is the map target (i.e.
|
||||||
|
|||||||
+8
-2
@@ -1336,8 +1336,14 @@ ol.Map.createOptionsInternal = function(options) {
|
|||||||
/**
|
/**
|
||||||
* @type {Element|Document}
|
* @type {Element|Document}
|
||||||
*/
|
*/
|
||||||
var keyboardEventTarget = goog.isDef(options.keyboardEventTarget) ?
|
var keyboardEventTarget = null;
|
||||||
options.keyboardEventTarget : null;
|
if (goog.isDef(options.keyboardEventTarget)) {
|
||||||
|
// cannot use goog.dom.getElement because its argument cannot be
|
||||||
|
// of type Document
|
||||||
|
keyboardEventTarget = goog.isString(options.keyboardEventTarget) ?
|
||||||
|
document.getElementById(options.keyboardEventTarget) :
|
||||||
|
options.keyboardEventTarget;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<string, *>}
|
* @type {Object.<string, *>}
|
||||||
|
|||||||
Reference in New Issue
Block a user