ESRI.ArcGIS.ADF.IMS
Legend Class
Members  Example  See Also 
ESRI.ArcGIS.ADF.IMS.Carto Namespace : Legend Class




Contains properties and references for the map Legend.

Object Model


Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class Legend 
Visual Basic (Usage)Copy Code
Dim instance As Legend
C# 
[SerializableAttribute()]
public class Legend 

Example

The following example sets some properties of the legend, draws the legend, and sets an image control to use the legend image. The example assumes an existing MapView object.
C#Copy Code
// Create the legend and set its properties 

Legend mapLegend = mapView.Legend; 

mapLegend.Antialiasing = false; 

mapLegend.AutoSize = true; 

mapLegend.BackColor = System.Drawing.Color.Beige; 

mapLegend.CanSplit = true; 

mapLegend.CellSpacing = 5; 

mapLegend.ColumnCount = 3; 

mapLegend.FileName = "World_Legend"; 

mapLegend.FontName = "Verdana"; 

mapLegend.Height = 200; 

mapLegend.LayerFontSize = 10; 

mapLegend.ReverseOrder = true; 

mapLegend.SplitText = "continued..."; 

mapLegend.SwatchHeight = 10; 

mapLegend.SwatchWidth = 14; 

mapLegend.TitleFontSize = 14; 

mapLegend.TitleText = "Map Key"; 

mapLegend.TransparentColor = System.Drawing.Color.Beige; 

mapLegend.ValueFontSize = 8; 

mapLegend.Width = 300; 

  

// Draw the legend and display it in an image control 

CartoImage legendImage = mapLegend.Draw(); 

imgLegend.ImageUrl = legendImage.Url; 

    
Visual BasicCopy Code
' Create the legend and set its properties

Dim mapLegend As Legend = mapView.Legend

mapLegend.Antialiasing = False

mapLegend.AutoSize = True

mapLegend.BackColor = System.Drawing.Color.Beige

mapLegend.CanSplit = True

mapLegend.CellSpacing = 5

mapLegend.ColumnCount = 3

mapLegend.FileName = "World_Legend"

mapLegend.FontName = "Verdana"

mapLegend.Height = 200

mapLegend.LayerFontSize = 10

mapLegend.ReverseOrder = True

mapLegend.SplitText = "continued..."

mapLegend.SwatchHeight = 10

mapLegend.SwatchWidth = 14

mapLegend.TitleFontSize = 14

mapLegend.TitleText = "Map Key"

mapLegend.TransparentColor = System.Drawing.Color.Beige

mapLegend.ValueFontSize = 8

mapLegend.Width = 300



' Draw the legend and display it in an image control

Dim legendImage As CartoImage = mapLegend.Draw()

imgLegend.ImageUrl = legendImage.Url

Remarks

The map legend is a graphical image with layer names and swatches of symbols showing how map layers are displayed. Many properties of the legend can be set with this object, which are used when the legend is drawn.

The legend may be drawn with two approaches. First, the Draw method draws only the map legend. Second, the legend may be drawn at the same time as the map is drawn. This occurs if the MapView.RefreshLegend property is set to true. The legend then is drawn when the map is drawn with a Draw method, or another method which generates a map such as Pan or Zoom(double). Whether drawn explicitly or in conjunction with a map, the legend image can be retrieved by accessing the legend's Image property. The Url property of the Image will contain the URL of the legend image.

Inheritance Hierarchy

System.Object
   ESRI.ArcGIS.ADF.IMS.Carto.Legend

See Also

© 2010 All Rights Reserved.