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 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", ...

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