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 – using resolutions array

Setting the resolutions array is one way to specify the number of zoom levels. Let's see it in action.

  1. In the map object definition specify the resolution array as the following:
    map = new OpenLayers.Map('map_element', {
      resolutions: [ 1.40625,0.703125, 0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125 ]
    });
  2. Zoom around on the map. Because we've only provided five possible resolutions, you should be able to zoom in five times.

What Just Happened?

Using the resolutions array, we were able to specify the number of zoom levels. Unless we're using a cached tile service, this isn't necessarily the easiest way to specify the number of zoom levels. We have mentioned earlier we can also use scales, and we ...

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