public class ParseGeoPoint extends Object
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();
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.
|
Modifier and Type | Method and Description |
---|---|
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 . |
static Task<ParseGeoPoint> |
getCurrentLocationInBackground(long timeout)
Asynchronously fetches the current location of the device.
|
static Task<ParseGeoPoint> |
getCurrentLocationInBackground(long timeout,
Criteria criteria)
Asynchronously fetches the current location of the device.
|
static void |
getCurrentLocationInBackground(long timeout,
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.
|
String |
toString() |
public ParseGeoPoint()
public ParseGeoPoint(double latitude, double longitude)
latitude
- The point's latitude.longitude
- The point's longitude.public void setLatitude(double latitude)
latitude
- The point's latitude.public double getLatitude()
public void setLongitude(double longitude)
longitude
- The point's longitude.public double getLongitude()
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 static Task<ParseGeoPoint> getCurrentLocationInBackground(long timeout)
Criteria
with no accuracy or power requirements, which will
generally result in slower, but more accurate location fixes.
Note: If GPS is the best provider, it might not be able to locate the device
at all and timeout.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)
Criteria
with no accuracy or power requirements, which will
generally result in slower, but more accurate location fixes.
Note: If GPS is the best provider, it might not be able to locate the device
at all and timeout.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 Task<ParseGeoPoint> getCurrentLocationInBackground(long timeout, Criteria criteria)
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, Criteria criteria, LocationCallback callback)
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)