Fit file encoder.
npm i gpx2fit
import {gpx2fitEncoder} from 'gpx2fit'
import {outputFile} from 'gpx2fit/lib/output'
gpx2fitEncoder(gpxString).then(encoder => outputFile(encoder, 'fileName'));
import {gpx2fitEncoder} from 'gpx2fit'
gpx2fitEncoder(gpxString).then(encoder => {
const blob = encoder.createBlob()
const url = URL.createObjectURL(blob);
const anchorElement = document.createElement('a');
anchorElement.download = `test.fit`;
anchorElement.href = url;
anchorElement.click();
})
import {gpx2fitEncoder} from 'gpx2fit'
import {outputFile} from 'gpx2fit/lib/output'
gpx2fitEncoder(gpxString).then(encoder => outputFile(encoder, 'file'))
- writeMessage: (name: string, values: Record<string, any>) => void;
import {FitEncoder} from 'gpx2fit'
const encoder = new FitEncoder()
encoder.writeMessage('record', {
altitude: 31.6,
cadence: 67,
distance: 6.27,
heart_rate: 129,
position_lat: 39.836671,
position_long: 116.5075257,
speed: 5.963,
temperature: 20,
timestamp: 1620512424000,
})
-
createBlob: () => Blob; only web
-
dataArrayBuffer: ArrayBuffer[]; fit file ArrayBuffer;
-
header: ArrayBuffer
-
trailer: ArrayBuffer
-
msgBuffers: ArrayBuffer[]
original author:
Nick Holloway