Packagecom.google.maps
Classpublic class LatLng

LatLng is a point in geographical coordinates with 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 coordinate is always written first, followed by the longitude, as is customary in cartography. Notice also that you cannot modify the coordinates of a LatLng. If you want to compute another point, you have to create a new one.



Public Methods
 MethodDefined by
  
LatLng(lat:Number, lng:Number, opt_noCorrect:Boolean = false)
Constructs a LatLng.
LatLng
  
angleFrom(other:LatLng):Number
Returns the angle (radians) between this point and the given point.
LatLng
  
Returns a new LatLng object that is a copy of this.
LatLng
  
distanceFrom(other:LatLng, opt_radius:Number):Number
Returns the distance, in meters, from this point to the given point.
LatLng
  
equals(other:LatLng):Boolean
Tests whether this LatLng is coincident with another specified LatLng, allowing for numerical rounding errors.
LatLng
  
fromRadians(lat:Number, lng:Number, opt_noCorrect:Boolean = false):LatLng
[static] Creates a latlng from radian values.
LatLng
  
fromUrlValue(value:String):LatLng
[static] Parses a string of the form "lat,lng" and returns a point with those values.
LatLng
  
lat():Number
Returns the latitude in degrees.
LatLng
  
latRadians():Number
Returns the latitude in radians.
LatLng
  
lng():Number
Returns the longitude in degrees.
LatLng
  
lngRadians():Number
Returns the longitude in radians.
LatLng
  
toString():String
Returns a string representation of this LatLng, for example '48.8584, 2.2944' for Paris.
LatLng
  
toUrlValue(opt_precision:Number = 6):String
Returns a string of the form "lat,lng" for this LatLng.
LatLng
  
[static] Returns a LatLng that is a copy of the given LatLng, but with latitude clamped to the range [-90, 90] and longitude wrapped to the range [-180, 180].
LatLng
Public Constants
 ConstantDefined by
  EARTH_RADIUS : Number = 6378137
[static] The equatorial radius of the earth in meters.
LatLng
Constructor detail
LatLng()constructor
public function LatLng(lat:Number, lng:Number, opt_noCorrect:Boolean = false)

Constructs a LatLng. If opt_noCorrect is false, we make sure the latitude and longitude are valid, wrapping the longitude appropriately around the dateline and clamping the latitude at the poles. Valid values for longitude lie in the range [-180,180]. Valid values for latitude lie in the range [-90,90].

Parameters
lat:Number — Latitude.
 
lng:Number — Longitude.
 
opt_noCorrect:Boolean (default = false) — Flag: do not correct to valid range.

Example
Construct three LatLng instances.
   var sydney:LatLng = new LatLng(-33.8581, 151.2149);
   var bound:LatLng = new LatLng(10, 190);  // longitude set to -170
   var unbound:LatLng = new LatLng(10, 190, true);  // longitude set to 190

Method detail
angleFrom()method
public function angleFrom(other:LatLng):Number

Returns the angle (radians) between this point and the given point. This is also the distance between those points on a unit sphere.

Parameters
other:LatLng — Other LatLng

Returns
Number — Distance in radians between this and other.

Example
Calculate angle in radians between London and Paris.
   var london:LatLng = new LatLng(51.53, -0.08);
   var paris:LatLng = new LatLng(48.8, 2.33);
   trace("angle: " + paris.angleFrom(london));

clone()method 
public function clone():LatLng

Returns a new LatLng object that is a copy of this.

Returns
LatLng — The new copy.
distanceFrom()method 
public function distanceFrom(other:LatLng, opt_radius:Number):Number

Returns the distance, in meters, from this point to the given point. Since we approximate the earth as a sphere, the distance could be off by as much as 0.3%.

Parameters
other:LatLng — Other LatLng
 
opt_radius:Number — The radius of the planet (default EARTH_RADIUS).

Returns
Number — Distance in meters between this and other.

Example
Calculate distance in km between London and Sydney.
   var london:LatLng = new LatLng(51.53, -0.08);
   var sydney:LatLng = new LatLng(-34.0, 151.0);
   trace("km: " + sydney.distanceFrom(london) / 1000);

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

Tests whether this LatLng is coincident with another specified LatLng, allowing for numerical rounding errors.

Parameters
other:LatLng — LatLng against which to compare.

Returns
Boolean — true if this LatLng is coincident with the other.
fromRadians()method 
public static function fromRadians(lat:Number, lng:Number, opt_noCorrect:Boolean = false):LatLng

Creates a latlng from radian values.

Parameters
lat:Number — Latitude in radians.
 
lng:Number — Longitude in radians.
 
opt_noCorrect:Boolean (default = false) — Flag to prevent correction to valid range.

Returns
LatLng — Resulting LatLng object.
fromUrlValue()method 
public static function fromUrlValue(value:String):LatLng

Parses a string of the form "lat,lng" and returns a point with those values.

Parameters
value:String — "lat,lng" string to parse.

Returns
LatLng — Resulting LatLng.

Example
Create a LatLng from a text string.
   var location:LatLng = LatLng.fromUrlValue("-34,151");

lat()method 
public function lat():Number

Returns the latitude in degrees.

Returns
Number — Latitude in degrees.
latRadians()method 
public function latRadians():Number

Returns the latitude in radians.

Returns
Number — Latitude in radians.
lng()method 
public function lng():Number

Returns the longitude in degrees.

Returns
Number — Longitude in degrees.
lngRadians()method 
public function lngRadians():Number

Returns the longitude in radians.

Returns
Number — Longitude in radians.
toString()method 
public function toString():String

Returns a string representation of this LatLng, for example '48.8584, 2.2944' for Paris.

Returns
String — String representation of this LatLng.
toUrlValue()method 
public function toUrlValue(opt_precision:Number = 6):String

Returns a string of the form "lat,lng" for this LatLng. We round the lat/lng values to 6 decimal places by default.

precisionapproximate error
-11000 kilometers / 700 miles
0100 kilometers / 70 miles
110 kilometers / 7 miles
21 kilometer / 0.7 miles
3100 meters / 300 feet
410 meters / 30 feet
51 meter / 3 feet
610 centimeters / 4 inches
71 centimeter (a nickel)

Parameters
opt_precision:Number (default = 6) — Number of digits following decimal point.

Returns
String — String representation suitable for use as a URL parameter, for example '48.858405,2.294362' for Paris.
wrapLatLng()method 
public static function wrapLatLng(latLng:LatLng):LatLng

Returns a LatLng that is a copy of the given LatLng, but with latitude clamped to the range [-90, 90] and longitude wrapped to the range [-180, 180].

Parameters
latLng:LatLng — Unbound LatLng object.

Returns
LatLng — Bound LatLng object.
Constant detail
EARTH_RADIUSconstant
public static const EARTH_RADIUS:Number = 6378137

The equatorial radius of the earth in meters. Assumes a perfectly spherical earth, and hence is approximate. The earth's radius in fact varies between 6357 km at the pole to 6378 KM at the equator - a difference of 0.3%.