Reputation: 91
I'm calculating route distance and transport time between user specified by LatLng (by dragging marker) with distance matrix api. But sometimes I got a wrong distance which looks like using toll(or highway) accidentally.
First I have tried:
Rounding origin(and destination) location by reverse geocoding LatLng with ROOF_TOP option to avoid user specified origin on highway.
I works like a charm to avoid highway origin (or destination).
But then I encounting a problem that distance matrix calculate too long route which looks like using highway.
I have checked estimate route with google-map then google returns route that using highway.
But when I checked Uber-app with same origin and destination (I assumed they using google map's api!!) they returned normal price. So I think there is a solution...but I can't find...
I found moving origin a little can solve this problem (it seems like google assumed one-way traffic accidentally), but how can I programatically solve it?
Upvotes: 1
Views: 2155
Reputation: 4950
You can avoid highways avoid
parameter in your request. This parameter supports tolls, highways, ferries and indoors
.
Directions may be calculated that adhere to certain restrictions. Restrictions are indicated by use of avoid
parameter and an argument to that parameter indicating the restriction to avoid.
It's possible to request a route avoids any combination of tolls, highways and ferries by passing both restrictions to the avoid parameter.
For example:
avoid=tolls|highways|ferries
avoid=tolls
avoid=highways
avoid=ferries
Upvotes: 2