简体   繁体   中英

Google Maps directions duration in traffic

I know there is a way to request for duration in traffic using Google Maps API but it's restricted to Google Maps Business users and is subject to availability.

My question is, is there a way to account for traffic using a normal Google maps directions request? Or if not, is there a general time buffer we can add to the returned estimate?

Short answer is no .

However, I must also say thay the DirectionRequest object specification does no longer include the parameter durationInTraffic .

As of November 2015 it says :

The durationInTraffic request field is now deprecated. It was previously the recommended way for Google Maps APIs Premium Plan customers to specify whether the result should include a duration that takes into account current traffic conditions. You should now use the drivingOptions field instead.

It also says:

The Directions service and the Distance Matrix service now return the predicted time in traffic (in response field duration_in_traffic) when the travel mode is driving. To receive predicted travel times, include a drivingOptions object literal in the request, specifying a current or future departureTime. [...] The duration_in_traffic is available only to Google Maps APIs Premium Plan customers .

check this out.I guess What you are requesting is possible using GOOGLE MAPS API V3 Direction Request will return Something like this.

{
 origin: LatLng | String,
 destination: LatLng | String,
  travelMode: TravelMode,
 transitOptions: TransitOptions,
 unitSystem: UnitSystem,
durationInTraffic: Boolean,
waypoints[]: DirectionsWaypoint,
 optimizeWaypoints: Boolean,
 provideRouteAlternatives: Boolean,
avoidHighways: Boolean,
 avoidTolls: Boolean
region: String
 }

hope this helps.

For Google API, you have to have API for Work to obtain traffic info. Bing provides the traffic info for basic account. You can either use Bing Map, or you can extract traffic info (basically, just the duration in traffice from A to B) from Bing to Google Map

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM