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 – creating a Bing/Virtual Earth Layer


  1. Include a reference to the Microsoft Mapping API in your <head> section, before the OpenLayers inclusion script:

    <script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=en-us"></script>
  2. Let's set up some layer objects now. We specify the type property like in the previous examples. For this layer, the type is prefixed by VEMapStyle., which stands for 'Virtual Earth Map Style'. Let's create a 'shaded' layer, which in this case is the street/road layer with shaded elevation:

    var ve_shaded = new OpenLayers.Layer.VirtualEarth(
      "Shaded",
      {type: VEMapStyle.Shaded}
    );
  3. We'll add an aerial (satellite imagery) layer now:

    var ve_aerial = new OpenLayers.Layer.VirtualEarth(
      "Aerial",
      {type: VEMapStyle.Aerial}
    );
  4. Now, let's create a default layer. If we don't pass in a type, the VEMapStyle.Road layer will be used. It is similar to the shaded layer, but without the shading. We'll also use another property...