You can connect geographic coordinates with a polygon by adding a C1VectorPolygon to the C1VectorLayer (see Vector Layer for more information). In this topic, you create a 3-point polygon.
Point | X | Y |
0 | -80.15 | 42.12 |
1 | -123.08 | 39.09 |
2 | -3.90 | 30.85 |
To know how to manipulate element visibility according to the scaling of the map, please see the Element Visibility section in the topic Vector Layer.
Add the following markup between the <c1:C1Maps> </c1:C1Maps> tags, to add a polygon over the maps control:
Source View |
Copy Code
|
---|---|
<Layers> <c1:C1VectorLayer> <DataWijJson> <Vectors> <c1:C1VectorPolygon Fill="Snow" Stroke="Yellow" StrokeWidth="2"> <Points> <c1:PointD X="-80.15" Y="42.12" /> <c1:PointD X="-123.08" Y="39.09" /> <c1:PointD X="-3.9" Y="30.85" /> </Points> </c1:C1VectorPolygon> </Vectors> </DataWijJson> </c1:C1VectorLayer> </Layers> |
C# |
Copy Code
|
---|---|
// Create a layer and add it to the map C1VectorLayer vl = new C1VectorLayer(); C1Maps1.Layers.Add(vl); // Set the datasource Type vl.DataType = DataType.WijJson; //Create a vector polygon and add it to the layer C1VectorPolygon vpl = new C1VectorPolygon(); vl.DataWijJson.Vectors.Add(vpl); // Add points to the vector polygon vpl.Points.Add(new PointD(-80.15, 42.12)); vpl.Points.Add(new PointD(-123.08, 39.09)); vpl.Points.Add(new PointD(-3.90, 30.85)); // set the fill, stroke color and stroke width vpl.Fill = System.Drawing.Color.Snow; vpl.Stroke = System.Drawing.Color.Yellow; vpl.StrokeWidth = 2; |
VB |
Copy Code
|
---|---|
' Create a layer and add it to the map Dim vl As New C1VectorLayer() C1Maps1.Layers.Add(vl) ' Set the datasource Type vl.DataType = DataType.WijJson 'Create a vector polygon and add it to the layer Dim vpl As New C1VectorPolygon() vl.DataWijJson.Vectors.Add(vpl) ' Add points to the vector polygon vpl.Points.Add(New PointD(-80.15, 42.12)) vpl.Points.Add(New PointD(-123.08, 39.09)) vpl.Points.Add(New PointD(-3.9, 30.85)) ' set the fill, stroke color and stroke width vpl.Fill = System.Drawing.Color.Snow vpl.Stroke = System.Drawing.Color.Yellow vpl.StrokeWidth = 2 |
The following image depicts a C1Maps control with three geographical coordinates connected by a polygon.