fix for #742 -- Adds getControl() and removeControl() methods to the map

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3282 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-06-07 18:01:52 +00:00
parent 6da7fb6851
commit 22c8e3ded4
2 changed files with 97 additions and 0 deletions

View File

@@ -598,6 +598,41 @@ OpenLayers.Map.prototype = {
}
},
/**
* @param {String} id ID of the control to return
*
* @returns The control from the map's list of controls which has a
* matching 'id'. If none found, returns null.
* @type OpenLayers.Control
*/
getControl: function (id) {
var returnControl = null;
for(var i=0; i < this.controls.length; i++) {
var control = this.controls[i];
if (control.id == id) {
returnControl = control;
break;
}
}
return returnControl;
},
/** Remove a control from the map. Removes the control both from the map
* object's internal array of controls, as well as from the map's
* viewPort (assuming the control was not added outsideViewport)
*
* @param {String} id ID of the control to remove
*/
removeControl: function (id) {
var control = this.getControl(id);
if (control) {
if (!control.outsideViewport) {
this.viewPortDiv.removeChild(control.div)
}
OpenLayers.Util.removeItem(this.controls, control);
}
},
/********************************************************/
/* */
/* Popup Functions */