6155031
6155031

Reputation: 4347

Directions Api Params

I wanted to use google map directions API and draw pessimistic traffic poly-lines. I looked at this URL.

https://maps.googleapis.com/maps/api/directions/json?origin=41.0050506,29.0680688&destination=41.011522,29.983513&sensor=false&trafficModel=pessimistic

I created API above for pessimistic traffic. But there is no difference between best_guide or optimistic. I don't know, There is something wrong with URL?

{
  origin: 'Chicago, IL',
  destination: 'Los Angeles, CA',

  provideRouteAlternatives: false,
  drivingOptions: {
    departureTime: new Date(/* now, or future date */),
    trafficModel: 'pessimistic'
  }
}

I guess trafficmodel param must be in drivingOptions. Can anybody help me to create url like this above .

Thanks for any suggestion .

Upvotes: 0

Views: 264

Answers (1)

Akhil
Akhil

Reputation: 6697

Below is from the documentation, Google will use data available to it, If Google doesn't have enough data for that particular route, it will return estimates, so these are estimates

Also please note:

  • Lat longs you are using are not very far under ~2km, try route for bigger distance say 25 km
  • You should try another route where you know traffic is more, you might get different results
  • bestguess (default) indicates that the returned duration_in_traffic should be the best estimate of travel time given what is known about both historical traffic conditions and live traffic. Live traffic becomes more important the closer the departureTime is to now..
  • pessimistic indicates that the returned duration_in_traffic should be longer than the actual travel time on most days, though occasional days with particularly bad traffic conditions may exceed this value.
  • optimistic indicates that the returned duration_in_traffic should be shorter than the actual travel time on most days, though occasional days with particularly good traffic conditions may be faster than this value.

Upvotes: 1

Related Questions