How to: Show Additional Information Over the Map
- 2 minutes to read
To show additional information over the map, do the following.
- Create and customize a MapOverlay object. For example, specify its MapOverlay.Margin and MapOverlay.Padding.
- Then, add a MapOverlayItemBase class descendant object to the MapOverlay.Items collection and configure it. For instance, specify the displayed image of MapOverlayImageItem using the MapOverlayImageItem.ImageUri, MapOverlayImageItem.Image or MapOverlayImageItem.ImageIndex property; or a text of MapOverlayTextItem using the MapOverlayTextItem.Text property.
- Finally, add the overlay to the MapControl.Overlays collection.
Note
To learn more about overlays and overlay items, refer to the Map Overlay and Map Overlay Items topics.
using DevExpress.XtraMap;
using System;
using System.Drawing;
using System.Windows.Forms;
//...
private void Form1_Load(object sender, EventArgs e) {
MapOverlay overlayWithText = new MapOverlay {
Alignment = ContentAlignment.BottomRight,
JoiningOrientation = Orientation.Vertical,
Margin = new Padding(0, 4, 8, 8),
Padding = new Padding(7)
};
overlayWithText.Items.Add(new MapOverlayTextItem {
Text = "Copyright © 2015. Microsoft and its suppliers. All rights reserved."
});
map.Overlays.Add(overlayWithText);
Uri baseUri = new Uri(System.Reflection.Assembly.GetEntryAssembly().Location);
MapOverlay overlayWithImage = new MapOverlay {
Alignment = ContentAlignment.BottomRight,
JoiningOrientation = Orientation.Vertical,
Margin = new Padding(0, 0, 8, 4),
Padding = new Padding(0),
};
overlayWithImage.Items.Add(new MapOverlayImageItem { ImageUri = new Uri(baseUri, "..\\..\\Images\\BingLogo.png") });
map.Overlays.Add(overlayWithImage);
}