VEMap.SetAltitude 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 altitude, in meters, above the WGS 84 ellipsoid in the map view.

VEMap.SetAltitude(altitude);

Parameters

Parameter Description

altitude

The altitude, in meters

Remarks

The SetAltitude method, VEMap.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.

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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="https://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>