Packagecom.afcomponents.umap.types
Classpublic class LatLng

LatLng is a point in geographical coordinates longitude and latitude.

Notice that although usual map projections associate longitude with the x-coordinate of the map, and latitude with the y-coordinate, the latitude cooridnate is always written first, followed by the longitude, as it is custom in cartography.

The following code creates a LatLng object at (0,0):
 import com.afcomponents.umap.types.LatLng;
  
 var latlng:LatLng = new LatLng();
 trace(latlng); // traces (lat=0, lng=0);
You can also use unbounded flag to control point's latitude & longitued to stay in the earth's bounds:
 import com.afcomponents.umap.types.LatLng;
  
 var latlng:LatLng = new LatLng(93,215);
  
 trace("original " + latlng); // traces original (lat=93.000000, lng=215.000000)
 latlng.unbounded = false;
 trace("bounded " + latlng); // traces bounded (lat=90.000000, lng=-145.000000)
 latlng.unbounded = true;
 trace("unbounded " + latlng); // traces unbounded (lat=93.000000, lng=215.000000)



Public Properties
 PropertyDefined by
  lat : Number
Gets or sets the point's latitude.
LatLng
  latRadians : Number
[read-only] Returns the latitude coordinate in radians, as a number between -PI/2 and +PI/2.
LatLng
  lng : Number
Gets or sets the point's longitude.
LatLng
  lngRadians : Number
[read-only] Returns the longitude coordinate in radians, as a number between -PI and +PI.
LatLng
  unbounded : Boolean
Gets or sets the unbounded flag.
LatLng
Public Methods
 MethodDefined by
  
LatLng(lat:Number = 0, lng:Number = 0, unbounded:Boolean = true)
Point's constructor.
LatLng
  
Creates a copy of this LatLng object.
LatLng
  
equals(other:LatLng):Boolean
Compares this point with the other.
LatLng
  
fromSexagecimal(string:String):LatLng
[static] Returns a LatLng point from sexagecimal string.
LatLng
  
fromXML(xml:XML):LatLng
[static] Creates new LatLng from XML object in KML 2.1 format.
LatLng
  
[static] Returns new object, which will be constructed from the source XML data.
LatLng
  
getXMLFromType(latlng:LatLng, name:String):XML
[static] Returns XML data that describes the Object.
LatLng
  
isValid():Boolean
Validates the point.
LatLng
  
toSexagecimal():String
Returns a string in sexagecimal format.
LatLng
  
toString():String
Returns a String that represents point's coordiantes.
LatLng
  
toXML(name:String = "coordinates"):XML
Builds an XML object in KML 2.1 format that describes this Object.
LatLng
Public Constants
 ConstantDefined by
  DEFAULT_NODE_NAME : String = "latlng"
[static] Defines default root node name for XML conversion.
LatLng
Property detail
latproperty
lat:Number  [read-write]

Gets or sets the point's latitude. Returns either normal or clamped latitude of the point, based on the unbounded flag.

The default value is 0.

Implementation
    public function get lat():Number
    public function set lat(value:Number):void

See also

latRadiansproperty 
latRadians:Number  [read-only]

Returns the latitude coordinate in radians, as a number between -PI/2 and +PI/2. If the unbounded flag is set, this coordinate can be outside this interval.

Implementation
    public function get latRadians():Number

See also

lngproperty 
lng:Number  [read-write]

Gets or sets the point's longitude. Returns either a normal or wrapped longitude of the point, based on the unbounded flag.

The default value is 0.

Implementation
    public function get lng():Number
    public function set lng(value:Number):void

See also

lngRadiansproperty 
lngRadians:Number  [read-only]

Returns the longitude coordinate in radians, as a number between -PI and +PI. If the unbounded flag is set, this coordinate can be outside this interval.

Implementation
    public function get lngRadians():Number

See also

unboundedproperty 
unbounded:Boolean  [read-write]

Gets or sets the unbounded flag. If the unbounded flag is true, then the numbers will be returned as passed, otherwise latitude will be clamped to lie between -90 degrees and +90 degrees, and longitude will be wrapped to lie between -180 degrees and +180 degrees.

The default value is false.

Implementation
    public function get unbounded():Boolean
    public function set unbounded(value:Boolean):void

See also

Constructor detail
LatLng()constructor
public function LatLng(lat:Number = 0, lng:Number = 0, unbounded:Boolean = true)

Point's constructor.

Creates a new point with given latitude and longitude coordinates. The numbers are always saved as passed to the constructor. If the unbounded flag is true, then the numbers will be returned as passed, otherwise latitude will be clamped to lie between -90 degrees and +90 degrees, and longitude will be wrapped to lie between -180 degrees and +180 degrees.

Parameters
lat:Number (default = 0) — Point's latitude.
 
lng:Number (default = 0) — Point's longitude.
 
unbounded:Boolean (default = true) — - A flag that determines whether point's coordinates should be unbounded.
Method detail
clone()method
public function clone():LatLng

Creates a copy of this LatLng object.

Returns
LatLng — A copy of this object.
equals()method 
public function equals(other:LatLng):Boolean

Compares this point with the other.

Returns true if both points are equal with a certain round-off. Both point's coordinates will be rounded to 6 decimal places.

Parameters
other:LatLng — The object to be compared.

Returns
Boolean — A value of true if both points are equal; false if they are not.
fromSexagecimal()method 
public static function fromSexagecimal(string:String):LatLng

Returns a LatLng point from sexagecimal string.

Parameters
string:String

Returns
LatLng

Example
For example:
  var string:String = "N 10° 14' 4'' E 20° 6' 44''";
  trace ( LatLng.fromSexagecimal(string)); // traces (lat=10.234444, lng=20.112222)
  

fromXML()method 
public static function fromXML(xml:XML):LatLng

Creates new LatLng from XML object in KML 2.1 format.

Parameters
xml:XML

Returns
LatLng — New LatLng object.
getTypeFromXML()method 
public static function getTypeFromXML(xml:XML):LatLng

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

Parameters
xml:XML — Source XML data.

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

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

Parameters
latlng:LatLng — Object that should be converted to XML.
 
name:String — Root node name.

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

Validates the point.

Returns true if both lat and lng components contains a defined Number.

Returns false if lat or lng have a value of NaN.

Returns
Boolean — A value of true if both lat and lng are defined; false if they are not.
toSexagecimal()method 
public function toSexagecimal():String

Returns a string in sexagecimal format.

Returns
String

Example
For example:
  var latLng:LatLng = new LatLng(10.2344,20.1121);
  trace (latLng.toSexagecimal); // traces S 10° 14' 4'' E 20° 6' 44''
  

toString()method 
public function toString():String

Returns a String that represents point's coordiantes.

The output will look like "(lat=lat, lng=lng)"

Returns
String — A textual representation of the point
toXML()method 
public function toXML(name:String = "coordinates"):XML

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

Parameters
name:String (default = "coordinates")

Returns
XML — XML object in KML 2.1 format.
Constant detail
DEFAULT_NODE_NAMEconstant
public static const DEFAULT_NODE_NAME:String = "latlng"

Defines default root node name for XML conversion.