Small preact-based (like React.js) project
https://inga-lovinde.github.io/static/komoot-demo/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
656 B
21 lines
656 B
import GeoJsonToGpx from '@dwayneparton/geojson-to-gpx';
|
|
import { saveAs } from 'file-saver';
|
|
import { Waypoint } from '../shared/types';
|
|
|
|
export const exportMarkersToGpx = (waypoints: Waypoint[]) => {
|
|
const gpx = GeoJsonToGpx({
|
|
type: 'Feature',
|
|
geometry: {
|
|
type: 'LineString',
|
|
coordinates: waypoints.map(({ coordinates }) => [
|
|
coordinates.lng,
|
|
coordinates.lat,
|
|
]),
|
|
},
|
|
properties: {},
|
|
});
|
|
const gpxBlob = new Blob([new XMLSerializer().serializeToString(gpx)], {
|
|
type: 'application/gpx+xml',
|
|
});
|
|
saveAs(gpxBlob, 'route.gpx');
|
|
};
|
|
|