var latA=32.718835,
lonA=-16.761171,
latB=32.711461,
lonB=-16.911347,
lat = Math.floor(latA * 1e6),
lon = Math.floor(lonA * 1e6),
countLat = Math.floor(Math.abs(latA-latB)*1e6)+1,
countLon = Math.floor(Math.abs(lonA-lonB)*1e6)+1,
count = Math.max(countLat, countLon),
lonDiff = (lonB-lonA) / countLat * 1e6,
latDiff = (latB-latA) / countLon * 1e6,
latSign = Math.sign(latB - latA),
lonSign = Math.sign(lonB - lonA),
arr = [];
if (countLat < countLon) {
lonDiff = lonSign;
} else {
latDiff = latSign;
}
for (let i = 0; i <= count; i++) {
arr.push({
lat: (lat / 1e6).toFixed(6),
lon: (lon / 1e6).toFixed(6)
});
lat += latDiff;
lon += lonDiff;
}
console.log(arr.length, arr[0], arr.slice(-1)[0]);