Book Image

OpenLayers 2.10 Beginner's Guide

Book Image

OpenLayers 2.10 Beginner's Guide

Overview of this book

Table of Contents (18 chapters)
OpenLayers 2.10
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for Action – using control methods


Let's go through a quick example using some of the functions we just covered.

  1. Open up an existing map (any map is fine).

  2. In Firebug, input and run the following:

    var returned_controls = map.getControlsBy('active', true);
  3. 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...