gpx 1.1.1

Dart native js
Flutter Android iOS web

Package for load, manipulate, and save GPS data in GPX format (a light-weight XML data format for the interchange of GPS data - waypoints, routes, and tracks).

gpx #

Pub Package Build Status Coverage Status GitHub Issues GitHub Forks GitHub Stars GitHub License

A library for or load, manipulate, and save GPS data in GPX format (https://www.topografix.com/gpx.asp, a light-weight XML data format for the interchange of GPS data - waypoints, routes, and tracks). View the official GPX 1.1 Schema at https://www.topografix.com/GPX/1/1/gpx.xsd.

Also support export from Gpx into:

Getting Started #

In your dart/flutter project add the dependency:

 dependencies:
   ...
   gpx: ^1.1.1

Reading XML #

To read XML input use the GpxReader object and function Gpx fromString(String input):

import 'package:gpx/gpx.dart';

main() {
  // create gpx from xml string
  var xmlGpx = GpxReader().fromString('<?xml version="1.0" encoding="UTF-8"?>'
      '<gpx version="1.1" creator="dart-gpx library">'
      '<wpt lat="-25.7996" lon="-62.8666"><ele>10.0</ele><name>Monte Quemado</name><desc>Argentina</desc></wpt>'
      '</gpx>');

  print(xmlGpx);
  print(xmlGpx.wpts);
}

Writing XML #

To write object to XML use the GpxWriter object and function String asString(Gpx gpx, {bool pretty = false}):

import 'package:gpx/gpx.dart';

main() {
  // create gpx object
  var gpx = Gpx();
  gpx.creator = "dart-gpx library";
  gpx.wpts = [
    Wpt(lat: 36.62, lon: 101.77, ele: 10.0, name: 'Xining', desc: 'China'),
  ];

  // generate xml string
  var gpxString = GpxWriter().asString(gpx, pretty: true);
  print(gpxString);
}

Export to KML #

To export object to KML use the KmlWriter object and function String asString(Gpx gpx, {bool pretty = false}):

import 'package:gpx/gpx.dart';

main() {
  // create gpx object
  var gpx = Gpx();
  gpx.creator = "dart-gpx library";
  gpx.wpts = [
    Wpt(lat: 36.62, lon: 101.77, ele: 10.0, name: 'Xining', desc: 'China'),
  ];

  // generate xml string
  var kmlString = KmlWriter().asString(gpx, pretty: true);
  print(kmlString);
}

Limitations #

This is just an initial version of the package. There are still some limitations:

  • No support for GPX 1.0.
  • Read/write only from strings.
  • Doesn't validate schema declarations.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

License #

The Apache 2.0 License, see LICENSE.

5
likes
110
pub points
77%
popularity

Publisher

kb-apps.com

Package for load, manipulate, and save GPS data in GPX format (a light-weight XML data format for the interchange of GPS data - waypoints, routes, and tracks).

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache 2.0 (LICENSE)

Dependencies

collection, quiver, xml

More

Packages that depend on gpx