0

I have an array of lat/lng. Example:

[
  "14.60592,103.12081",
  "38.21146,114.86461",
  "13.73028,100.65138",
  "34.08863,108.39783",
  "57.186,14.04"
]

How can I calculate the overall distance from A to B and from B to C.

I trying with the Google Distance Matrix API.

Badacadabra
  • 8,043
  • 7
  • 28
  • 49

1 Answers1

0

If you need driving distance then you will not be able to calculate it with any formula not knowing the terrain, roads etc. For example if there is a river between those two points then the driving distance will depend on where is the closest bridge.

You can use some API that has that knowledge and can give you a real driving distance. For example you can use the Google Maps API. See e.g. Distance Matrix API:

You can use the Google Maps API in Node with:

and some more - see:

rsp
  • 107,747
  • 29
  • 201
  • 177