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

184
Views
Can I save user latitude to a variable?

I can't pull the latitude or longitude out of the browsers API and have been trying for probably two weeks. Have been reading everything I can find and taking a class on functions, but this is just over my head. Is there a way I can save it to a variable so I plug it into another function. Have tried a couple ways

Way 1:

const x = navigator.geolocation.getCurrentPosition(({coords})) => {
    return pos.coords.latitude
}

Way 2:

navigator.geolocation.getCurrentPosition(function (position) {
    if ((splitCoords[1] - position.coords.latitude >= -0.009 && splitCoords[1] - position.coords.latitude <= 0.009) && 
    (splitCoords[0] - position.coords.longitude >= -0.009 && splitCoords[0] - position.coords.longitude <= 0.009))
    {
        return "Yes"
    } else {
        return "No"
    }
})     

What's throwing me off is the fact that getCurrentPosition() is, itself, a function.. and I can't find anywhere that shows me how to query certain coordinates out of it. I console.logged the whole thing in the browser and went down the tree and 'coordinates' don't exist. Am I on the right track?

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

0

I was able to find the answer in a series of youtube videos starting with this one. The videos are awesome, highly recommend for anyone who stumbles across this looking for a solution.

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!