A LabelSymbol used to label point, line, and polygon layers.
Object Model
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As TextSymbol |
Example
This example creates a new TextSymbol, and uses it in a new SimpleLabelRenderer to replace the labels for a city layer. As is typical with map layers, the layer has a GroupRenderer to display both layer symbols and labels, so the example replaces the label renderer with a new one.
Visual Basic | Copy Code |
---|
' Create a new text symbol and set its properties
Dim textSymb As New TextSymbol()
textSymb.Font = New FontInfo("Arial", 16, Drawing.Color.Red, FontStyle.Italic)
textSymb.Antialiasing = True
textSymb.GlowColor = Drawing.Color.Bisque
textSymb.Interval = 2
textSymb.ShadowColor = Drawing.Color.Gray
textSymb.TextCasing = TextCasing.TitleCaps
textSymb.Transparency = 30
' Retrieve an existing layer
Dim layer As FeatureLayer = mapView.Layers.FindByName("Cities")
' Create new label renderer
Dim labelRend As New SimpleLabelRenderer("NAME")
labelRend.Symbol = textSymb
' Replace the existing label renderer with the new one
' -- Layer has a symbol renderer as well as a label renderer, in a GroupRenderer
Dim groupRend As GroupRenderer = layer.Renderer
groupRend.Renderers.RemoveAt(1) ' label renderer is second renderer
groupRend.Renderers.Add(labelRend) |
C# | Copy Code |
---|
// Create a new text symbol and set its properties
TextSymbol textSymb = new TextSymbol();
textSymb.Font = new FontInfo("Arial", 16, Drawing.Color.Red, FontStyle.Italic);
textSymb.Antialiasing = true;
textSymb.GlowColor = Drawing.Color.Bisque;
textSymb.Interval = 2;
textSymb.ShadowColor = Drawing.Color.Gray;
textSymb.TextCasing = TextCasing.TitleCaps;
textSymb.Transparency = 30;
// Retrieve an existing layer
FeatureLayer layer = mapView.Layers.FindByName("Cities");
// Create new label renderer
SimpleLabelRenderer labelRend = new SimpleLabelRenderer("NAME");
labelRend.Symbol = textSymb;
// Replace the existing label renderer with the new one
// -- Layer has a symbol renderer as well as a label renderer, in a GroupRenderer
GroupRenderer groupRend = layer.Renderer;
groupRend.Renderers.RemoveAt(1); // label renderer is second renderer
groupRend.Renderers.Add(labelRend); |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also