I want to get the coordinates of a point x meters away from a given point.
I found this code which gives the distance between two coordinate pairs but I want to give one coordinate pair and the distance and return the coordinates of the point away by the given distance.
I think an angle will need to be given too otherwise the result will be a circle. I got the following from this question
function measure(lat1, lon1, lat2, lon2){ // generally used geo measurement function
var R = 6378.137; // Radius of earth in KM
var dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
var dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
return d * 1000; // meters
}
Can someone help me do this in JavaScript?
I found another one that uses distance and bearing to do the same but using Google maps API. I don't understand the math behind the conversion and I don't want to include the Google maps API either.
this code is on This other question