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 – 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 like before:

    map = new OpenLayers.Map('map_element', {});
  4. Now we're going to create our first layer. We'll use a WMS layer and ask the WMS server for the layer 'basic' (a layer on the WMS service). We'll also explicitly set it to be a base layer.

      var...

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