Created
May 30, 2021 09:28
-
-
Save ng-the-engineer/f2cd86d7e401815d89bbad4f56d239fb to your computer and use it in GitHub Desktop.
Code snippet of tutorial running tracker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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