Back to Devexpress

MapMultipointItemMappingInfo.Points Property

wpf-devexpress-dot-xpf-dot-map-dot-mapmultipointitemmappinginfo.md

latest7.7 KB
Original Source

MapMultipointItemMappingInfo.Points Property

Gets or sets the name of a data source member that contains polyline points.

Namespace : DevExpress.Xpf.Map

Assembly : DevExpress.Xpf.Map.v25.2.dll

NuGet Package : DevExpress.Wpf.Map

Declaration

csharp
public string Points { get; set; }
vb
Public Property Points As String

Property Value

TypeDescription
String

Data source member.

|

Example

How to: Generate Polylines from a Data Source

This example demonstrates how to generate map polylines based on data source objects and how to display these polylines on a vector layer.

  1. Create a ListSourceDataAdapter object and assign it to the VectorLayer.Data property.

  2. Specify the adapter’s DataSource property.

  3. Create a MapMultipointItemMappingInfo object and assign it to the adapter’s Mappings property.

  4. Map the following properties to data source fields:

  5. To specify the type of created map items, assign the appropriate settings to the ListSourceDataAdapter.ItemSettings property. In this example, use MapPolylineSettings to draw polylines.

xaml
<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:MapApp"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map" 
        x:Class="MapApp.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <dxm:MapControl x:Name="mapControl">
            <!-- You can optionally create a background image layer. -->
            <dxm:ImageLayer>
                <dxm:BingMapDataProvider Kind="RoadGray" 
                                         BingKey="Insert your Bing key." />
            </dxm:ImageLayer>

            <dxm:VectorLayer x:Name="vectorLayer" DataLoaded="OnVectorLayerDataLoaded">
                <dxm:VectorLayer.Data>
                    <dxm:ListSourceDataAdapter x:Name="listSourceDataAdapter" 
                                               DataSource="{Binding}">
                        <dxm:ListSourceDataAdapter.Mappings>
                            <dxm:MapMultipointItemMappingInfo Latitude="X" 
                                                              Longitude="Y" 
                                                              Points="PointSource"/>
                        </dxm:ListSourceDataAdapter.Mappings>
                        <dxm:ListSourceDataAdapter.ItemSettings>
                            <dxm:MapPolylineSettings Stroke="Red">
                                <dxm:MapPolylineSettings.StrokeStyle>
                                    <dxm:StrokeStyle Thickness="2"/>
                                </dxm:MapPolylineSettings.StrokeStyle>
                            </dxm:MapPolylineSettings>
                        </dxm:ListSourceDataAdapter.ItemSettings>
                    </dxm:ListSourceDataAdapter>
                </dxm:VectorLayer.Data>
            </dxm:VectorLayer>
        </dxm:MapControl>
    </Grid> 
</Window>
csharp
using DevExpress.Xpf.Map;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Media;

namespace MapApp {
    public partial class MainWindow : Window {
        ObservableCollection<Line> Data { get; set; }
        public MainWindow() {
            InitializeComponent();

            Data = new ObservableCollection<Line>();

            Line line1 = new Line();
            line1.PointSource.Add(new Coordinate(-5.93107, -35.112723));
            line1.PointSource.Add(new Coordinate(-10.13507, -25.15696));
            line1.PointSource.Add(new Coordinate(-5.183714, -8.911391));
            line1.PointSource.Add(new Coordinate(4.253438, 5.47072));
            Data.Add(line1);

            Line line2 = new Line();
            line2.PointSource.Add(new Coordinate(1, 0.5));
            line2.PointSource.Add(new Coordinate(-25, -15));
            line2.PointSource.Add(new Coordinate(-15, -25));
            line2.PointSource.Add(new Coordinate(-22.1531, -41.45984));
            Data.Add(line2);

            this.DataContext = Data;
        }
        private void OnVectorLayerDataLoaded(object sender, DataLoadedEventArgs e) {
            mapControl.ZoomToFitLayerItems(new LayerBase[] { vectorLayer }, paddingFactor: 0.3);
        }
    }
    public struct Coordinate {
        public double X { get; }
        public double Y { get; }
        public Coordinate(double x, double y) {
            X = x;
            Y = y;
        }
    }

    public class Line {
        public ObservableCollection<Coordinate> PointSource { get; } = new ObservableCollection<Coordinate>();
    }
}
vb
Imports DevExpress.Xpf.Map
Imports System.Collections.ObjectModel
Imports System.Windows.Media
Namespace MapApp
    Public Partial Class MainWindow
        Inherits Window
        Private Property Data As ObservableCollection(Of Line)
        Public Sub New()
            InitializeComponent()
            Data = New ObservableCollection(Of Line)()
            Dim line1 As Line = New Line()
            line1.PointSource.Add(New Coordinate(-5.93107, -35.112723))
            line1.PointSource.Add(New Coordinate(-10.13507, -25.15696))
            line1.PointSource.Add(New Coordinate(-5.183714, -8.911391))
            line1.PointSource.Add(New Coordinate(4.253438, 5.47072))
            Data.Add(line1)
            Dim line2 As Line = New Line()
            line2.PointSource.Add(New Coordinate(1, 0.5))
            line2.PointSource.Add(New Coordinate(-25, -15))
            line2.PointSource.Add(New Coordinate(-15, -25))
            line2.PointSource.Add(New Coordinate(-22.1531, -41.45984))
            Data.Add(line2)
            Me.DataContext = Data
        End Sub
        Private Sub OnVectorLayerDataLoaded(ByVal sender As Object, ByVal e As DataLoadedEventArgs)
            mapControl.ZoomToFitLayerItems(New LayerBase() {vectorLayer}, paddingFactor:=0.3)
        End Sub
    End Class
    Public Structure Coordinate
        Public ReadOnly Property X As Double
        Public ReadOnly Property Y As Double
        Public Sub New(ByVal x As Double, ByVal y As Double)
            Me.X = x
            Me.Y = y
        End Sub
    End Structure
    Public Class Line
        Public ReadOnly Property PointSource As ObservableCollection(Of Coordinate) = New ObservableCollection(Of Coordinate)()
    End Class
End Namespace

See Also

MapMultipointItemMappingInfo Class

MapMultipointItemMappingInfo Members

DevExpress.Xpf.Map Namespace