O'Reilly logo

OpenLayers 2.10 by Erik Hazzard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required