windowsforms-devexpress-dot-xtramap-6870b4da.md
The base class for various map item types.
Namespace : DevExpress.XtraMap
Assembly : DevExpress.XtraMap.v25.2.dll
NuGet Package : DevExpress.Win.Map
public abstract class MapItem :
IOwnedElement,
IHitTestableElement,
IRenderItem,
IInteractiveElementProvider,
ISupportStyleKey,
IInteractiveElement,
IMapStyleOwner,
IMapItemCore,
IMapDataItem,
ISupportToolTip,
IMapItemAttributeOwner,
ILockableObject,
ITransformableItem,
IEditableItemCore,
IEditingBoundsSupport
Public MustInherit Class MapItem
Implements IOwnedElement,
IHitTestableElement,
IRenderItem,
IInteractiveElementProvider,
ISupportStyleKey,
IInteractiveElement,
IMapStyleOwner,
IMapItemCore,
IMapDataItem,
ISupportToolTip,
IMapItemAttributeOwner,
ILockableObject,
ITransformableItem,
IEditableItemCore,
IEditingBoundsSupport
The following members return MapItem objects:
The MapItem class implements the basic functionality common to all map items. For more information on map items, refer to Vector Items.
The following example demonstrates how to create an array of vector items and display them on a map.
To show vector items on a map, do the following:
MapItem class descendants (e.g., MapCallout) and add this array to the MapItemStorage.Items property.The code below illustrates how this can be done.
using System;
using System.Windows.Forms;
using DevExpress.XtraMap;
namespace AddItemsManually {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Create a map control with initial settings and add it to the form.
MapControl map = new MapControl()
{ Dock = DockStyle.Fill, ZoomLevel = 4, CenterPoint = new GeoPoint(43, 15) };
this.Controls.Add(map);
// Create a layer to load image tiles from OpenStreetMap.
ImageLayer tileLayer = new ImageLayer();
tileLayer.DataProvider = new OpenStreetMapDataProvider();
map.Layers.Add(tileLayer);
// Create a layer to display vector items.
VectorItemsLayer itemsLayer = new VectorItemsLayer();
map.Layers.Add(itemsLayer);
// Create a storage for map items and generate them.
MapItemStorage storage = new MapItemStorage();
MapItem[] capitals = GetCapitals();
storage.Items.AddRange(capitals);
itemsLayer.Data = storage;
}
// Create an array of callouts for 5 capital cities.
MapItem[] GetCapitals() {
return new MapItem[] {
new MapCallout() { Text = "London", Location = new GeoPoint(51.507222, -0.1275) },
new MapCallout() { Text = "Rome", Location = new GeoPoint(41.9, 12.5) },
new MapCallout() { Text = "Paris", Location = new GeoPoint(48.8567, 2.3508) },
new MapCallout() { Text = "Berlin", Location = new GeoPoint(52.52, 13.38) },
new MapCallout() { Text = "Madrid", Location = new GeoPoint(40.4, -3.68) }
};
}
}
}
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraMap
Namespace AddItemsManually
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
' Create a map control with initial settings and add it to the form.
Dim map As New MapControl() With {.Dock = DockStyle.Fill, .ZoomLevel = 4, .CenterPoint = New GeoPoint(43, 15)}
Me.Controls.Add(map)
' Create a layer to load image tiles from OpenStreetMap.
Dim tileLayer As New ImageLayer()
tileLayer.DataProvider = New OpenStreetMapDataProvider()
map.Layers.Add(tileLayer)
' Create a layer to display vector items.
Dim itemsLayer As New VectorItemsLayer()
map.Layers.Add(itemsLayer)
' Create a storage for map items and generate them.
Dim storage As New MapItemStorage()
Dim capitals() As MapItem = GetCapitals()
storage.Items.AddRange(capitals)
itemsLayer.Data = storage
End Sub
' Create an array of callouts for 5 capital cities.
Private Function GetCapitals() As MapItem()
Return New MapItem() { _
New MapCallout() With {.Text = "London", .Location = New GeoPoint(51.507222, -0.1275)}, _
New MapCallout() With {.Text = "Rome", .Location = New GeoPoint(41.9, 12.5)}, _
New MapCallout() With {.Text = "Paris", .Location = New GeoPoint(48.8567, 2.3508)}, _
New MapCallout() With {.Text = "Berlin", .Location = New GeoPoint(52.52, 13.38)}, _
New MapCallout() With {.Text = "Madrid", .Location = New GeoPoint(40.4, -3.68)} _
}
End Function
End Class
End Namespace
Show 19 items
Object MapItem MapPointer
See Also