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

    C1Map allows you to add custom elements like text label on the map surface. Label can be added on a map using placemarks. You can use the following code to add a label to a geographic point using VectorLayer and VectorPlacemark:

    C1Map1.TileLayer.TileSource = New VirtualEarthAerialSource()
    
    Dim vl = New C1.Win.Map.VectorLayer()
    C1Map1.Layers.Add(vl)
    
    Dim pm = New C1.Win.Map.VectorPlacemark()
    pm.Geometry = New GeoPoint(78, 28)
    vl.Items.Add(pm)
    
    vl.LabelVisibility = LabelVisibility.Visible
    pm.Marker.Caption = "INDIA"
    pm.LabelStyle.ForeColor = Color.Yellow
    
    c1Map1.TileLayer.TileSource = new VirtualEarthAerialSource();
    
    var vl = new C1.Win.Map.VectorLayer();
    c1Map1.Layers.Add(vl);
    
    var pm = new C1.Win.Map.VectorPlacemark();
    pm.Geometry = new GeoPoint(78,28);
    vl.Items.Add(pm);
    
    vl.LabelVisibility = LabelVisibility.Visible;
    pm.Marker.Caption = "INDIA";
    pm.LabelStyle.ForeColor = Color.Yellow;
    

    The above code adds a label to the map, gives a caption to it, and sets the font color for the label caption.

    The image given below shows Map control with a label added on a geographic point – the geographic coordinates of India.

     map with labels

    C1Map also allows you to customize the label added on a map. You can use the following properties to make further customizations to the label and marker:

    Here is a list of Marker Properties.

    Properties Description
    Shape Used to set the shape for a marker.
    CustomShape Specifies a custom shape for the marker.
    LabelPosition Specifies the label position relatively to the marker.
    Size Specifies the size of marker shape.

    You can also use other properties to set the style for Label using LabelStyle property of VectorPlacemark class. With this property, you can change the background color of label, width, and round radius of the label borders.