Location Class

Bing
 

Contains the altitude and coordinate values of a location on the map.

Name

Definition

Description

Location

Location(latitude:number, longitude:number, altitude?:number, altitudeReference?:AltitudeReference)

Initializes a new instance of the Location class. The altitude and altitudeReference parameters default to undefined.

Name

Type

Description

altitude

number

The altitude of the location.

altitudeReference

AltitudeReference

The reference from which the altitude is measured.

latitude

number

The latitude of the location.

longitude

number

The longitude of the location.

Name

Definition

Return Value

Description

areEqual

areEqual(location1:Location, location2:Location)

boolean

Determines if the specified Location objects are equal.

normalizeLongitude

normalizeLongitude(longitude:number)

number

Normalizes the specified longitude so that it is between -180 and 180.

Name

Definition

Return Value

Description

clone

clone()

Location

Returns a copy of the Location object.

toString

toString()

string

Converts the Location object to a string.

<!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=7.0"></script>

      <script type="text/javascript">

      var map = null;

      function GetMap()
      {  

         map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "Bing Maps Key"});

      }

      function SetLocation()
      {
         // Parse the input string
         var latLongArray = (document.getElementById("txtlatlong").value).split(",");

         // Retrieve the latitude and longitude values- normalize the longitude value
         var latVal = parseInt(latLongArray[0]);
         var longVal = Microsoft.Maps.Location.normalizeLongitude(parseInt(latLongArray[1]));

         // Set the map center
         map.setView({center:new Microsoft.Maps.Location(latVal, longVal)});

      }
      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:600px; height:600px;"></div> 
      Latitude, Longitude: <input id="txtlatlong" type="text" value="40, -120"/>
      <input type="button" value="Set center location" onclick="SetLocation();"/>      
   </body>
</html>
Show: