Back to Devexpress

DataSourceAdapterBase.PropertyMappings Property

windowsforms-devexpress-dot-xtramap-dot-datasourceadapterbase-5ce61ef8.md

latest4.6 KB
Original Source

DataSourceAdapterBase.PropertyMappings Property

Returns a collection of map item property mappings.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public MapItemPropertyMappingCollection PropertyMappings { get; }
vb
Public ReadOnly Property PropertyMappings As MapItemPropertyMappingCollection

Property Value

TypeDescription
MapItemPropertyMappingCollection

A MapItemPropertyMappingCollection object that stores MapItemPropertyMappingBase class descendant objects.

|

Remarks

The following example uses PropertyMappings to add additional properties (Width and Height) to map items:

csharp
class StateRect {
    // The latitude of the top-left angle of a rectangle.
    public double Top { get; set; }
    // The longitude of the top-left angle of a rectangle.
    public double Left { get; set; }
    // The width in kilometers of a rectangle.
    public double Width { get; set; }
    // The height in kilometers of a rectangle.
    public double Height { get; set; }
}

// Create a data source.
List<StateRect> dataSource = new List<StateRect> {
    new StateRect { Top = 44.996250, Left = -111.049638, Width = 496, Height = 444 },
    new StateRect { Top = 48.990004, Left = -104.042967, Width = 480, Height = 338 },
    new StateRect { Top = 45.944326, Left = -104.042967, Width = 528, Height = 338 },
    new StateRect { Top = 41.000038, Left = -109.049518, Width = 528, Height = 445 }
};

private void Form1_Load(object sender, EventArgs e) {
    // Create a data source for the vector layer.
    var dataAdapter = new ListSourceDataAdapter();
    dataAdapter.DataSource = dataSource;
    dataAdapter.DefaultMapItemType = MapItemType.Rectangle;
    // Specify the obligatory mappings.
    dataAdapter.Mappings.Latitude = "Top";
    dataAdapter.Mappings.Longitude = "Left";
    // Add rectangle-specific property mappings.
    dataAdapter.PropertyMappings.AddRange(new MapItemPropertyMappingBase[] {
        new MapRectangleWidthMapping { Member = "Width", DefaultValue = 0 },
        new MapRectangleHeightMapping { Member = "Height", DefaultValue = 0 }
    });
    VectorLayer.Data = dataAdapter;
}
vb
Private Class StateRect
    ' The latitude of the top-left angle of a rectangle.
    Public Property Top() As Double
    ' The longitude of the top-left angle of a rectangle.
    Public Property Left() As Double
    ' The width in kilometers of a rectangle.
    Public Property Width() As Double
    ' The height in kilometers of a rectangle.
    Public Property Height() As Double
End Class

' Create a data source.
Private dataSource As New List(Of StateRect)() From { _
    New StateRect With {.Top = 44.996250, .Left = -111.049638, .Width = 496, .Height = 444}, _
    New StateRect With {.Top = 48.990004, .Left = -104.042967, .Width = 480, .Height = 338}, _
    New StateRect With {.Top = 45.944326, .Left = -104.042967, .Width = 528, .Height = 338}, _
    New StateRect With {.Top = 41.000038, .Left = -109.049518, .Width = 528, .Height = 445} _
}

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    ' Create a data source for the vector layer.
    Dim dataAdapter = New ListSourceDataAdapter()
    dataAdapter.DataSource = dataSource
    dataAdapter.DefaultMapItemType = MapItemType.Rectangle
    ' Specify the obligatory mappings.
    dataAdapter.Mappings.Latitude = "Top"
    dataAdapter.Mappings.Longitude = "Left"
    ' Add rectangle-specific property mappings.
    dataAdapter.PropertyMappings.AddRange(New MapItemPropertyMappingBase() { _
        New MapRectangleWidthMapping With {.Member = "Width", .DefaultValue = 0}, _
        New MapRectangleHeightMapping With {.Member = "Height", .DefaultValue = 0} _
    })
    VectorLayer.Data = dataAdapter
End Sub

See Also

DataSourceAdapterBase Class

DataSourceAdapterBase Members

DevExpress.XtraMap Namespace