Skip to main content

Legends

  • 2 minutes to read

A Legend is a panel that shows information about value meanings of vector items. This may be information about either item colors or item sizes, depending on the item’s nature.

To add a legend to the Map control, it is necessary to create an appropriate MapLegendBase class descendant (either a color-based or size-based legend) and add it to the MapControl.Legends collection.

Then, it is required to specify a layer which contains vector items to be annotated by this legend. To do this, assign this layer object to the ItemsLayerLegend.Layer property.

Below you will find the more detailed information about various types of legends supported by the Map control.

Color-Based Legend

A Color-Based Legend is intended to detail the meaning of specific colors. In this case, a layer specified by a legend’s ItemsLayerLegend.Layer property should contain vector items colorized by one of the following colorizers:

There are two types of color-based legends.

The main properties that affect element appearance and functionality are listed below.

Group Properties
Availability MapControl.Legends
Layout HorizontalAlignment, VerticalAlignment
Elements ItemsLayerLegend.Layer, ColorLegend.CustomItems
Appearance MapLegendBase.Header, MapLegendBase.Description, ColorLegend.ItemTemplate, MapLegendBase.ItemLabelTemplate, ColorScaleLegend.EnableGradientScale, Background, Foreground, BorderBrush

For more information on using these legends, see the following examples:

Size-Based Legend

A Size-Based Legend details the meaning of various sizes in MapBubble or MapPie charts.

This legend type is represented by the SizeLegend class. The appearance of the size-based legend is defined by its SizeLegend.Type property value.

SizeLegend.Type = Inline

SizeLegendExample

SizeLegend.Type = Nested

SizeLegendNestedExample

The main properties that affect element appearance and functionality are listed below.

Group

Properties

Availability

MapControl.Legends

Layout

HorizontalAlignment, VerticalAlignment

Elements

ItemsLayerLegend.Layer, SizeLegend.CustomItems

Appearance

MapLegendBase.Header, MapLegendBase.Description, MapLegendBase.ItemLabelTemplate, Background, BorderBrush, Foreground, SizeLegend.Type, SizeLegend.ShowTickMarks

To learn how to create a SizeLegend object, refer to Lesson 3 - Add Analytical Data to a Geographical Map.