Merge pull request #3139 from elemoine/control-setmap
Add ol.control.Control#setTarget
This commit is contained in:
@@ -51,8 +51,7 @@ ol.control.Control = function(options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {Element}
|
* @type {Element}
|
||||||
*/
|
*/
|
||||||
this.target_ = goog.isDef(options.target) ?
|
this.target_ = null;
|
||||||
goog.dom.getElement(options.target) : null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -71,6 +70,10 @@ ol.control.Control = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.render = goog.isDef(options.render) ? options.render : goog.nullFunction;
|
this.render = goog.isDef(options.render) ? options.render : goog.nullFunction;
|
||||||
|
|
||||||
|
if (goog.isDef(options.target)) {
|
||||||
|
this.setTarget(options.target);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.control.Control, ol.Object);
|
goog.inherits(ol.control.Control, ol.Object);
|
||||||
|
|
||||||
@@ -121,3 +124,17 @@ ol.control.Control.prototype.setMap = function(map) {
|
|||||||
map.render();
|
map.render();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is used to set a target element for the control. It has no
|
||||||
|
* effect if it is called after the control has been added to the map (i.e.
|
||||||
|
* after `setMap` is called on the control). If no `target` is set in the
|
||||||
|
* options passed to the control constructor and if `setTarget` is not called
|
||||||
|
* then the control is added to the map's overlay container.
|
||||||
|
* @param {Element|string} target Target.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.control.Control.prototype.setTarget = function(target) {
|
||||||
|
this.target_ = goog.dom.getElement(target);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user