public class ParseGeoPoint
extends java.lang.Object
implements android.os.Parcelable
ParseGeoPoint represents a latitude / longitude point that may be associated with a key
in a ParseObject or used as a reference point for geo queries. This allows proximity
based queries on the key.
Only one key in a class may contain a ParseGeoPoint.
Example:
ParseGeoPoint point = new ParseGeoPoint(30.0, -20.0);
ParseObject object = new ParseObject("PlaceObject");
object.put("location", point);
object.save();
| Modifier and Type | Field and Description |
|---|---|
static android.os.Parcelable.Creator<ParseGeoPoint> |
CREATOR |
| Modifier | Constructor and Description |
|---|---|
|
ParseGeoPoint()
Creates a new default point with latitude and longitude set to 0.0.
|
|
ParseGeoPoint(double latitude,
double longitude)
Creates a new point with the specified latitude and longitude.
|
protected |
ParseGeoPoint(android.os.Parcel source)
Creates a new point instance from a
Parcel source. |
|
ParseGeoPoint(ParseGeoPoint point)
Creates a copy of
point; |
| Modifier and Type | Method and Description |
|---|---|
int |
describeContents() |
double |
distanceInKilometersTo(ParseGeoPoint point)
Get distance between this point and another
ParseGeoPoint in kilometers. |
double |
distanceInMilesTo(ParseGeoPoint point)
Get distance between this point and another
ParseGeoPoint in kilometers. |
double |
distanceInRadiansTo(ParseGeoPoint point)
Get distance in radians between this point and another
ParseGeoPoint. |
boolean |
equals(java.lang.Object obj) |
static <any> |
getCurrentLocationInBackground(long timeout)
Asynchronously fetches the current location of the device.
|
static <any> |
getCurrentLocationInBackground(long timeout,
android.location.Criteria criteria)
Asynchronously fetches the current location of the device.
|
static void |
getCurrentLocationInBackground(long timeout,
android.location.Criteria criteria,
LocationCallback callback)
Asynchronously fetches the current location of the device.
|
static void |
getCurrentLocationInBackground(long timeout,
LocationCallback callback)
Asynchronously fetches the current location of the device.
|
double |
getLatitude()
Get latitude.
|
double |
getLongitude()
Get longitude.
|
void |
setLatitude(double latitude)
Set latitude.
|
void |
setLongitude(double longitude)
Set longitude.
|
java.lang.String |
toString() |
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public static final android.os.Parcelable.Creator<ParseGeoPoint> CREATOR
public ParseGeoPoint()
public ParseGeoPoint(double latitude,
double longitude)
latitude - The point's latitude.longitude - The point's longitude.public ParseGeoPoint(ParseGeoPoint point)
point;point - The point to copy.protected ParseGeoPoint(android.os.Parcel source)
Parcel source. This is used when unparceling a
ParseGeoPoint. Subclasses that need Parcelable behavior should provide their own
Parcelable.Creator and override this constructor.source - The recovered parcel.public static <any> getCurrentLocationInBackground(long timeout)
This will use a default Criteria with no accuracy or power requirements, which will
generally result in slower, but more accurate location fixes.
timeout - The number of milliseconds to allow before timing out.LocationManager.getBestProvider(android.location.Criteria, boolean),
LocationManager.requestLocationUpdates(String, long, float, android.location.LocationListener)public static void getCurrentLocationInBackground(long timeout,
LocationCallback callback)
This will use a default Criteria with no accuracy or power requirements, which will
generally result in slower, but more accurate location fixes.
timeout - The number of milliseconds to allow before timing out.callback - callback.done(geoPoint, error) is called when a location is found.LocationManager.getBestProvider(android.location.Criteria, boolean),
LocationManager.requestLocationUpdates(String, long, float, android.location.LocationListener)public static <any> getCurrentLocationInBackground(long timeout,
android.location.Criteria criteria)
This will request location updates from the best provider that match the given criteria and return the first location received.
You can customize the criteria to meet your specific needs.
* For higher accuracy, you can set Criteria.setAccuracy(int), however result in longer
times for a fix.
* For better battery efficiency and faster location fixes, you can set
Criteria.setPowerRequirement(int), however, this will result in lower accuracy.
timeout - The number of milliseconds to allow before timing out.criteria - The application criteria for selecting a location provider.LocationManager.getBestProvider(android.location.Criteria, boolean),
LocationManager.requestLocationUpdates(String, long, float, android.location.LocationListener)public static void getCurrentLocationInBackground(long timeout,
android.location.Criteria criteria,
LocationCallback callback)
This will request location updates from the best provider that match the given criteria and return the first location received.
You can customize the criteria to meet your specific needs.
* For higher accuracy, you can set Criteria.setAccuracy(int), however result in longer
times for a fix.
* For better battery efficiency and faster location fixes, you can set
Criteria.setPowerRequirement(int), however, this will result in lower accuracy.
timeout - The number of milliseconds to allow before timing out.criteria - The application criteria for selecting a location provider.callback - callback.done(geoPoint, error) is called when a location is found.LocationManager.getBestProvider(android.location.Criteria, boolean),
LocationManager.requestLocationUpdates(String, long, float, android.location.LocationListener)public double getLatitude()
public void setLatitude(double latitude)
latitude - The point's latitude.public double getLongitude()
public void setLongitude(double longitude)
longitude - The point's longitude.public double distanceInRadiansTo(ParseGeoPoint point)
ParseGeoPoint. This is the
smallest angular distance between the two points.point - ParseGeoPoint describing the other point being measured against.public double distanceInKilometersTo(ParseGeoPoint point)
ParseGeoPoint in kilometers.point - ParseGeoPoint describing the other point being measured against.public double distanceInMilesTo(ParseGeoPoint point)
ParseGeoPoint in kilometers.point - ParseGeoPoint describing the other point being measured against.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic int describeContents()
describeContents in interface android.os.Parcelablepublic void writeToParcel(android.os.Parcel dest,
int flags)
writeToParcel in interface android.os.Parcelable