windowsforms-devexpress-dot-xtramap-dot-mapitemmappinginfo.md
Gets or sets the data field to which a GeoPoint.Latitude property is bound.
Namespace : DevExpress.XtraMap
Assembly : DevExpress.XtraMap.v25.2.dll
NuGet Package : DevExpress.Win.Map
[DefaultValue("")]
public string Latitude { get; set; }
<DefaultValue("")>
Public Property Latitude As String
| Type | Default | Description |
|---|---|---|
| String | String.Empty |
A string value that specifies the name of the bound data field.
|
This example binds a Map control to data. This data is stored in an external XML file that contains information about wrecked ships, including ship coordinates.
In this example, the map control generates ship images based on data from the data source, along with a description for each image in a tooltip.
Follow the steps below to create a map as on the image above:
MapItemMappingInfo.Latitude and MapItemMappingInfo.Longitude properties of the object, returned by the ListSourceDataAdapter.Mappings property.Also, this sample illustrates how to customize tooltips using the MapItemsLayerBase.ToolTipPattern property.
Note
For more information on how to add images on the map, refer to the following help topic: Generate Vector Items Automatically.
// In the Form's constructor.
object data = LoadData(@"..\..\Data\Ships.xml");
// Create a vector layer.
map.Layers.Add(new VectorItemsLayer() {
Data = CreateAdapter(data),
ToolTipPattern = "<b>{Name} ({Year})</b> \r\n{Description}",
ItemImageIndex = 0
});
// Creates an adapter for the map's vector layer.
private IMapDataAdapter CreateAdapter(object source) {
ListSourceDataAdapter adapter = new ListSourceDataAdapter();
adapter.DataSource = source;
adapter.Mappings.Latitude = "Latitude";
adapter.Mappings.Longitude = "Longitude";
adapter.AttributeMappings.Add(new MapItemAttributeMapping() { Member = "Name", Name = "Name" });
adapter.AttributeMappings.Add(new MapItemAttributeMapping() { Member = "Year", Name = "Year" });
adapter.AttributeMappings.Add(new MapItemAttributeMapping() { Member = "Description", Name = "Description" });
return adapter;
}
// Loads data from a XML file.
private List<ShipwreckData> LoadData(string path) {
return XDocument.Load(path).Element("Ships").Elements("Ship")
.Select(e => new ShipwreckData(
year: Convert.ToInt32(e.Element("Year").Value, CultureInfo.InvariantCulture),
name: e.Element("Name").Value,
description: e.Element("Description").Value,
latitude: Convert.ToDouble(e.Element("Latitude").Value, CultureInfo.InvariantCulture),
longitude: Convert.ToDouble(e.Element("Longitude").Value, CultureInfo.InvariantCulture)
))
.ToList();
}
public class ShipwreckData {
public int Year { get; }
public string Name { get; }
public string Description { get; }
public double Latitude { get; }
public double Longitude { get; }
public ShipwreckData(int year, string name, string description, double latitude, double longitude) {
this.Year = year;
this.Name = name;
this.Description = description;
this.Latitude = latitude;
this.Longitude = longitude;
}
}
' In the Form's constructor.
Dim data As Object = LoadData("..\..\Data\Ships.xml")
' Create a vector layer.
map.Layers.Add(New VectorItemsLayer() With { _
.Data = CreateAdapter(data), _
.ToolTipPattern = "<b>{Name} ({Year})</b> " & ControlChars.CrLf & "{Description}", _
.ItemImageIndex = 0 _
})
' Creates an adapter for the map's vector layer.
Private Function CreateAdapter(ByVal source As Object) As IMapDataAdapter
Dim adapter As New ListSourceDataAdapter()
adapter.DataSource = source
adapter.Mappings.Latitude = "Latitude"
adapter.Mappings.Longitude = "Longitude"
adapter.AttributeMappings.Add(New MapItemAttributeMapping() With {.Member = "Name", .Name = "Name"})
adapter.AttributeMappings.Add(New MapItemAttributeMapping() With {.Member = "Year", .Name = "Year"})
adapter.AttributeMappings.Add(New MapItemAttributeMapping() With {.Member = "Description", .Name = "Description"})
Return adapter
End Function
' Loads data from a XML file.
Private Function LoadData(ByVal path As String) As List(Of ShipwreckData)
Return XDocument.Load(path).Element("Ships").Elements("Ship") _
.Select(Function(e) New ShipwreckData(
year:=Convert.ToInt32(e.Element("Year").Value, CultureInfo.InvariantCulture),
name:=e.Element("Name").Value,
description:=e.Element("Description").Value,
latitude:=Convert.ToDouble(e.Element("Latitude").Value, CultureInfo.InvariantCulture),
longitude:=Convert.ToDouble(e.Element("Longitude").Value, CultureInfo.InvariantCulture)
)) _
.ToList()
End Function
Public Class ShipwreckData
Public ReadOnly Property Year() As Integer
Public ReadOnly Property Name() As String
Public ReadOnly Property Description() As String
Public ReadOnly Property Latitude() As Double
Public ReadOnly Property Longitude() As Double
Public Sub New(ByVal year As Integer, ByVal name As String, ByVal description As String, ByVal latitude As Double, ByVal longitude As Double)
Me.Year = year
Me.Name = name
Me.Description = description
Me.Latitude = latitude
Me.Longitude = longitude
End Sub
End Class
The following code snippets (auto-collected from DevExpress Examples) contain references to the Latitude 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-customize-mini-map-layers/CS/MiniMapLayers/Form1.cs#L95
adapter.DataSource = data;
adapter.Mappings.Latitude = "Latitude";
adapter.Mappings.Longitude = "Longitude";
winforms-map-bind-to-xml-data/CS/WinForms_MapControl_ListAdapter/Form1.cs#L54
adapter.Mappings.Latitude = "Latitude";
adapter.Mappings.Longitude = "Longitude";
winforms-map-customize-mini-map-layers/VB/MiniMapLayers/Form1.vb#L71
adapter.DataSource = data
adapter.Mappings.Latitude = "Latitude"
adapter.Mappings.Longitude = "Longitude"
winforms-map-bind-to-xml-data/VB/WinForms_MapControl_ListAdapter/Form1.vb#L40
adapter.DataSource = source
adapter.Mappings.Latitude = "Latitude"
adapter.Mappings.Longitude = "Longitude"
See Also