Good morning.
Apologies for the apparently silly/newbie question, but using the available endpoints, how do I calculate the distance between two locations - by coordinates or address? I cannot see a direct method to do this through the API documentation nor existing posts.
Thanks, Greg
The driving distance is provided directly in the api response
"routes": [
{
"summary": { "distance": 6120.9, "duration": 717.1 },
If you’re talking about the straight-line distance, you probably want to use a geodesic library function. The calculation differs depending on if you want to approximate it on a flat plane (nearby points) or if you need to use haversine for distant points to account for the shape of the planet.
1 Like
Hi @Arctyc
Thankyou for responding.
I’d be looking at the most “generic” route by roads as its a driving to site arrangement
Which is the (or best) endpoint to use for establishing the difference. The tools available through this service appear to be very comprehensive - almost overkill for what I’m doing, so I’m happy with the most basic one. I’m currently using Google but is not quite right for me.
Thanks again, Greg
Hey,
the endpoint for calculating distance is called directions.
Check our interactive API docs for examples on how to use it.
You might want to change the profile, depending on your mode of transport.
In the interactive docs, you can do that in the Path Parameters tab.
Best regards