GeoPoint

Parse. GeoPoint

Creates a new GeoPoint with any of the following forms:

  new GeoPoint(otherGeoPoint)
  new GeoPoint(30, 30)
  new GeoPoint([30, 30])
  new GeoPoint({latitude: 30, longitude: 30})
  new GeoPoint()  // defaults to (0, 0)
  

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 GeoPoint.

Example:

  var point = new Parse.GeoPoint(30.0, -20.0);
  var object = new Parse.Object("PlaceObject");
  object.set("location", point);
  object.save();

Constructor

new GeoPoint(options, longitude)

Parameters:
Name Type Description
options Array.<Number> | Object | Number

Either a list of coordinate pairs, an object with latitude, longitude, or the latitude or the point.

longitude Number

The longitude of the GeoPoint

Members

latitude :Number

North-south portion of the coordinate, in range [-90, 90]. Throws an exception if set out of range in a modern browser.

Properties:
Name Type Description
latitude
Type:
  • Number

longitude :Number

East-west portion of the coordinate, in range [-180, 180]. Throws if set out of range in a modern browser.

Properties:
Name Type Description
longitude
Type:
  • Number

Methods

(static) current(options)

Creates a GeoPoint with the user's current location, if available. Calls options.success with a new GeoPoint instance or calls options.error.

Parameters:
Name Type Description
options Object

An object with success and error callbacks.

kilometersTo(point) → {Number}

Returns the distance from this GeoPoint to another in kilometers.

Parameters:
Name Type Description
point Parse.GeoPoint

the other Parse.GeoPoint.

Returns:
Type:
Number

milesTo(point) → {Number}

Returns the distance from this GeoPoint to another in miles.

Parameters:
Name Type Description
point Parse.GeoPoint

the other Parse.GeoPoint.

Returns:
Type:
Number

radiansTo(point) → {Number}

Returns the distance from this GeoPoint to another in radians.

Parameters:
Name Type Description
point Parse.GeoPoint

the other Parse.GeoPoint.

Returns:
Type:
Number

toJSON() → {Object}

Returns a JSON representation of the GeoPoint, suitable for Parse.

Returns:
Type:
Object