ParsePolygon

Parse~ ParsePolygon

Creates a new Polygon with any of the following forms:

  new Polygon([[0,0],[0,1],[1,1],[1,0]])
  new Polygon([GeoPoint, GeoPoint, GeoPoint])
  

Represents a coordinates 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.

Example:

  var polygon = new Parse.Polygon([[0,0],[0,1],[1,1],[1,0]]);
  var object = new Parse.Object("PlaceObject");
  object.set("area", polygon);
  object.save();

Constructor

new ParsePolygon(coordinates)

Parameters:
Name Type Description
coordinates Array.<Array.<number>> | Array.<Parse.GeoPoint>

An Array of coordinate pairs

Members

coordinates

Coordinates value for this Polygon. Throws an exception if not valid type.

Properties:
Name Type Description
coordinates Array.<Array.<number>> | Array.<Parse.GeoPoint>

list of coordinates

Methods

(static) _validate(coords) → {Array.<Array.<number>>}

Validates that the list of coordinates can form a valid polygon

Parameters:
Name Type Description
coords Array

the list of coordinates to validate as a polygon

Throws:
TypeError
Returns:
Type:
Array.<Array.<number>>

Array of coordinates if validated.

containsPoint(point) → {boolean}

Parameters:
Name Type Description
point Parse.GeoPoint
Returns:
Type:
boolean

Returns if the point is contained in the polygon

equals(other) → {boolean}

Checks if two polygons are equal

Parameters:
Name Type Description
other Parse.Polygon | object
Returns:
Type:
boolean

toJSON() → {object}

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

Returns:
Type:
object