Android Question Google Maps shortest distance

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello All,

Is there any way, from Google Maps library, or using other method, to get the shortest distance from two points Distance by road and not direct (strait line) distance ?

thanks
 

emexes

Expert
Licensed User
or using other method
You can directly try Open Streetmap Routing Machine from a browser eg request:

https://router.project-osrm.org/rou...7.689931;144.982734,-37.808353?overview=false

returns the almost human-readable:

JSON:
{"code":"Ok","waypoints":
[{"hint":"TPWHghP2RYASAAAATgAAABABAABbAAAAp8hyQOSRgkHesmJC7FmXQQkAAAAnAAAAiAAAAC0AAACDLAAAZuWjCNDlwP1m5aMIteXA_QIArwUnjHjC","distance":2.996673,"location":[144.958822,-37.689904],"name":""},
{"hint":"3456gjSPeoIwAAAACQAAAAAAAAAAAAAAtmMrQgJ_80AAAAAAAAAAADAAAAAJAAAAAAAAAAAAAACDLAAAikKkCCYXv_3OQqQIHxe__QAAfwAnjHjC","distance":6.037123,"location":[144.982666,-37.808346],"name":"Smith Street"}],
"routes":[{"legs":[{"steps":[],"weight":1252.6,"distance":16428.2,"summary":"","duration":1244.1}],"weight_name":"routability","weight":1252.6,
"distance":16428.2,
"duration":1244.1}]}

The distance (here, 16428 metres) is usually good, but the time doesn't take traffic into account.

I assume there's some limit on how much routing you can do for free, but I never got any sign of rejection even when I was doing gridded lookups up to 80 x 80 but was just me and only a few times per day - there might be some pushback if you had thousands of users doing similar.
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I have been using and cooperating with this service for years, and if it is limited, if they detect that you make massive use of the service. but there is an option so that you do not have problems with the blocking of the service.

 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
If you want to have the distances between the waypoints, you can apply this routine:


and translated by @marcick

 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I will soon publish a route optimization demo in the link I posted above.

Using my route server that I have set up with this service.
 
Upvote 0
Top