com.google.gwt.maps.client.geom
Class LatLng

java.lang.Object
  extended by com.google.gwt.core.client.JavaScriptObject
      extended by com.google.gwt.maps.client.geom.LatLng

public class LatLng
extends com.google.gwt.core.client.JavaScriptObject

A geographical point represented by a latitude and a longitude. Instances of this class are immutable.


Constructor Summary
protected LatLng()
           
 
Method Summary
 double distanceFrom(LatLng other)
          Returns the distance from another LatLng in meters.
 double distanceFrom(LatLng other, double radius)
          Returns the distance from another LatLng in meters.
 double getLatitude()
          Returns the latitude coordinate of this point in degrees as a number between -90 and 90.
 double getLatitudeRadians()
          Returns the latitude coordinate of this point in radians as a number between -pi/2 and pi/2.
 double getLongitude()
          Returns the longitude coordinate of this point in degrees as a number between -180 and 180.
 double getLongitudeRadians()
          Returns the longitude coordinate of this point in radians as a number between -pi and pi.
 boolean isEquals(LatLng other)
          Does what equals() ought to do, but we are constrained by the JS overlay rules.
static LatLng newInstance(double latitude, double longitude)
          Create a new point.
static LatLng newInstance(double latitude, double longitude, boolean unbounded)
          Create a new point.
static com.google.gwt.core.client.JsArray<LatLng> toJsArray(LatLng[] points)
          Convenience routine for creating a JsArray from Java array of LatLng values.
 java.lang.String toUrlValue()
          Returns a string that represents this point in a format suitable for use as a URL parameter value.
 java.lang.String toUrlValue(int precision)
          Returns a string that represents this point in a format suitable for use as a URL parameter value.
 
Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createFunction, createObject, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LatLng

protected LatLng()
Method Detail

newInstance

public static LatLng newInstance(double latitude,
                                 double longitude)
Create a new point. 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:
latitude - value between -90 and +90 degrees (clamped)
longitude - value between -180 and +180 degrees (wrapped)

newInstance

public static LatLng newInstance(double latitude,
                                 double longitude,
                                 boolean unbounded)
Create a new point. 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:
latitude - value between -90 and +90 degrees (clamped)
longitude - value between -180 and +180 degrees (wrapped)
unbounded - if true, then numbers will not be wrapped or clamped.

toJsArray

public static com.google.gwt.core.client.JsArray<LatLng> toJsArray(LatLng[] points)
Convenience routine for creating a JsArray from Java array of LatLng values.

Parameters:
points - A Java array of LatLng values
Returns:
A JavaScript array of LatLng values

distanceFrom

public final double distanceFrom(LatLng other)
Returns the distance from another LatLng in meters. By default, this distance is calculated given the default equatorial earth radius of 6378137 meters. This measurement can be off by as much as 0.3% since the Earth is approximated as a sphere. See distanceFrom(LatLng, double).

Parameters:
other - point to measure distance to
Returns:
the distance computed between the two points

distanceFrom

public final double distanceFrom(LatLng other,
                                 double radius)
Returns the distance from another LatLng in meters. By default, this distance is calculated given the default equatorial earth radius of 6378137 meters. The earth is approximated as a sphere, hence the distance could be off as much as 0.3%, especially in the polar extremes.

Parameters:
other - point to measure distance to
radius - alternative radius value to use.
Returns:
the distance computed between the two points

getLatitude

public final double getLatitude()
Returns the latitude coordinate of this point in degrees as a number between -90 and 90.

Returns:
the latitude coordinate of this point in degrees.

getLatitudeRadians

public final double getLatitudeRadians()
Returns the latitude coordinate of this point in radians as a number between -pi/2 and pi/2.

Returns:
the latitude coordinate of this point in radians

getLongitude

public final double getLongitude()
Returns the longitude coordinate of this point in degrees as a number between -180 and 180.

Returns:
the longitude coordinate of this point in degrees.

getLongitudeRadians

public final double getLongitudeRadians()
Returns the longitude coordinate of this point in radians as a number between -pi and pi.

Returns:
the longitude coordinate of this point in degrees.

isEquals

public final boolean isEquals(LatLng other)
Does what equals() ought to do, but we are constrained by the JS overlay rules.

Parameters:
other - a point to compare
Returns:
true if the latitude and longitude match.

toUrlValue

public final java.lang.String toUrlValue()
Returns a string that represents this point in a format suitable for use as a URL parameter value.

Returns:
a URL-safe string that represents this point

toUrlValue

public final java.lang.String toUrlValue(int precision)
Returns a string that represents this point in a format suitable for use as a URL parameter value. For example, a precision of six digits corresponds to a resolution of 4 inches or 11 centimeters.

Parameters:
precision - the precision in number of digits
Returns:
a URL-safe string that represents this point