GpxFileDataAdapter Class
Namespace: DevExpress.Xpf.Map
Assembly: DevExpress.Xpf.Map.v24.2.dll
NuGet Package: DevExpress.Wpf.Map
#Declaration
public class GpxFileDataAdapter :
MapGeoDataAdapter,
IListSource,
IGpxOptionsProvider
#Remarks
Tip
To try out the Gpx
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:
- Add a VectorLayer object to the MapControl.Layers collection.
- Create a GpxFileDataAdapter object.
- Specify the path to a GPX file via the MapGeoDataAdapter.FileUri property.
- Assign the GpxFileDataAdapter to the VectorItemsLayer.Data property.
using DevExpress.Xpf.Map;
using System.Windows;
using System.Windows.Media;
namespace FileDataAdapters {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void OnVectorLayerDataLoaded(object sender, DataLoadedEventArgs e) {
mapControl.ZoomToFitLayerItems(new LayerBase[] { vectorLayer });
}
private void OnDataAdapterShapesLoaded(object sender, ShapesLoadedEventArgs e) {
foreach (MapItem item in e.Shapes) {
if (item is MapDot) {
((MapDot)item).Fill = Brushes.Coral;
((MapDot)item).Stroke = Brushes.Coral;
((MapDot)item).Size = 8;
}
if (item is MapPath) {
((MapPath)item).Stroke = Brushes.Black;
((MapPath)item).StrokeStyle = new StrokeStyle { Thickness = 2 };
}
}
}
}
}
Note: In the example above, the GPX file’s Build Action is set to Resource.