Let's go through a quick example using some of the functions we just covered.
In Firebug, input and run the following:
var returned_controls = map.getControlsBy('active', true);
Now, if that array is not empty, call the following. If the array is empty, it means that there are no active controls. Try to add some controls to your map until this function returns a non empty array:
map.removeControl(returned_controls[0])
We just got an array of controls that were active and then removed the first item in the returned array from the map. If the returned_controls
array is empty, calling removeControl
will not do anything (you can't remove a null
control). Let's now look at a larger group of functions.