VEMap.GetHeading 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, returns a double that represents the compass heading of the current map view.


A double that represents the compass heading, where 0 is true north and 180 is true south.

The VEMap.GetAltitude Method, the GetHeading method and the VEMap.GetPitch Method return values 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">