Add ol.Map#getTargetElement
ol.Map#getTarget returns an element or a string, depending on what was passed to setTarget. This commit adds a getTargetElement method that always returns an Element.
This commit is contained in:
@@ -645,6 +645,19 @@ goog.exportProperty(
|
||||
ol.Map.prototype.getTarget);
|
||||
|
||||
|
||||
/**
|
||||
* Get the DOM element into which this map is rendered. In contrast to
|
||||
* `getTarget` this method always return an `Element`, or `null` if the
|
||||
* map has no target.
|
||||
* @return {Element} The element that the map is rendered in.
|
||||
* @api
|
||||
*/
|
||||
ol.Map.prototype.getTargetElement = function() {
|
||||
var target = this.getTarget();
|
||||
return goog.isDef(target) ? goog.dom.getElement(target) : null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Pixel} pixel Pixel.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
|
||||
Reference in New Issue
Block a user