diff --git a/src/ol/map.exports b/src/ol/map.exports index 8523ff1658..71fe519081 100644 --- a/src/ol/map.exports +++ b/src/ol/map.exports @@ -1,4 +1,5 @@ @exportClass ol.Map ol.MapOptions +@exportProperty ol.Map.prototype.addControl @exportProperty ol.Map.prototype.addLayer @exportProperty ol.Map.prototype.addPreRenderFunction @exportProperty ol.Map.prototype.addPreRenderFunctions @@ -6,6 +7,7 @@ @exportProperty ol.Map.prototype.getFeatures @exportProperty ol.Map.prototype.getInteractions @exportProperty ol.Map.prototype.getRenderer +@exportProperty ol.Map.prototype.removeControl @exportProperty ol.Map.prototype.removeLayer @exportProperty ol.Map.prototype.updateSize diff --git a/src/ol/map.js b/src/ol/map.js index e929730ecc..d08576f636 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -338,6 +338,18 @@ ol.Map = function(options) { goog.inherits(ol.Map, ol.Object); +/** + * Add the given control to the map. + * @param {ol.control.Control} control Control. + */ +ol.Map.prototype.addControl = function(control) { + var controls = this.getControls(); + goog.asserts.assert(goog.isDef(controls)); + controls.push(control); + control.setMap(this); +}; + + /** * Adds the given layer to the top of this map. * @param {ol.layer.Layer} layer Layer. @@ -809,6 +821,20 @@ ol.Map.prototype.requestRenderFrame = function() { }; +/** + * Remove the given control from the map. + * @param {ol.control.Control} control Control. + * @return {ol.control.Control|undefined} The removed control of undefined + * if the control was not found. + */ +ol.Map.prototype.removeControl = function(control) { + var controls = this.getControls(); + goog.asserts.assert(goog.isDef(controls)); + control.setMap(null); + return /** @type {ol.control.Control|undefined} */ (controls.remove(control)); +}; + + /** * Removes the given layer from the map. * @param {ol.layer.Layer} layer Layer.