VEMap.SetHeading Method

You are not viewing the latest version of the AJAX control. Bing Maps AJAX V7 is the recommended JavaScript control for Bing Maps. If you need this documentation, it is available in as a CHM or PDF download.

In 3D mode, sets the compass heading of the current map view.



Parameter Description


The compass direction, expressed as a double. A value of 0 is true north, and a value of 180 is true south. Values less than 0 and greater than 360 are valid and are calculated as compass directions.

The VEMap.SetAltitude Method, SetHeading method, and VEMap.SetPitch Method apply only when the map mode (VEMapMode Enumeration) is set to Mode3D and the current map view is completely loaded. To be sure that the map view is completely loaded, you can use the VEMap.onendpan Event.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src=""></script>

      <script type="text/javascript">
         var map = null;
         var center = new VELatLong(33.338550,-118.424636);
         var initView = new VEMapViewSpecification(center, 1, 900000, -90, 0);

         function GetMap()
            map = new VEMap('myMap');

         function SetHeading()
            if (document.getElementById('txtHdg').value != null && document.getElementById('txtHdg').value <= 360 && document.getElementById('txtHdg').value > -1)
               var heading = map.GetHeading();
               alert("The map heading is " + heading + " degrees.");
               alert("Please enter a value between 0 and 360.");

   <body onload="GetMap();">
      <div id='myMap' style="position: relative; width: 400px; height: 400px;">
      <input id="sethdg" type="button" value="Set a Heading Value" name="sethdg" onclick="SetHeading();">
      <input id="txtHdg" type="text" name="txtHdg" maxlength="3" value="270">