From 4a311e66d78c1415265ec017b22383b321d0c8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 15 Dec 2014 17:29:12 +0100 Subject: [PATCH] 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. --- src/ol/map.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ol/map.js b/src/ol/map.js index 4ee6642c5f..268bc08e28 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -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.