Time for Action – creating a Bing/Virtual Earth Layer
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>
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 byVEMapStyle.
, 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} );
We'll add an aerial (satellite imagery) layer now:
var ve_aerial = new OpenLayers.Layer.VirtualEarth( "Aerial", {type: VEMapStyle.Aerial} );
Now, let's create a default layer. If we don't pass in a
type
, theVEMapStyle.Road
layer will be used. It is similar to the shaded layer, but without the shading. We'll also use another property...