ColorLegendItem Class
An item that stores information about the color and description of the ColorLegendBase class descendants.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v18.1.dll
Declaration
Example
To use images in a legend, do the following.
- Assign the image storage to the ColorListLegend.ImageList property.
- Add several ColorLegendItem objects with the specified ColorLegendItem.ImageIndex property to the ColorListLegend.CustomItems collection.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/xtramap-getting-started-lesson-3-binding-a-map-control-to-data-loaded-from-xml-e4687
object data = LoadData(xmlFilepath);
// Create a map and data for it.
MapControl map = new MapControl() {
CenterPoint = new GeoPoint(-37.2, 143.2),
ZoomLevel = 5,
Dock = DockStyle.Fill,
ToolTipController = new ToolTipController() { AllowHtmlText = true },
ImageList = LoadImage(imageFilepath)
};
this.Controls.Add(map);
//Create a Legend containing images.
ColorListLegend legend = new ColorListLegend();
legend.ImageList = map.ImageList;
legend.CustomItems.Add(new ColorLegendItem() { ImageIndex = 0, Text = "Shipwreck" });
map.Legends.Add(legend);
// Loads an image to an image collection.
private ImageCollection LoadImage(string path) {
ImageCollection imageCollection = new ImageCollection();
Bitmap image = new Bitmap(path);
imageCollection.ImageSize = new Size(50, 50);
imageCollection.Images.Add(image);
return imageCollection;
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ColorLegendItem class.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.