VEMap.GetAltitude 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 altitude (in meters) above the geoid.


VEMap.GetAltitude();

A double that represents the altitude (in meters) above the geoid.

Altitude is represented as meters above the geoid, not above the ground level.

The GetAltitude method, VEMap.GetHeading Method, and 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>

      <script type="text/javascript">
         var map = null;
         var alt = null;
         var center = new VELatLong(33.338550,-118.424636);
         var initView = new VEMapViewSpecification(center, 1, 50000, -90, 0);
         
         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap();

            map.SetMapMode(VEMapMode.Mode3D);
            map.SetMapStyle(VEMapStyle.Aerial);
            map.SetMapView(initView);
            map.AttachEvent("onendzoom", GetAltitude);
         } 
         
         function GetAltitude()
         {
            var dblAlt = map.GetAltitude();
            showAltitude.innerHTML = "<p>Altitude: " + dblAlt + " meters.</p>";
         }
         
         function SetAltitude()
         {
            map.SetAltitude(document.getElementById('txtAlt').value);
         }
      </script>
   </head>
   <body onload="GetMap();" style="font-family:Arial">
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
      <INPUT id="setaltitude" type="button" value="Set Altitude" name="setaltitude" 
         onclick="SetAltitude();"/>
      <INPUT id="txtAlt" type="text" value="20000" name="txtAlt" />
      <div id="showAltitude"></div>
   </body>
</html>

Show: