MapItem.Tag Property
Gets or sets the object that contains data related to a map item.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v24.2.dll
NuGet Package: DevExpress.Win.Map
#Declaration
#Property Value
Type | Default | Description |
---|---|---|
Object | null | A Object that contains information about the map item. |
#Remarks
Any type derived from the Object class can be assigned to this property. Use it to store data associated with a map item.
#Example
The following example adds two pushpins to a map item storage. Each pushpin’s Tag property is initialized with an object of the ItemInfo type. The storage’s DataChanged event handler defines pushpins’ visibility based on the ItemInfo.IsOpened property value.
VectorItemsLayer vectorLayer;
//...
private void Form1_Load(object sender, EventArgs e) {
vectorLayer = new VectorItemsLayer();
mapControl1.Layers.Add(vectorLayer);
MapItemStorage storage = new MapItemStorage();
vectorLayer.Data = storage;
storage.DataChanged += Storage_DataChanged;
MapPushpin pushpin1 = new MapPushpin();
pushpin1.Location = new GeoPoint(48.862644, 2.336578);
pushpin1.Tag = new ItemInfo { IsOpened = true };
storage.Items.Add(pushpin1);
MapPushpin pushpin2 = new MapPushpin();
pushpin2.Location = new GeoPoint(59.9398, 30.3146);
pushpin2.Tag = new ItemInfo { IsOpened = false };
storage.Items.Add(pushpin2);
}
private void Storage_DataChanged(object sender, DataAdapterChangedEventArgs e) {
foreach (MapItem item in vectorLayer.Data.Items) {
ItemInfo info = item.Tag as ItemInfo;
item.Visible = info.IsOpened;
}
}
public class ItemInfo {
public bool IsOpened { get; set; }
}
#Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Tag property.
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.