I'm currently using Google DistanceMatrix to get the distance between multiple points.
For example, I have 4 different points, to get the distance between each point, I give in the 4 points as both origins and destinations.
"destination_addresses" : [
"201 W 75th St, New York, NY 10023, USA",
"569-573 Columbus Ave, New York, NY 10024, USA",
"142a E 79th St, New York, NY 10075, USA",
"1350-1352 Madison Ave, New York, NY 10128, USA"
],
"origin_addresses" : [
"201 W 75th St, New York, NY 10023, USA",
"569-573 Columbus Ave, New York, NY 10024, USA",
"142a E 79th St, New York, NY 10075, USA",
"30 E 95th St, New York, NY 10128, USA"
],
...
This gives me a 4 x 4 array, which makes sense. But now I want to find all possible routes from A
to B, C and D
.
So essentially I want to find and get the total distance and duration
A -> B -> C -> D
A -> B -> D -> C
A -> C -> B -> D
...
I tried writing a recursive function, but failed at it. What would be the best way to do this?