windowsforms-devexpress-dot-xtramap-dot-vectoritemslayer.md
Specifies the data source for the vector items layer.
Namespace : DevExpress.XtraMap
Assembly : DevExpress.XtraMap.v25.2.dll
NuGet Package : DevExpress.Win.Map
[DefaultValue(null)]
public IMapDataAdapter Data { get; set; }
<DefaultValue(Nothing)>
Public Property Data As IMapDataAdapter
| Type | Default | Description |
|---|---|---|
| IMapDataAdapter | null |
An object implementing the IMapDataAdapter interface.
|
For more examples of the Data property in use, refer to the Providing Data Examples topic.
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:
VectorItemsLayer.Data 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
The following code snippets (auto-collected from DevExpress Examples) contain references to the Data 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.
winforms-map-create-choropleth-map-based-on-shapefile/CS/XtraMap_ShapefileDataAdapter/Form1.cs#L17
// Create data for the MapLayer.
MapLayer.Data = CreateData();
#endregion #DataProperty
winforms-map-customize-coordinate-systems-of-a-map/CS/CoordinateSystems/Form1.cs#L20
Adapter = new ShapefileDataAdapter();
vectorLayer.Data = Adapter;
vectorLayer.DataLoaded += DataLayer_DataLoaded;
winforms-map-load-data-from-a-kml-file/CS/WinForms_MapControl_KmlFileDataAdapter/Form1.cs#L17
Uri baseUri = new Uri(System.Reflection.Assembly.GetEntryAssembly().Location);
KmlLayer.Data = new KmlFileDataAdapter() {
FileUri = new Uri(baseUri, filePath)
winforms-map-show-callouts/CS/Form1.cs#L32
storage.Items.AddRange(capitals);
itemsLayer.Data = storage;
}
VectorItemsLayer items = new VectorItemsLayer();
items.Data = new MapItemStorage();
map.Layers.Add(items);
winforms-map-create-choropleth-map-based-on-shapefile/VB/XtraMap_ShapefileDataAdapter/Form1.vb#L23
' Create data for the MapLayer.
Me.MapLayer.Data = Me.CreateData()
'#End Region ' #DataProperty
winforms-map-customize-coordinate-systems-of-a-map/VB/CoordinateSystems/Form1.vb#L26
Adapter = New ShapefileDataAdapter()
vectorLayer.Data = Adapter
AddHandler vectorLayer.DataLoaded, AddressOf DataLayer_DataLoaded
winforms-map-load-data-from-a-kml-file/VB/WinForms_MapControl_KmlFileDataAdapter/Form1.vb#L23
Dim baseUri As Uri = New Uri(Reflection.Assembly.GetEntryAssembly().Location)
KmlLayer.Data = New KmlFileDataAdapter() With {.FileUri = New Uri(baseUri, filePath)}
'#End Region ' #KmlFileDataAdapter
winforms-map-show-callouts/VB/Form1.vb#L29
storage.Items.AddRange(capitals)
itemsLayer.Data = storage
End Sub
Dim items As VectorItemsLayer = New VectorItemsLayer()
items.Data = New MapItemStorage()
map.Layers.Add(items)
See Also