Skip to content

Instantly share code, notes, and snippets.

@ng-the-engineer
Created May 30, 2021 09:28
Show Gist options
  • Save ng-the-engineer/f2cd86d7e401815d89bbad4f56d239fb to your computer and use it in GitHub Desktop.
Save ng-the-engineer/f2cd86d7e401815d89bbad4f56d239fb to your computer and use it in GitHub Desktop.
Code snippet of tutorial running tracker
const drawNewSegment = (detail) => {
const { latitude, longitude } = detail;
return new Promise((resolve) => {
if (path == null) {
path = L.polyline([
[ latitude, longitude ],
], {
color: '#fbc531',
bubblingMouseEvents: true
}).addTo(map);
map.setView([latitude, longitude], 15)
map.fitBounds(path.getBounds());
} else {
if (isStart === true) {
path._latlngs.push([latitude, longitude]);
path.redraw();
}
}
return resolve(detail);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment