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 – configuring the options parameter


The options parameter is something that is present in all Layer classes, so let's get a bit more familiar with it. I suggest opening up the Layer documentation and following along, and even trying to add in the options yourself from the possible list of layer properties (at http://dev.openlayers.org/docs/files/OpenLayers/Layer-js.html).

  1. Use the template (or code from Chapter 1 with the WMS layer code removed). We'll be adding some WMS layers, and we'll refer to this file as chapter_3_ex2_options_config.html.

  2. First we'll add in a layer that contains the 'basic' layer from the WMS server, like in the previous example.

    // Setup our two layer objects
    var wms_layer_map = new OpenLayers.Layer.WMS(
      'Base layer',
      'http://vmap0.tiles.osgeo.org/wms/vmap0',
      {layers: 'basic'},
      {isBaseLayer: true}
    );
  3. Next we'll create another layer object. We'll create a layer using labels, like in the previous example. This time though, let's set the layer's options...