Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
How to get Latitude and Longitude after going a distance at certain bearing from another point?

Let's say I have the latitude and longitude coordinate [30, -87]. From that point, I would like to be able to find where my location would be after traveling let's say 10km at 45 degrees of bearing.

My first attempt at trying to solve this didn't go so well as you can see below. This obviously doesn't account for the units which is really the hardest part to comprehend for me at least.

var bearing = 45;
var distance = 10;

var position = {
 "latitude": 30,
 "longitude": -87
};

var newLat = Math.cos(bearing) * distance + position.latitude;
var newLon = Math.sin(bearing) * distance + position.longitude;

I'm assuming the radius of the earth will come into play at one point but I really didn't know where to start so any help would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have used python code here: Get lat/long given current point, distance and bearing, and converted in into JS code to get the answer.

Here is the code:

const bearing = 45;
const bearing_rad = (bearing*Math.PI)/180;
const distance = 10;

const EARTH_RADIUS = 6378.1;

const initial_position = {
 "latitude": 30,
 "longitude": -87
};

const init_lat = (initial_position.latitude*Math.PI)/180;
const init_lon = (initial_position.longitude*Math.PI)/180;

const final_lat = (180/Math.PI)*(Math.asin( Math.sin(init_lat)*Math.cos(distance/EARTH_RADIUS) + Math.cos(init_lat)*Math.sin(distance/EARTH_RADIUS)*Math.cos(bearing_rad)));

const final_lon = (180/Math.PI)*(init_lon + Math.atan2(Math.sin(bearing_rad)*Math.sin(distance/EARTH_RADIUS)*Math.cos(init_lat), Math.cos(distance/EARTH_RADIUS)-Math.sin(init_lat)*Math.sin(final_lat)));

console.log(final_lat, final_lon); // 30.06350049619102 -86.96303358059173
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!