Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda