A Dart library for loading, manipulating, and saving GPS data in GPX format
(https://www.topografix.com/gpx.asp), a light-weight XML data format for the
interchange of GPS data, including waypoints, routes, and tracks.
View the official GPX 1.1 Schema at https://www.topografix.com/GPX/1/1/gpx.xsd.
It also supports exporting Gpx data into:
KML (a file format used to display geographic data in an Earth browser such as Google Earth, https://developers.google.com/kml/)
CSV (not implemented yet)
Getting Started
In your dart/flutter project add the dependency:
dependencies:...gpx:^2.5.0
Reading XML
To read XML input use the GpxReader object and function Gpx fromString(String input):
Some GPX applications expect the standard GPX 1.1 namespace and schema declarations on the root <gpx> element. Use
GpxCompatibilityMode.gpx11 when writing files for applications such as EasyGPS, JPX, Garmin BaseCamp, and other strict
GPX parsers:
final xml = GpxWriter().asString(
gpx,
pretty: true,
compatibility: GpxCompatibilityMode.gpx11,
);
This writes a root element with the standard GPX 1.1 declarations:
For Garmin BaseCamp files that also need the Garmin GpxExtensions/v3
namespace, combine the GPX 1.1 compatibility mode with GpxNamespaces.garmin:
final xml = GpxWriter().asString(
gpx,
pretty: true,
compatibility: GpxCompatibilityMode.gpx11,
namespaces: GpxNamespaces.garmin,
);
Custom namespaces and attributes are applied after the compatibility mode,
so they can extend or override the default GPX 1.1 declarations when needed.
Garmin GpxExtensions v3
The package includes typed models for the Garmin GpxExtensions/v3, TrackPointExtension/v1, and
WaypointExtension/v1 schemas: