public class LatLng extends Object implements ILatLng, 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.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<LatLng> |
CREATOR
Inner class responsible for recreating Parcels into objects.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
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(Location location)
Construct a new latitude, longitude, altitude point given location argument
|
protected |
LatLng(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(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.
|
String |
toString()
Returns a string representation of the object.
|
LatLng |
wrap()
Return a new LatLng object with a wrapped Longitude.
|
void |
writeToParcel(Parcel out,
int flags)
Flatten this object in to a Parcel.
|
public static final 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(Location location)
location
- Android Locationpublic LatLng(LatLng latLng)
latLng
- LatLng to be cloned.protected LatLng(Parcel in)
in
- the parcel containing the latitude, longitude, altitude valuespublic void setLatitude(double latitude)
This value is in the range of [-85.05112878, 85.05112878], see GeoConstants.MIN_LATITUDE
and
GeoConstants.MAX_LATITUDE
latitude
- the latitude value in degreesGeoConstants.MIN_LATITUDE
,
GeoConstants.MAX_LATITUDE
public double getLatitude()
This value is in the range of [-85.05112878, 85.05112878], see GeoConstants.MIN_LATITUDE
and
GeoConstants.MAX_LATITUDE
getLatitude
in interface ILatLng
GeoConstants.MIN_LATITUDE
,
GeoConstants.MAX_LATITUDE
public void setLongitude(double longitude)
This value is in the range of [-180, 180], see GeoConstants.MIN_LONGITUDE
and
GeoConstants.MAX_LONGITUDE
longitude
- the longitude value in degreesGeoConstants.MIN_LONGITUDE
,
GeoConstants.MAX_LONGITUDE
public double getLongitude()
This value is in the range of [-180, 180], see GeoConstants.MIN_LONGITUDE
and
GeoConstants.MAX_LONGITUDE
getLongitude
in interface ILatLng
GeoConstants.MIN_LONGITUDE
,
GeoConstants.MAX_LONGITUDE
public void setAltitude(double altitude)
altitude
- the altitude in meterspublic double getAltitude()
getAltitude
in interface ILatLng
public LatLng wrap()
public boolean equals(Object object)
public int hashCode()
public String toString()
public int describeContents()
describeContents
in interface Parcelable
public void writeToParcel(Parcel out, int flags)
writeToParcel
in interface Parcelable
out
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be writtenpublic double distanceTo(LatLng other)
other
- Other LatLng to compare to© 2015–2017 Mapbox. All rights reserved.