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

    C1Map allows you to connect geographic coordinates of a map with a polyline by using VectorPolyline class. The VectorPolyline class accepts a list of GeoPoints to define the location and nodes of a polyline on a map. The following code can be used to add a polyline on the map surface and customize it:

    C1Map1.TileLayer.TileSource = New VirtualEarthAerialSource()
    
    Dim vl = New C1.Win.Map.VectorLayer()
    C1Map1.Layers.Add(vl)
    
    Dim pline = New C1.Win.Map.VectorPolyline()
    vl.Items.Add(pline)
    
    'Provide the stroke style to the polyline
    pline.Style.Stroke.Width = 2
    pline.Style.Stroke.Style = DashStyle.Dot
    pline.Style.Stroke.Color = Color.Beige
    
    'Provide the geometry fro polyline
    pline.Geometry = New GeoMultiLineString(New GeoLineString() _
    {New GeoLineString(New GeoPoint() {New GeoPoint(20, -20),
    New GeoPoint(-20, 20)}), New GeoLineString(New GeoPoint() _
    {New GeoPoint(-20, -20), New GeoPoint(20, 20)})})
    
    c1Map1.TileLayer.TileSource = new VirtualEarthAerialSource();
    
    var vl = new C1.Win.Map.VectorLayer();
    c1Map1.Layers.Add(vl);
    
    var pline = new C1.Win.Map.VectorPolyline();
    vl.Items.Add(pline);
    
    //Provide the stroke style to the polyline
    pline.Style.Stroke.Width = 2;
    pline.Style.Stroke.Style = DashStyle.Dot;
    pline.Style.Stroke.Color = Color.Beige;
    
    //Provide the geometry fro polyline
    pline.Geometry = new GeoMultiLineString(
        new GeoLineString[]
        {
            new GeoLineString(new GeoPoint[]
            {
                new GeoPoint(20, -20),
                new GeoPoint(-20, 20),
            }),
            new GeoLineString(new GeoPoint[]
            {
                new GeoPoint(-20, -20),
                new GeoPoint(20, 20),
            })
        });
    

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

     map with polyline