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

Adding controls to your map


There are two methods for adding controls to a map.

  1. Pass in a JavaScript array of OpenLayers Control objects when you instantiate the map object.

  2. Add controls to the map object after it has been created by calling either of the two map functions addControl(), passing in a single control object, or addControls(), passing in an array of control objects.

When you create your map, four control objects are added automatically. These four controls are:

  • OpenLayers.Control.Navigation: Responsible for handling map interaction from mouse events, such as dragging the mouse, zooming with the scroll bar, and double-clicking.

  • OpenLayers.Control.PanZoom: Adds a Pan/Zoom bar to the top left hand side of the map. Contains up/down/left/right arrows for panning, and zoom in, zoom out, and zoom to maximum map extent buttons for zooming.

  • OpenLayers.Control.ArgParser: Allows the map to zoom to a specific location and turn on/off layers based on the URL that you call the map with. In other...