Export (0) Print
Expand All

LocationRect Class

Bing

Represents a rectangle on the map.

Constructor

Name Definition Description

LocationRect

LocationRect(center: Location , width:number, height:number)

Initializes a new instance of the LocationRect class.

Properties

Name Type Description

center

Location

The location that defines the center of the rectangle.

height

number

The height, in degrees, of the rectangle.

width

number

The width, in degrees, of the rectangle.

Static Methods

Name Definition Return Value Description

fromCorners

fromCorners(northwest: Location , southeast: Location )

LocationRect

Returns a LocationRect using the specified locations for the northwest and southeast corners.

fromEdges

fromEdges(north:number, west:number, south:number, east:number, altitude:number, altitudeReference: AltitudeReference )

LocationRect

Returns a LocationRect using the specified northern and southern latitudes and western and eastern longitudes for the rectangle boundaries.

fromLocations

fromLocations(list of locations/array)

LocationRect

Returns a LocationRect using a list of locations or an array of locations.

To provide a list of locations:
Microsoft.Maps.LocationRect.fromLocations(location1, location2, location3);

To provide an array of locations:
var locations = [location1, location2, location3];
Microsoft.Maps.LocationRect.fromLocations(locations);

fromString

fromString(string:string)

LocationRect

Creates a LocationRect from a string with the following format: "north,west,south,east". North, west, south and east specify the coordinate number values.

Methods

Name Definition Return Value Description

clone

clone()

LocationRect

Returns a copy of the LocationRect object.

contains

contains(location: Location )

boolean

Returns whether the specified Location is within the LocationRect.

getEast

getEast()

number

Returns the longitude that defines the eastern edge of the LocationRect.

getNorth

getNorth()

number

Returns the latitude that defines the northern edge of the LocationRect.

getNorthwest

getNorthwest()

Location

Returns the Location that defines the northwest corner of the LocationRect.

getSouth

getSouth()

number

Returns the latitude that defines the southern edge of the LocationRect.

getSoutheast

getSoutheast()

Location

Returns the Location that defines the southeast corner of the LocationRect.

getWest

getWest()

number

Returns the latitude that defines the western edge of the LocationRect.

intersects

intersects(rect: LocationRect )

boolean

Returns whether the specified LocationRect intersects with this LocationRect.

toString

toString()

string

Converts the LocationRect object to a string.

Example

<!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"});

         var viewRect = Microsoft.Maps.LocationRect.fromCorners(new Microsoft.Maps.Location(40,-120), new Microsoft.Maps.Location(35,-115));

         map.setView({bounds: viewRect});

      }

      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:500px; height:500px;"></div>       
   </body>
</html>
Show:
© 2014 Microsoft