I'm trying to programmatically calculate and add x number of equidistant points between two points on a polyline in the google maps api. For example with a polyline of two points I would like to add 5 equidistant points between them to make a total of 7. I'd like to achieve this programmatically, not via user interaction.
let path = [
{lat : 35.20806877349178, lng : 38.14744584290822},
{lat : 35.202442417421985, lng : 38.185044716791985},
];
path = someFunction(path);
console.log(path);
// outputs
[
{lat : 35.20806877349178, lng : 38.14744584290822},
// 5 new points in here
{lat : 35.202442417421985, lng : 38.185044716791985},
];
I think that I need to start by determining direction from point A to point B, and could then get the difference between lat/lng values divide by the number of points to add and then increment/decrement lat/lng values of point A by the divided difference...I think.
I'm struggling to know where to begin with this. Any help appreciated.