This page describes an older version, please see latest API at http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/geometry/Polygon.html.
Packagecom.esri.ags.geometry
Classpublic class Polygon
InheritancePolygon Inheritance Geometry Inheritance Object

An array of rings where each ring is an array of MapPoints. To make the polygon valid from an ArcGIS Server point of view, always make sure that the first and last point are in the same location. Polygons created with the DrawTool, or returned from ArcGIS Server will always be valid, i.e., have identical first and last point locations.

Default MXML Propertyrings

View the examples

See also

MapPoint


Public Properties
 PropertyDefined By
  extent : Extent
[override] [read-only] The extent of this polygon.
Polygon
  rings : Array
An array of rings where each ring is an array of two or more MapPoints.
Polygon
 InheritedspatialReference : SpatialReference
The spatial reference of the geometry.
Geometry
  type : String
[override] [read-only] The type of geometry is POLYGON.
Polygon
Public Methods
 MethodDefined By
  
Polygon(rings:Array = null, spatialReference:SpatialReference = null)
Creates a new Polygon object.
Polygon
  
addRing(points:Array):void
Adds a ring to the polygon.
Polygon
  
contains(point:MapPoint):Boolean
Checks if a point is contained in "this" polygon.
Polygon
  
getPoint(ringIndex:int, pointIndex:int):MapPoint
Returns a point specified by a ring and point in the path.
Polygon
  
insertPoint(ringIndex:int, pointIndex:int, point:MapPoint):void
Inserts a point into the polygon.
Polygon
  
removePoint(ringIndex:int, pointIndex:int):MapPoint
Removes a point from the polygon.
Polygon
  
removeRing(index:int):Array
Removes a ring from the polygon.
Polygon
  
setPoint(ringIndex:int, pointIndex:int, point:MapPoint):void
Sets(updates) an existing point in the polygon.
Polygon
Public Constants
 ConstantDefined By
 InheritedEXTENT : String = esriGeometryEnvelope
[static] An extent is defined by xmin, ymin, xmax and ymax.
Geometry
 InheritedMAPPOINT : String = esriGeometryPoint
[static] A MapPoint is a basic point with x (often longitude), y (often latitude) and an optional spatial reference.
Geometry
 InheritedMULTIPOINT : String = esriGeometryMultipoint
[static] A multipoint consists of one or more MapPoint(s).
Geometry
 InheritedPOLYGON : String = esriGeometryPolygon
[static] A polygon is a set of areas with three or more points.
Geometry
 InheritedPOLYLINE : String = esriGeometryPolyline
[static] A polyline is set of lines with two or more points.
Geometry
Property Detail
extentproperty
extent:Extent  [read-only] [override]

The extent of this polygon.


Implementation
    public function get extent():Extent
ringsproperty 
rings:Array

An array of rings where each ring is an array of two or more MapPoints.


Implementation
    public function get rings():Array
    public function set rings(value:Array):void
typeproperty 
type:String  [read-only] [override]

The type of geometry is POLYGON.


Implementation
    public function get type():String
Constructor Detail
Polygon()Constructor
public function Polygon(rings:Array = null, spatialReference:SpatialReference = null)

Creates a new Polygon object.

Parameters
rings:Array (default = null) — Array of rings (each of which is an array of MapPoints).
 
spatialReference:SpatialReference (default = null) — The spatial reference of the polygon.
Method Detail
addRing()method
public function addRing(points:Array):void

Adds a ring to the polygon. When added the index of the ring is incremented by one.

Parameters

points:Array — The array of MapPoints.

contains()method 
public function contains(point:MapPoint):Boolean

Checks if a point is contained in "this" polygon. A point on the polygon line is considered in.

Parameters

point:MapPoint — The location to check for.

Returns
Boolean — Returns true if the polygon contains the point, false otherwise.

Example
ActionScript to check if a point is inside the polygon:
     if( polygon.contains( MapPoint(graphic.geometry) ) ) 
getPoint()method 
public function getPoint(ringIndex:int, pointIndex:int):MapPoint

Returns a point specified by a ring and point in the path.

Parameters

ringIndex:int — The index of a ring.
 
pointIndex:int — The index of a point in a ring.

Returns
MapPoint
insertPoint()method 
public function insertPoint(ringIndex:int, pointIndex:int, point:MapPoint):void

Inserts a point into the polygon.

Parameters

ringIndex:int — The index of the ring to insert point.
 
pointIndex:int — The index of the inserted point.
 
point:MapPoint — The point to be inserted.

removePoint()method 
public function removePoint(ringIndex:int, pointIndex:int):MapPoint

Removes a point from the polygon.

Parameters

ringIndex:int — The index of the ring to remove point.
 
pointIndex:int — The index of the point to be removed.

Returns
MapPoint
removeRing()method 
public function removeRing(index:int):Array

Removes a ring from the polygon. The index specifies which ring to remove.

Parameters

index:int — The index of the ring to remove.

Returns
Array
setPoint()method 
public function setPoint(ringIndex:int, pointIndex:int, point:MapPoint):void

Sets(updates) an existing point in the polygon.

Parameters

ringIndex:int — The index of the ring to update point.
 
pointIndex:int — The index of the updated point.
 
point:MapPoint — The updated point.

Examples
MXML usage of Polygon:
 <esri:Graphic>
     <esri:Polygon spatialReference="{new SpatialReference(4326)}">
         <fx:Array>
             <fx:Array>
                 <esri:MapPoint x="13" y="55.59"/>
                 <esri:MapPoint x="18.42" y="-33.92"/>
                 <esri:MapPoint x="-43.23" y="-22.90"/>
                 <esri:MapPoint x="13" y="55.59"/>
             </fx:Array>
         </fx:Array>
     </esri:Polygon>
 </esri:Graphic>