I have an array with x elements given lat - lng value. My aim is to find the distance difference between the previous position and the next position in the loop as long as the number of elements (length) of the array with the haversine formula.
Example my array value;
var array = [
[51.06745252933975, -114.11267548799515],
[51.067506465746014, -114.09559518098831],
[51.0827140244322,-114.0949085354805],
[51.088267312195484,-114.10709649324417]];
I don't have a problem with math, my goal is to get the cursor in the loop as the previous element vs. the next actually pointer order.
Sketchy code recipe;
1st index of the loop; array[0] lat-lng and array[1] lat-lng calc distance
2nd index of the loop; array[1] lat-lng and array[2] lat-lng calc distance
I'm using Javascript and how do I do it most ideally?