示例#1
0
        public static void SaveGpxCoordinates(LocationCollection route, string gpxFileName)
        {
            var coords = route.Select(l => new Coordinate(l.Latitude, l.Longitude)).ToList();

            var gpx     = new Gpx11Serializer();
            var gpsData = new GpsData();
            var track   = new Track();
            var segment = new TrackSegment();

            track.Segments.Add(segment);

            foreach (var loc in route)
            {
                segment.Waypoints.Add(new Waypoint(loc.Latitude, loc.Longitude));
            }

            gpsData.Tracks.Add(track);
            string gpxData = gpx.Serialize(gpsData);

            File.WriteAllText(gpxFileName, gpxData);
        }