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

744
Vistas
How to get distance between two coordinates with Mapbox

I am learning how to use the Mapbox API for my node app and I want to perform calculations on the backend like getting the distance between two coordinates.

How can I achieve this?, the Mapbox documentation doesn't make this clear...

Set-up the SDK

const mapboxSdk = require("mapbox")
let mapbox = new mapboxSdk(process.env.MAPBOX_TOKEN)

// EXAMPLE OF WHAT I WANT TO DO

coordA = {lat : 33.968123, long: -118.419454}

coordB = {{lat : 33.997223, long: -117.929145}}

const distance = await mapbox.getDistance(coordA, coordB)

console.log(distance)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I believe Mapbox recommends using the Turf.js library for this type of thing: Turf.js Distance Function. However, the distance between two lat/long coords is a simple geometry problem that doesn't need any external APIs/libraries, and can be calculated from your coordinates using the Haversine Formula. Check this SO question for implementations of the Haversine formula as a javascript function.

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