Packagecom.afcomponents.umap.types
Classpublic class LatLngBounds

LatLngBounds represents a rectangle in geographical coordinates.

This class can also be used to create a rectangle that crosses the 180 degrees meridian. Rectangle is created using south-west (top-left) and north-east (bottom-right) corners. These coreners should be specified as LatLng objects.

Here is a quick usage example:
 import com.afcomponents.umap.types.LatLngBounds;
 import com.afcomponents.umap.types.LatLng;
  
 var sw:LatLng = new LatLng(-30, -50);
 var ne:LatLng = new LatLng(14, 12);
  
 var bounds:LatLngBounds = new LatLngBounds(sw, ne);
 trace("bounds " + bounds);
 // traces bounds (south-west=(lat=-30.000000, lng=-50.000000), north-east=(lat=14.000000, lng=12.000000))
  
 var point:LatLng = new LatLng(0, 10);
 trace("bounds contain " + point + " " + bounds.containsLatLng(point));
 // traces bounds contain (lat=0.000000, lng=10.000000) true
  
 point = new LatLng(-31, 0);
 trace("bounds contain " + point + " " + bounds.containsLatLng(point));
 // traces bounds contain (lat=-31.000000, lng=0.000000) false



Public Properties
 PropertyDefined by
  height : Number
[read-only] The height of the rectangle.
LatLngBounds
  northEast : LatLng
Gets or sets coordinates of the north-east (bottom-right) corner.
LatLngBounds
  southWest : LatLng
Gets or sets coordinates of the south-west (top-left) corner.
LatLngBounds
  width : Number
[read-only] The width of the rectangle.
LatLngBounds
Public Methods
 MethodDefined by
  
LatLngBounds constructor.
LatLngBounds
  
addBounds(bounds:LatLngBounds):Boolean
Extends current bounding rectangle with the specified bounds.
LatLngBounds
  
addLatLng(latlng:LatLng):Boolean
Extends current bounding rectangle with the specified point.
LatLngBounds
  
Creates a copy of this LatLngBounds object.
LatLngBounds
  
containsBounds(bounds:LatLngBounds):Boolean
Checks whether given rectangle lies within this rectangle.
LatLngBounds
  
containsLatLng(latlng:LatLng):Boolean
Checks whether given point lies within this rectangle.
LatLngBounds
  
equals(other:LatLngBounds):Boolean
Determines whether two rectangles are equal.
LatLngBounds
  
[static] Creates new LatLngBounds from XML object in KML 2.1 format.
LatLngBounds
  
[static] Returns new object, which will be constructed from the source XML data.
LatLngBounds
  
getXMLFromType(bounds:LatLngBounds, name:String):XML
[static] Returns XML data that describes the Object.
LatLngBounds
  
intersects(bounds:LatLngBounds):Boolean
Checks whether given rectangle intersects with this rectangle.
LatLngBounds
  
isValid():Boolean
Validates the rectangle.
LatLngBounds
  
Limits a point by the boundaries of this rectangle.
LatLngBounds
  
toLatLngArray(closed:Boolean = false):Array
Returns an Array with corner points of the rectangle in geographical coordinates.
LatLngBounds
  
toString():String
Returns a String that represents the coordinates of the rectangle's corners.
LatLngBounds
  
toXML(name:String = "LatLonBox"):XML
Builds an XML object in KML 2.1 format that describes this Object.
LatLngBounds
Public Constants
 ConstantDefined by
  DEFAULT_NODE_NAME : String = "latlngBounds"
[static] Defines default root node name for XML conversion.
LatLngBounds
Property detail
heightproperty
height:Number  [read-only]

The height of the rectangle. If target rectangle is invalid, height equals Number.NaN

Implementation
    public function get height():Number

See also

northEastproperty 
northEast:LatLng  [read-write]

Gets or sets coordinates of the north-east (bottom-right) corner.

Implementation
    public function get northEast():LatLng
    public function set northEast(value:LatLng):void
southWestproperty 
southWest:LatLng  [read-write]

Gets or sets coordinates of the south-west (top-left) corner.

Implementation
    public function get southWest():LatLng
    public function set southWest(value:LatLng):void
widthproperty 
width:Number  [read-only]

The width of the rectangle. If target rectangle is invalid, width equals Number.NaN

Implementation
    public function get width():Number

See also

Constructor detail
LatLngBounds()constructor
public function LatLngBounds(sw:LatLng, ne:LatLng)

LatLngBounds constructor.

Constructs a rectangle from the points at its south-west (top-left) and north-east (bottom-right) corners.

Parameters
sw:LatLng — Coordinates of the south-west (top-left) corner.
 
ne:LatLng — Coordinates of the north-east (bottom-right) corner.
Method detail
addBounds()method
public function addBounds(bounds:LatLngBounds):Boolean

Extends current bounding rectangle with the specified bounds.

Parameters
bounds:LatLngBounds — Bounding rectangle that should be added to the current bounds.

Returns
Boolean — A value of true if current bounding reactangle has been changed; false if it has not.
addLatLng()method 
public function addLatLng(latlng:LatLng):Boolean

Extends current bounding rectangle with the specified point.

Parameters
latlng:LatLng — A point that should be added to the current bounds.

Returns
Boolean — A value of true if current bounding reactangle has been changed; false if it has not.
clone()method 
public function clone():LatLngBounds

Creates a copy of this LatLngBounds object.

Returns
LatLngBounds — A copy of this object.
containsBounds()method 
public function containsBounds(bounds:LatLngBounds):Boolean

Checks whether given rectangle lies within this rectangle.

Returns true if given rectangle lies within this rectangle.
Returns false if any point of the given rectangle lies outside of this rectangle, or if specified rectangle or target rectangle are invalid.

Parameters
bounds:LatLngBounds — Target bounds object for checking.

Returns
Boolean — A value of true if given rectangle lies within this rectangle.

See also

containsLatLng()method 
public function containsLatLng(latlng:LatLng):Boolean

Checks whether given point lies within this rectangle.

Returns true if given point lies within this rectangle.
Returns false if given point lies outside of this rectangle, or if specified point or target rectangle are invalid.

Parameters
latlng:LatLng — Target latlng object for checking.

Returns
Boolean — A value of true if given point lies within this rectangle; false if it is not.

See also

equals()method 
public function equals(other:LatLngBounds):Boolean

Determines whether two rectangles are equal.

Two rectangles are equal if all parameters in this rectangle are equal to the parameters of the other.

Parameters
other:LatLngBounds — The object to be compared.

Returns
Boolean — A value of true if object is equal to this Bounds object; false if it is not.
fromXML()method 
public static function fromXML(xml:XML):LatLngBounds

Creates new LatLngBounds from XML object in KML 2.1 format.

Parameters
xml:XML

Returns
LatLngBounds — New LatLngBounds object.

Example
Here is a sample XML:
  <LatLonBox xmlns="http://earth.google.com/kml/2.1">
        <north>...</north>                      <! kml:angle90 -->
        <south>...</south>                      <! kml:angle90 -->
        <east>...</east>                        <! kml:angle180 -->
        <west>...</west>                        <! kml:angle180 -->
  </LatLonBox>

getTypeFromXML()method 
public static function getTypeFromXML(xml:XML):LatLngBounds

Returns new object, which will be constructed from the source XML data.

Parameters
xml:XML — Source XML data.

Returns
LatLngBounds — Object that was constructed from the source XML data.
getXMLFromType()method 
public static function getXMLFromType(bounds:LatLngBounds, name:String):XML

Returns XML data that describes the Object. You can also specify root node name in the second parameter.

Parameters
bounds:LatLngBounds — Object that should be converted to XML.
 
name:String — Root node name.

Returns
XML — XML data that describes the properties of the source object.
intersects()method 
public function intersects(bounds:LatLngBounds):Boolean

Checks whether given rectangle intersects with this rectangle.

Returns true if given rectangle intersects within this rectangle.
Returns false if all points of the given rectangle lie outside of this rectangle, or if specified rectangle or target rectangle are invalid.

Parameters
bounds:LatLngBounds — Target bounds object for checking.

Returns
Boolean — A value of true if given rectangle intersects within this rectangle; false if it is not.

See also

isValid()method 
public function isValid():Boolean

Validates the rectangle.

Returns true if both south-west and north-east corners are defined.
Returns false if south-west or north-east corners are invalid or have a value of null.

Returns
Boolean — A value of true if both south-west and north-east corners are defined; false if they are not.

See also

Number.NaN
limitLatLng()method 
public function limitLatLng(latlng:LatLng):LatLng

Limits a point by the boundaries of this rectangle. Doesn't creates a copy of the given point.

Parameters
latlng:LatLng — Target point to check.

Returns
LatLng — If the point has been moved, returns the modified point.

See also

toLatLngArray()method 
public function toLatLngArray(closed:Boolean = false):Array

Returns an Array with corner points of the rectangle in geographical coordinates.

Parameters
closed:Boolean (default = false) — A flag which indicates whether to return a closed shape (true), with first point repeated twice at the beginning and at the end of the resulting array.

Returns
Array — An Array with reactangle corner points, or null it the rectangle is invalid.
toString()method 
public function toString():String

Returns a String that represents the coordinates of the rectangle's corners.

The output will look like "(south-west=south-west corner, norh-east=north-east corner)"

Returns
String — A textual representation of the rectangle.
toXML()method 
public function toXML(name:String = "LatLonBox"):XML

Builds an XML object in KML 2.1 format that describes this Object.

Parameters
name:String (default = "LatLonBox")

Returns
XML — XML object in KML 2.1 format.

Example
Here is a sample XML:
  <LatLonBox xmlns="http://earth.google.com/kml/2.1">
        <north>...</north>                      <! kml:angle90 -->
        <south>...</south>                      <! kml:angle90 -->
        <east>...</east>                        <! kml:angle180 -->
        <west>...</west>                        <! kml:angle180 -->
  </LatLonBox>

Constant detail
DEFAULT_NODE_NAMEconstant
public static const DEFAULT_NODE_NAME:String = "latlngBounds"

Defines default root node name for XML conversion.