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

194
Vistas
Get distances of all stores from user in MapBox on the getCurrentPosition() button

I am working with the MapBox API and I want to sort all the stores on pressing the getCurrentPosition() button. I can do this when I search a location in the searchBox provided, because I change the location of the event object to the location of the user and sort all stores from that object.

Get current long, lat and store in user_long and user_lat

navigator.geolocation.getCurrentPosition(position => { 
          user_lat = position.coords.latitude;
          user_long = position.coords.longitude;
      }); 

Assign that long and lat to an event object

geocoder.on('result', (event) => {
          /* Get the coordinate of the search result */
          const searchResult = event.result.geometry;
          userLoc = searchResult;
// Make an object like event and assign that object the users location
          userLoc["coordinates"][0] = user_long;
          userLoc["coordinates"][1] = user_lat;

From here on its the same as the documentation.

How do I do this in the getCurrentPosition() button when I dont have 'event'?

about 4 years ago · Juan Pablo Isaza
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