ESRI.ArcGIS.ADF.IMS
Polygon Class
Members  Example  See Also 
ESRI.ArcGIS.ADF.IMS.Geometry Namespace : Polygon Class




Represents a grouping of Rings.

Object Model



Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class Polygon 
   Inherits Geometry
Visual Basic (Usage)Copy Code
Dim instance As Polygon
C# 
[SerializableAttribute()]
public class Polygon : Geometry 

Example

This example creates a polygon on an acetate layer. It adds a single ring to the polygon, and adds a hole inside the ring. The code assumes an existing MapView object.
C#Copy Code
// Create a new polygon 

ESRI.ArcGIS.ADF.IMS.Geometry.Polygon poly = 

    new ESRI.ArcGIS.ADF.IMS.Geometry.Polygon(); 

ESRI.ArcGIS.ADF.IMS.Geometry.Ring ring =  

    new ESRI.ArcGIS.ADF.IMS.Geometry.Ring(); 

poly.Rings.Add(ring); 

  

// Create a ring for the polygon 

ESRI.ArcGIS.ADF.IMS.Geometry.Point pt; 

pt = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(10, 10); 

ring.Points.Add(pt); 

pt = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(10, 30); 

ring.Points.Add(pt); 

pt = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(30, 25); 

ring.Points.Add(pt); 

pt = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(28, 12); 

ring.Points.Add(pt); 

  

// Add a hole to the ring 

ESRI.ArcGIS.ADF.IMS.Geometry.Hole polyHole =  

    new ESRI.ArcGIS.ADF.IMS.Geometry.Hole(); 

pt = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(12, 12); 

polyHole.Points.Add(pt); 

pt = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(12, 28); 

polyHole.Points.Add(pt); 

pt = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(20, 25); 

polyHole.Points.Add(pt); 

pt = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(22, 13); 

polyHole.Points.Add(pt); 

ring.Holes.Add(polyHole); 

  

// Create an acetate geometry element and add the polygon to it 

ESRI.ArcGIS.ADF.IMS.Display.Symbol.SimpleFillSymbol polySymbol = 

new ESRI.ArcGIS.ADF.IMS.Display.Symbol.SimpleFillSymbol(); 

polySymbol.Color = System.Drawing.Color.Red; 

ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.GeometryElement acetatePoly = 

new ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.GeometryElement( 

ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.AcetateUnits.Database, poly, polySymbol); 

  

// Create an acetate layer for the geometry element, and add it to the map 

ESRI.ArcGIS.ADF.IMS.Carto.Layer.AcetateLayer acetateLayer =  

    new ESRI.ArcGIS.ADF.IMS.Carto.Layer.AcetateLayer("mapGraphics"); 

acetateLayer.AcetateElements.Add(acetatePoly); 

mapView.Layers.Add(acetateLayer); 

    
Visual BasicCopy Code
' Create a new polygon

Dim poly As New ESRI.ArcGIS.ADF.IMS.Geometry.Polygon()

Dim ring As New ESRI.ArcGIS.ADF.IMS.Geometry.Ring()

poly.Rings.Add(ring)



' Create a ring for the polygon

Dim pt As ESRI.ArcGIS.ADF.IMS.Geometry.Point pt

pt = New ESRI.ArcGIS.ADF.IMS.Geometry.Point(10, 10)

ring.Points.Add(pt)

pt = New ESRI.ArcGIS.ADF.IMS.Geometry.Point(10, 30)

ring.Points.Add(pt)

pt = New ESRI.ArcGIS.ADF.IMS.Geometry.Point(30, 25)

ring.Points.Add(pt)

pt = New ESRI.ArcGIS.ADF.IMS.Geometry.Point(28, 12)

ring.Points.Add(pt)



' Add a hole to the ring

Dim polyHole As New ESRI.ArcGIS.ADF.IMS.Geometry.Hole()

pt = New ESRI.ArcGIS.ADF.IMS.Geometry.Point(12, 12)

polyHole.Points.Add(pt)

pt = New ESRI.ArcGIS.ADF.IMS.Geometry.Point(12, 28)

polyHole.Points.Add(pt)

pt = New ESRI.ArcGIS.ADF.IMS.Geometry.Point(20, 25)

polyHole.Points.Add(pt)

pt = New ESRI.ArcGIS.ADF.IMS.Geometry.Point(22, 13)

polyHole.Points.Add(pt)

ring.Holes.Add(polyHole)



' Create an acetate geometry element and add the polygon to it

Dim polySymbol As New _

    ESRI.ArcGIS.ADF.IMS.Display.Symbol.SimpleFillSymbol()

polySymbol.Color = System.Drawing.Color.Red

Dim acetatePoly As New _

    ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.GeometryElement( _

    ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.AcetateUnits.Database, _

    poly, polySymbol)



' Create an acetate layer for the geometry element, and add it to the map

Dim acetateLayer As New _

    ESRI.ArcGIS.ADF.IMS.Carto.Layer.AcetateLayer("mapGraphics")

acetateLayer.AcetateElements.Add(acetatePoly)

mapView.Layers.Add(acetateLayer)

Remarks

A Polygon is a type of geometry, and may be used to add graphics to the map, in a filter to select features in a layer, and may be returned as the geometry of features when performing a query. For details, see Geometry.

A Polygon consists of one or more Ring objects. For example, a chain of islands (e.g., Hawaii) may be represented by a single polgyon object with several rings, one ring per island.

A ring in a polygon may have one or more Hole items, which are gaps inside the ring.

The points in the rings and holes of the polygon must occur in the order they will be drawn. A polygon must be closed - the beginning and ending points must be identical. If the last point is not identical to the first, the first point will be duplicated as the last point in the request to the server (though the last point will not be added to the ring's Points collection).

Inheritance Hierarchy

System.Object
   ESRI.ArcGIS.ADF.IMS.Geometry.Geometry
      ESRI.ArcGIS.ADF.IMS.Geometry.Polygon

See Also

© 2010 All Rights Reserved.