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

161
Views
How can I get truly random even distribution of GPS coordinates in JavaScript?

My first attempt produces points often near polar regions:

gps = {
    lat: (Math.random() * (90 - -90) + -90) * Math.PI / 180,
    lon: (Math.random() * (180 - -180) + -180) * Math.PI / 180,
    alt: 0
};

(yes I'm converting to radians) I quickly realized that it's an uneven distribution. According to this site https://dosull.github.io/posts/2021-10-20-random-even-points-on-the-globe/ I'll need to use some sort of "acos" (is that arccos?) function, but I don't even know what language that is. whuber's comment at https://gis.stackexchange.com/questions/236321/generating-random-lat-long-coordinates mentions cosine but I'm not sure exactly what the formula would be.

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

0

lat: Math.acos(Math.random() * 2 - 1) - Math.PI / 2,
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!