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

Time for Action – setting zoom levels and maxExtent

  1. Create your map object, by specifying the numZoomLevels and adding a PanZoomBar control. We'll also set the numZoomLevels property to 8, meaning that only eight zoom levels will be available. Lastly, we'll set the maxExtent property to include just a subset of the world, like the following:
    map = new OpenLayers.Map('map_element', {
      controls: [
        new OpenLayers.Control.Navigation(),
        new OpenLayers.Control.PanZoomBar(),
        new OpenLayers.Control.LayerSwitcher()
      ],
      numZoomLevels: 8,
      maxExtent: new OpenLayers.Bounds(-100, -30, 40, 30)
    });
  2. Open up the page, and you should see something like this:
    Time for Action – setting zoom levels and maxExtent

What Just ...

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