Assuming I have the following:
Point A (lat, lon) 33.95,-118.4333
Point B (lat, lon) 33.9461,-118.4431
I want to get the angle/direction the line is pointing to. How do I do this in Javascript?
Assuming I have the following:
Point A (lat, lon) 33.95,-118.4333
Point B (lat, lon) 33.9461,-118.4431
I want to get the angle/direction the line is pointing to. How do I do this in Javascript?
There's a npm package for that:
https://www.npmjs.com/package/geojson-tools#getDistance
and it's fairly easy to use:
const { getDistance } = require('geojson-tools')
var array = [
[20, 30],
[20.5, 29.5]
];
getDistance(array, 4); // 76.3212
Units are in meters i believe.
If you need the actual code to getDistance
, you may look for it here: https://github.com/MovingGauteng/GeoJSON-Tools/blob/master/src/geojson-tools.js