ShowLabels

Labels are a textual representation on the map that usually convey information about ancillary attribute data that correspond to the vector shape. In the example below, a very simple label setup is used, where the labels are always visible, and whatever value appears in the first column of the data table for that featureset will be used to generate the label. Notice that the name is encapsulated in square brackets. The LabelSymbolizer contains lots of different properties that affect the appearance of all the labels, but the text of the labels in this case will be supplied by the attributes.

labels.png

private void AddLabels()
{
    IFeatureLayer fl = geoMap1.AddFeatureLayer();
    string expression = "[" + fl.DataSet.DataTable.Columns[0].ColumnName + "]";
    LabelSymbolizer ls = new LabelSymbolizer();
    ls.Orientation = ContentAlignment.MiddleCenter;
    geoMap1.AddLabels(fl, expression, "", ls);
}

Last edited Feb 27, 2010 at 1:38 AM by Shade1974, version 3

Comments

No comments yet.