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 Min and Max resolution

Let's look at how to use the minResolution and maxResolution properties and how they affect our zoom levels.

  1. Instantiate your map object, by specifying the the min/max resolution properties:
    //Create a map with an empty array of controls 
    map = new OpenLayers.Map('map_element', { 
        controls: [ 
            new OpenLayers.Control.Navigation(), 
            new OpenLayers.Control.PanZoomBar(), 
            new OpenLayers.Control.LayerSwitcher() 
        ], 
        minResolution: 0.02197265625, 
        maxResolution: 0.3515625 
    });
  2. You should see something like this, with limited zoom levels:
    Time for Action – using Min and Max resolution
  3. Now, let's recreate the map element and set the maxResolution and numZoomLevels ...

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