Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • OpenLayers 2.10 Beginner's Guide
  • Toc
  • feedback
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)
close
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)

Overview of this book

Table of Contents (18 chapters)
close
OpenLayers 2.10
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 can also use minResolution and maxResolution.

Map/Layer property inheritance

Resolutions/scales/max extent etc. properties can be specified in the map object or layer objects. Preferably, they should be specified in the map, as you won't have to worry...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete