Class ParseGeoPoint
- java.lang.Object
-
- com.parse.ParseGeoPoint
-
public class ParseGeoPoint extends java.lang.Object
ParseGeoPoint
represents a latitude / longitude point that may be associated with a key in aParseObject
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();
-
-
Field Summary
Fields Modifier and Type Field Description static <any>
CREATOR
-
Constructor Summary
Constructors Constructor 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.ParseGeoPoint(ParseGeoPoint point)
Creates a copy ofpoint
;
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
describeContents()
double
distanceInKilometersTo(ParseGeoPoint point)
Get distance between this point and anotherParseGeoPoint
in kilometers.double
distanceInMilesTo(ParseGeoPoint point)
Get distance between this point and anotherParseGeoPoint
in kilometers.double
distanceInRadiansTo(ParseGeoPoint point)
Get distance in radians between this point and anotherParseGeoPoint
.boolean
equals(java.lang.Object obj)
static <any>
getCurrentLocationInBackground(long timeout)
Asynchronously fetches the current location of the device.static void
getCurrentLocationInBackground(long timeout, LocationCallback callback)
Asynchronously fetches the current location of the device.static <any>
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.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(Parcel dest, int flags)
-
-
-
Constructor Detail
-
ParseGeoPoint
public ParseGeoPoint()
Creates a new default point with latitude and longitude set to 0.0.
-
ParseGeoPoint
public ParseGeoPoint(double latitude, double longitude)
Creates a new point with the specified latitude and longitude.- Parameters:
latitude
- The point's latitude.longitude
- The point's longitude.
-
ParseGeoPoint
public ParseGeoPoint(ParseGeoPoint point)
Creates a copy ofpoint
;- Parameters:
point
- The point to copy.
-
-
Method Detail
-
getCurrentLocationInBackground
public static <any> getCurrentLocationInBackground(long timeout)
Asynchronously fetches the current location of the device.This will use a default
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.
- Parameters:
timeout
- The number of milliseconds to allow before timing out.- Returns:
- A Task that is resolved when a location is found.
- See Also:
android.location.LocationManager#getBestProvider(android.location.Criteria, boolean)
,android.location.LocationManager#requestLocationUpdates(String, long, float, android.location.LocationListener)
-
getCurrentLocationInBackground
public static void getCurrentLocationInBackground(long timeout, LocationCallback callback)
Asynchronously fetches the current location of the device.This will use a default
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.
- Parameters:
timeout
- The number of milliseconds to allow before timing out.callback
- callback.done(geoPoint, error) is called when a location is found.- See Also:
android.location.LocationManager#getBestProvider(android.location.Criteria, boolean)
,android.location.LocationManager#requestLocationUpdates(String, long, float, android.location.LocationListener)
-
getCurrentLocationInBackground
public static <any> getCurrentLocationInBackground(long timeout, Criteria criteria)
Asynchronously fetches the current location of the device.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 setCriteria#setPowerRequirement(int)
, however, this will result in lower accuracy.- Parameters:
timeout
- The number of milliseconds to allow before timing out.criteria
- The application criteria for selecting a location provider.- Returns:
- A Task that is resolved when a location is found.
- See Also:
android.location.LocationManager#getBestProvider(android.location.Criteria, boolean)
,android.location.LocationManager#requestLocationUpdates(String, long, float, android.location.LocationListener)
-
getCurrentLocationInBackground
public static void getCurrentLocationInBackground(long timeout, Criteria criteria, LocationCallback callback)
Asynchronously fetches the current location of the device.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 setCriteria#setPowerRequirement(int)
, however, this will result in lower accuracy.- Parameters:
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.- See Also:
android.location.LocationManager#getBestProvider(android.location.Criteria, boolean)
,android.location.LocationManager#requestLocationUpdates(String, long, float, android.location.LocationListener)
-
getLatitude
public double getLatitude()
Get latitude.
-
setLatitude
public void setLatitude(double latitude)
Set latitude. Valid range is (-90.0, 90.0). Extremes should not be used.- Parameters:
latitude
- The point's latitude.
-
getLongitude
public double getLongitude()
Get longitude.
-
setLongitude
public void setLongitude(double longitude)
Set longitude. Valid range is (-180.0, 180.0). Extremes should not be used.- Parameters:
longitude
- The point's longitude.
-
distanceInRadiansTo
public double distanceInRadiansTo(ParseGeoPoint point)
Get distance in radians between this point and anotherParseGeoPoint
. This is the smallest angular distance between the two points.- Parameters:
point
-ParseGeoPoint
describing the other point being measured against.
-
distanceInKilometersTo
public double distanceInKilometersTo(ParseGeoPoint point)
Get distance between this point and anotherParseGeoPoint
in kilometers.- Parameters:
point
-ParseGeoPoint
describing the other point being measured against.
-
distanceInMilesTo
public double distanceInMilesTo(ParseGeoPoint point)
Get distance between this point and anotherParseGeoPoint
in kilometers.- Parameters:
point
-ParseGeoPoint
describing the other point being measured against.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
describeContents
public int describeContents()
-
writeToParcel
public void writeToParcel(Parcel dest, int flags)
-
-