I have an array of geocoordinates as follows:
const coordinates = [
{ lat: 40.54735374702427, lon: -74.39442702644757 },
{ lat: 40.27735374702427, lon: -74.43442702644757 },
{ lat: 40.19735374202427, lon: -74.84442702644757 }
]
How do I get the total distance with all the coordinates combined like so:
Distance between coords[0]
- coords[1]
added to coords[1]
- coords[2]
etc. for all the elements in the array to get the total distance in miles. I also want to take into account the curvature of the earth.
NOTE: All coordinates are made up for the purpose of this question.