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 – creating a map with multiple layers

Let's create a map with two WMS layers. One layer will act as our base layer, and the other will be an overlay layer containing labels for country, state, and city names.

  1. Create a copy of the file you made for the last example of Chapter 1 and remove the existing WMS layer code (or, use the template from http://vasir.net/openlayers_book/). You can name it whatever you'd like, but we'll refer to it as chapter3_ex1_wms_layers.html. Make sure it is in the same directory as your OpenLayers.js file.
  2. First we're going to remove everything that was in the init() function. Your function should now look like this:
    function init() {
    }
    
  3. Next, inside the init() function, we're going to setup our map object ...

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