public class LatLng
extends java.lang.Object
implements android.os.Parcelable
Latitude and longitude are expressed as decimal degrees in the WGS84 datum. By default, altitude is 0.0, or sea level.
Mapbox GL displays maps in the Mercator Projection and projects geographical data automatically, so all data enters in the WGS84 datum.
Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator<LatLng> |
CREATOR
Inner class responsible for recreating Parcels into objects.
|
Modifier | Constructor and Description |
---|---|
|
LatLng()
Construct a new latitude, longitude point at (0, 0)
|
|
LatLng(double latitude,
double longitude)
Construct a new latitude, longitude point given double arguments
|
|
LatLng(double latitude,
double longitude,
double altitude)
Construct a new latitude, longitude, altitude point given double arguments
|
|
LatLng(LatLng latLng)
Construct a new latitude, longitude, altitude point given another latitude, longitude, altitude point.
|
|
LatLng(android.location.Location location)
Construct a new latitude, longitude, altitude point given location argument
|
protected |
LatLng(android.os.Parcel in)
Constructs a new latitude, longitude, altitude tuple given a parcel.
|
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
|
double |
distanceTo(LatLng other)
Calculate distance between two points
|
boolean |
equals(java.lang.Object object)
Indicates whether some other object is "equal to" this one.
|
double |
getAltitude()
Get the altitude, in meters.
|
double |
getLatitude()
Get the latitude, in degrees.
|
double |
getLongitude()
Get the longitude, in degrees.
|
int |
hashCode()
Returns a hash code value for the object.
|
void |
setAltitude(double altitude)
Set the altitude, in meters.
|
void |
setLatitude(double latitude)
Set the latitude, in degrees.
|
void |
setLongitude(double longitude)
Set the longitude, in degrees.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
LatLng |
wrap()
Return a new LatLng object with a wrapped Longitude.
|
void |
writeToParcel(android.os.Parcel out,
int flags)
Flatten this object in to a Parcel.
|
public static final android.os.Parcelable.Creator<LatLng> CREATOR
public LatLng()
public LatLng(double latitude, double longitude)
latitude
- Latitude in degreeslongitude
- Longitude in degreespublic LatLng(double latitude, double longitude, double altitude)
latitude
- Latitude in degreeslongitude
- Longitude in degressaltitude
- Altitude in meterspublic LatLng(android.location.Location location)
location
- Android Locationpublic LatLng(LatLng latLng)
latLng
- LatLng to be cloned.protected LatLng(android.os.Parcel in)
in
- the parcel containing the latitude, longitude, altitude valuespublic void setLatitude(@FloatRange(from=-90.0,to=90.0) double latitude)
This value is in the range of [-90, 90], see GeometryConstants.MIN_LATITUDE
and
GeometryConstants.MAX_LATITUDE
latitude
- the latitude value in degreesGeometryConstants.MIN_LATITUDE
,
GeometryConstants.MAX_LATITUDE
public double getLatitude()
This value is in the range of [-90, 90], see GeometryConstants.MIN_LATITUDE
and
GeometryConstants.MAX_LATITUDE
GeometryConstants.MIN_LATITUDE
,
GeometryConstants.MAX_LATITUDE
public void setLongitude(@FloatRange(from=-1.7976931348623157E308,to=1.7976931348623157E308) double longitude)
This value is in the range of [-180, 180], see GeometryConstants.MIN_LONGITUDE
and
GeometryConstants.MAX_LONGITUDE
longitude
- the longitude value in degreesGeometryConstants.MIN_LONGITUDE
,
GeometryConstants.MAX_LONGITUDE
public double getLongitude()
This value is in the range of [-180, 180], see GeometryConstants.MIN_LONGITUDE
and
GeometryConstants.MAX_LONGITUDE
GeometryConstants.MIN_LONGITUDE
,
GeometryConstants.MAX_LONGITUDE
public void setAltitude(double altitude)
altitude
- the altitude in meterspublic double getAltitude()
@NonNull public LatLng wrap()
public boolean equals(@Nullable java.lang.Object object)
equals
in class java.lang.Object
object
- The object to comparepublic int hashCode()
hashCode
in class java.lang.Object
@NonNull public java.lang.String toString()
toString
in class java.lang.Object
public int describeContents()
describeContents
in interface android.os.Parcelable
public void writeToParcel(@NonNull android.os.Parcel out, int flags)
writeToParcel
in interface android.os.Parcelable
out
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be writtenpublic double distanceTo(@NonNull LatLng other)
other
- Other LatLng to compare to