Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda