PFGeoPoint

@interface PFGeoPoint : NSObject <NSCopying, NSCoding>

PFGeoPoint may be used to embed a latitude / longitude point as the value for a key in a PFObject. It could be used to perform queries in a geospatial manner using PFQuery.-whereKey:nearGeoPoint:.

Currently, instances of PFObject may only have one key associated with a PFGeoPoint type.

  • Create a PFGeoPoint object. Latitude and longitude are set to 0.0.

    Declaration

    Objective-C

    + (nonnull instancetype)geoPoint;

    Return Value

    Returns a new PFGeoPoint.

  • Creates a new PFGeoPoint object for the given CLLocation, set to the location’s coordinates.

    Declaration

    Objective-C

    + (nonnull instancetype)geoPointWithLocation:(nullable CLLocation *)location;

    Parameters

    location

    Instace of CLLocation, with set latitude and longitude.

    Return Value

    Returns a new PFGeoPoint at specified location.

  • Create a new PFGeoPoint object with the specified latitude and longitude.

    Declaration

    Objective-C

    + (nonnull instancetype)geoPointWithLatitude:(double)latitude
                                       longitude:(double)longitude;

    Parameters

    latitude

    Latitude of point in degrees.

    longitude

    Longitude of point in degrees.

    Return Value

    New point object with specified latitude and longitude.

  • Fetches the current device location and executes a block with a new PFGeoPoint object.

    Declaration

    Objective-C

    + (void)geoPointForCurrentLocationInBackground:
            (nullable PFGeoPointResultBlock)resultBlock;

    Parameters

    resultBlock

    A block which takes the newly created PFGeoPoint as an argument. It should have the following argument signature: ^(PFGeoPoint *geoPoint, NSError *error)

  • Latitude of point in degrees. Valid range is from -90.0 to 90.0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) double latitude;
  • Longitude of point in degrees. Valid range is from -180.0 to 180.0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) double longitude;
  • Get distance in radians from this point to specified point.

    Declaration

    Objective-C

    - (double)distanceInRadiansTo:(nullable PFGeoPoint *)point;

    Parameters

    point

    PFGeoPoint that represents the location of other point.

    Return Value

    Distance in radians between the receiver and point.

  • Get distance in miles from this point to specified point.

    Declaration

    Objective-C

    - (double)distanceInMilesTo:(nullable PFGeoPoint *)point;

    Parameters

    point

    PFGeoPoint that represents the location of other point.

    Return Value

    Distance in miles between the receiver and point.

  • Get distance in kilometers from this point to specified point.

    Declaration

    Objective-C

    - (double)distanceInKilometersTo:(nullable PFGeoPoint *)point;

    Parameters

    point

    PFGeoPoint that represents the location of other point.

    Return Value

    Distance in kilometers between the receiver and point.