This commit is contained in:
muerwre 2019-02-18 12:17:11 +07:00
parent 99f76dbe2c
commit bcc357ca98

View file

@ -18,13 +18,28 @@ export const getGPXString = ({ points, title }: IGetGPXString): string => (`
${
points.reduce((cat, { lat, lng }, index) => (
` ${cat}
<rtept lat="${lat}" lon="${lng}"></rtept>`
<wpt lat="${lat.toFixed(6)}" lon="${lng.toFixed(6)}"></wpt>`
), '')
}
</rte>
</gpx>
`);
// export const getGPXString = ({ points, title }: IGetGPXString): string => (`
// <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
// <gpx>
// <rte>
// <name>${title || 'GPX Track'}</name>
// ${
// points.reduce((cat, { lat, lng }, index) => (
// `${cat}
// <rtept lat="${lat}" lon="${lng}"></rtept>`
// ), '')
// }
// </rte>
// </gpx>
// `);
export const downloadGPXTrack = ({ track, title }: { track: string, title?: string }) => (
saveAs(
new Blob([track], { type: 'application/gpx+xml;charset=utf-8' }),