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:
Éric Lemoine
2014-12-15 17:29:12 +01:00
parent 6b46d5c76a
commit 4a311e66d7

View File

@@ -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.