Book Image

OpenLayers 2.10 Beginner's Guide

Book Image

OpenLayers 2.10 Beginner's Guide

Overview of this book

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

Time for Action – interacting with a map


We'll use the map we created in Chapter 1 to do this example, interacting with our OpenLayers map by calling various functions of the map.

  1. Open up the map from Chapter 1 in Firefox. Enable Firebug and the Console panel. If you would like, you can take a look at the Net panel and view the network activity to see the requests your page is making.

  2. Go to the Console panel, input and then execute the following code:

    console.log(map);
  3. You should see the map object information come up in the console log. Click on it, and take a moment to look over the various attributes it has. Near the bottom, you can see a list of all the functions that belong to it (which are also referred to as methods).

    Take note of the function names, as we'll be using them.

  4. Go back to the Console panel, type in and execute the following code:

    map.zoomIn();
    map.getExtent();
  5. Take note of the extent. Clear out the code you typed in, then type in the following and execute it:

    map.zoomToMaxExtent...