Polygon Class
Polygon Class
Defines a polygon data type to be rendered on a map. An array of Polygon objects is used by the MapSpecification.Polygons property.
Public Class Polygon Inherits System.Object
[C#]
public class Polygon : System.Object
Public Constructors
Name | Description |
---|---|
Polygon Constructor | Initializes a new instance of the Polygon class. |
Public Properties
Name | Description |
---|---|
DataSourceName | A string representing the name of the data source (DataSource.Name property) that contains the polygon. |
EntityID | An integer representing the entity ID for the polygon. |
BorderColor | An ElementColor object defining the color and level of transparency that is used when drawing the outside border of the polygon. |
FillColor | An ElementColor object defining the color and level of transparency that is used when shading the polygon. |
Label | The text to display when rendering the polygon. |
Example
[Visual Basic]
'Create an array of Polygon objects. For each Polygon object,
'set the DataSourceName, EntityID, BorderColor, and FillColor properties.
Dim fillColor As New ElementColor
fillColor.A = Convert.ToByte(txtFillAlpha.Text)
fillColor.B = Convert.ToByte(txtFillBlue.Text)
fillColor.G = Convert.ToByte(txtFillGreen.Text)
fillColor.R = Convert.ToByte(txtFillRed.Text)
Dim lineColor As New ElementColor
lineColor.A = Convert.ToByte(txtLineAlpha.Text)
lineColor.B = Convert.ToByte(txtLineBlue.Text)
lineColor.G = Convert.ToByte(txtLineGreen.Text)
lineColor.R = Convert.ToByte(txtLineRed.Text)
Dim poly As New Polygon
poly.DataSourceName = "MyDataSource"
poly.EntityID = "MyEntityID"
poly.BorderColor = lineColor
poly.FillColor = fillColor
' Set the MapSpecification.Polygons property to the polygon array.
spec.Polygons(1) = New Polygon
spec.Polygons(0) = poly
'Call the RenderServiceSoap.GetMap method.
Dim mi() As New MapImage
mi = render.GetMap(spec)
pictMap.Image = New Bitmap(New System.IO.MemoryStream(mi(0).MimeData.Bits))
[C#]
//Display a polygon on a map
MapSpecification spec = new MapSpecification();
spec.DataSourceName = "MapPoint.NA";
spec.Views = views;
spec.Options = mo;
//Create an array of Polygon objects. For each Polygon object,
//set the DataSourceName, EntityID, BorderColor, and FillColor properties.
MapPointColor fillColor = new ElementColor();
fillColor.A=Convert.ToByte(txtFillAlpha.Text);
fillColor.B=Convert.ToByte(txtFillBlue.Text);
fillColor.G=Convert.ToByte(txtFillGreen.Text);
fillColor.R=Convert.ToByte(txtFillRed.Text);
MapPointColor lineColor = new ElementColor();
lineColor.A=Convert.ToByte(txtLineAlpha.Text);
lineColor.B=Convert.ToByte(txtLineBlue.Text);
lineColor.G=Convert.ToByte(txtLineGreen.Text);
lineColor.R=Convert.ToByte(txtLineRed.Text);
Polygon poly = new Polygon();
poly.DataSourceName = "MyDataSource";
poly.EntityID = "MyEntityID";
poly.BorderColor=lineColor;
poly.FillColor=fillColor;
// Set the MapSpecification.Polygons property to the polygon array.
spec.Polygons = new Polygon[1];
spec.Polygons[0] = poly;
//Call the RenderServiceSoap.GetMap method.
MapImage[] mi = render.GetMap(spec);
pictMap.Image = new Bitmap(new System.IO.MemoryStream(mi[0].MimeData.Bits));
See Also
MapSpecification.Polygons property | Working with Polygons