ComponentOne Maps for WinForms
Working with Map Control / Adding Vector Data / Adding a Polygon
In This Topic
    Adding a Polygon
    In This Topic

    C1Map allows you to add a polygon on the top of a map using VetorPolygon class. The VectorPolygon class accepts a list of GeoPoints that define the location and shape of the polygon. The following code shows how to create a polygon on a map surface:

    C1Map1.TileLayer.TileSource = New VirtualEarthAerialSource()
    
    Dim vl = New C1.Win.Map.VectorLayer()
    C1Map1.Layers.Add(vl)
    
    ' Can add the polygon vector (C1.Win.Map.VectorPolygon) into a vector layer.
    Dim polygon = New C1.Win.Map.VectorPolygon()
    vl.Items.Add(polygon)
    
    ' Customize the polygon
    polygon.Style.BackColor = Color.Beige
    
    ' Provide the geopoint location for the polygon
    polygon.Geometry = New GeoPolygon(New GeoLinearRing() _
    {New GeoLinearRing(New GeoPoint() {New GeoPoint(-10, -10),
    New GeoPoint(-10, 10), New GeoPoint(10, 10), New GeoPoint(10, -10)})})
    
    c1Map1.TileLayer.TileSource = new VirtualEarthAerialSource();
    
    var vl = new C1.Win.Map.VectorLayer();
    c1Map1.Layers.Add(vl);
    
    // Can add the polygon vector (C1.Win.Map.VectorPolygon) into a vector layer.
    var polygon = new C1.Win.Map.VectorPolygon();
    vl.Items.Add(polygon);
    
    // Customize the polygon
    polygon.Style.BackColor = Color.Beige;
    
    // Provide the geopoint location for the polygon
    polygon.Geometry = new GeoPolygon(new GeoLinearRing[]
    {
        new GeoLinearRing(new GeoPoint[]
        {
            new GeoPoint(-10,-10),
            new GeoPoint(-10,10),
            new GeoPoint(10,10),
            new GeoPoint(10,-10),
        }),
    });
    

    The following image depicts Map control with four geographical coordinates connected by a polygon:

     maps with polygon