Polygon

Parse. Polygon

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 Polygon(coordinates)

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

An Array of coordinate pairs

Members

coordinates :Array

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

Properties:
Name Type Description
coordinates
Type:
  • Array

Methods

(static) _validate(coords)

Validates that the list of coordinates can form a valid polygon

Parameters:
Name Type Description
coords Array

the list of coordinated to validate as a polygon

Throws:
TypeError

containsPoint(point) → {Boolean}

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

wether the points is contained into 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 GeoPoint, suitable for Parse.

Returns:
Type:
Object