O'Reilly logo

OpenLayers 3 : Beginner's Guide by Erik Hazzard, Paul Spencer, Thomas Gratier

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 – interacting with a map

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

  1. Edit the example map from Chapter 1, Getting Started with OpenLayers, to change the reference to JavaScript from ../assets/ol3/js/ol.js to ../assets/ol3/js/ol-debug.js and open the file in Chrome. Enable Chrome DevTools and go to the Console panel. If you like, you can take a look at the Network panel and view the network activity to see the requests your page is making.
  2. Go to the Console panel, input the following code, and then execute it:
    console.log(map);
  3. You should see the map object information come up in the console log. Click on ...

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