Time for Action – using control methods
Let's go through a quick example using some of the functions we just covered.
Open up an existing map (any map is fine).
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])
What Just Happened?
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.
Extent/Coordinate/Bounds related
The following functions are all related, in some capacity, to moving or getting position information about the map.
Some of the functions will make use of the OpenLayers...