kb0 / dart-gpx

Dart 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).
Apache License 2.0
24 stars 27 forks source link

Save GPX file and upload to Strava #7

Closed ilhamamirullah closed 3 years ago

ilhamamirullah commented 3 years ago

Hello,

Kindly need your help how to save a file GPX because I wanna write the GPX file then upload to Strava. Is this library support to Strava?

Thank you

kb0 commented 3 years ago

Hi,

Yes, you can upload GPX generated by this library to Strava. Use GpxWriter().asString(gpx, pretty: true); to save your data as GPX string

import 'package:gpx/gpx.dart';

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

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

  // save it to file