Created
February 2, 2021 23:01
-
-
Save xantiagoma/2d181c11526fe8ab1406ce18c9ced325 to your computer and use it in GitHub Desktop.
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
L.Polyline = L.Polyline.include({ | |
getDistance: function(system) { | |
// distance in meters | |
var mDistanse = 0, | |
length = this._latlngs.length; | |
for (var i = 1; i < length; i++) { | |
mDistanse += this._latlngs[i].distanceTo(this._latlngs[i - 1]); | |
} | |
// optional | |
if (system === 'imperial') { | |
return mDistanse / 1609.34; | |
} else { | |
return mDistanse / 1000; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment