Skip to content

Instantly share code, notes, and snippets.

@ng-the-engineer
Created May 30, 2021 16:43
Show Gist options
  • Select an option

  • Save ng-the-engineer/d9ef888f0a3a7036fe4322de91f5c736 to your computer and use it in GitHub Desktop.

Select an option

Save ng-the-engineer/d9ef888f0a3a7036fe4322de91f5c736 to your computer and use it in GitHub Desktop.

Revisions

  1. ng-the-engineer created this gist May 30, 2021.
    17 changes: 17 additions & 0 deletions tracker.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    const refreshMeter = (detail) => {
    return new Promise((resolve) => {

    if (path == null) return resolve(detail);

    if (!isStart) return resolve(detail);

    const delta = calculateDelta(path._latlngs)
    accumulatedDistance += delta;

    const formattedDistance = (round(accumulatedDistance, 3)).toLocaleString('en-US', { minimumFractionDigits: 3 })
    distanceBox.textContent = formattedDistance;
    report(`3. Updated path with ${delta} km | accumulatedDistance = ${formattedDistance}`);

    return resolve(detail);
    })
    }