VEMap.SetPitch 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 pitch of the current map view.

VEMap.SetPitch(pitch);

Parameters

Parameter Description

pitch

The pitch direction, expressed as a double. A value of 0 is level and a value of -90 is straight down. Values less than -90 or greater than 0 are ignored, and the pitch is set to -90.

Remarks

The VEMap.SetAltitude Method, VEMap.SetHeading Method, and 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;
 
         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap();

            map.SetMapMode(VEMapMode.Mode3D);
            map.SetMapStyle(VEMapStyle.Aerial);
            var latLong = new VELatLong(32.79590319365016, -117.25798010185956);
            map.SetCenterAndZoom(latLong, 15);
         }   
     
         function SetPitch()
         {
            //The pitch direction, expressed as a double.
            //A value of 0 is level and a value of -90 is straight down.
            //Values less than -90 or greater than 0 are ignored, and the pitch is set to -90.
            if(!isNaN(document.getElementById('txtPitch').value)) 
            {
               if(document.getElementById('txtPitch').value > 0)
               {
                  document.getElementById('txtPitch').value = -(document.getElementById('txtPitch').value);
               }

               if(document.getElementById('txtPitch').value < -90)
               {
                  alert("Please enter a value between 0 and -90.");
                  return;
               }

               map.SetPitch(document.getElementById('txtPitch').value);
            }
            else
            {
               alert("Please enter a numeric value between 0 and -90.");
            }
         }
      </script>
   </head>
   <body onload="GetMap();" style="font-family:Arial">
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
      Enter a value between 0 and -90.<br />
      <input id="txtPitch" type="text" value="0" style="width:50px"/>
      <input id="btnSetPitch" type="button" value="Set Pitch" onclick="SetPitch()">
   </body>
</html>