Skip to main content

GpxFileDataAdapter Class

A data adapter that loads data from GPX files, and displays it on vector layers.

Namespace: DevExpress.Xpf.Map

Assembly: DevExpress.Xpf.Map.v24.1.dll

NuGet Package: DevExpress.Wpf.Map

Declaration

public class GpxFileDataAdapter :
    MapGeoDataAdapter,
    IListSource,
    IGpxOptionsProvider

Remarks

Tip

To try out the GpxFileDataAdapter, see the GPX Data Adapter demo.

GPX files store coordinate-based data such as waypoints, routes, and tracks in an XML-like format.

The Map Control converts GPX file elements as follows:

  • <wpt> (waypoint) is displayed as MapDot.
  • <rte> (route) is converted to a MapPolyline.
  • <trk> (track) is represented by a MapPath.

Routes and tracks are built based on trkpt coordinates nested inside <rte> or <trk> elements. If you enable the CreateRoutePoints property, map dots are generated for each trkpt element.

Follow the steps below to load data from a .GPX file:

  1. Add a VectorLayer object to the MapControl.Layers collection.
  2. Create a GpxFileDataAdapter object.
  3. Specify the path to a GPX file via the MapGeoDataAdapter.FileUri property.
  4. Assign the GpxFileDataAdapter to the VectorItemsLayer.Data property.
<Window xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
        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:FileDataAdapters"
        x:Class="FileDataAdapters.MainWindow"
        xmlns:sys="clr-namespace:System;assembly=System"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <dxm:MapControl x:Name="mapControl">
            <dxm:ImageLayer>
                <dxm:BingMapDataProvider Kind="Road" BingKey="Your-BingKey-here"/>
            </dxm:ImageLayer>
            <dxm:VectorLayer x:Name="vectorLayer" DataLoaded="OnVectorLayerDataLoaded">
                <dxm:VectorLayer.Data>
                    <dxm:GpxFileDataAdapter ShapesLoaded="OnDataAdapterShapesLoaded" CreateRoutePoints="True">
                        <dxm:GpxFileDataAdapter.FileUri>
                            <sys:Uri>pack://application:,,,/FileDataAdapters;component/Data/boston-marathon-course.gpx</sys:Uri>
                        </dxm:GpxFileDataAdapter.FileUri>
                    </dxm:GpxFileDataAdapter>                    
                </dxm:VectorLayer.Data>
            </dxm:VectorLayer>
        </dxm:MapControl>
    </Grid>
</Window>

Note: In the example above, the GPX file’s Build Action is set to Resource.

See Also