On Monday, August 8, 2022 20:37:30(IST) and Sunday, August 14, 2022 17:02:32(IST), when we called Google Distance Matrix API for following source and destination address combination
origin_addresses: 143 River St, Jaffrey, NH 03452, USA
destination_addresses: 75 Lowell Rd, Salem, NH 03079, USA
We got different Response as following:
August 8, 2022 20:37:30- We got 101 km
August 14, 2022 17:02:32(IST) - We got 85.9 km
We don't have any extra query parameters except source an destination API URL= Google API URL
- Can we know, Is it possible to have different distance for single source and destination?
The short answer is NO. That is, if you are using Distance Matrix API. The API will only return a single route, which is the best possible route.
But it is possible to have different distance for a single origin and destination by including the
alternativesparameter and setting it totrueusing Directions API.I commented on your question as to why it is recommended to use Directions API if you only have a single origin and a single destination. Or watch this Youtube Video for a quick explanation about Distance Matrix API and it's difference with Directions API.
With that said, I tried the address you used on the Directions API and included the parameter
alternativesand set it totrueand it showed an array of three alternate routes:Results are as follows:
Route #1
Route #2
Route #3
This concludes that the results you got on August 8 was the Route #1 and the one from August 14 was the Route #3.
The most probable cause of this could be the almost the same duration. although duration in hours is the same, if you look at the
valueon the results, route #1 had avalue: 4794while route #3 had avalue: 4793. And it could be interchanged because of traffic data and other factors, given that you had two different date and time on your requests(duration in traffic could be different on different days and different times of the day).Here's what the docs says:
Here's my request if you need some reference:
https://maps.googleapis.com/maps/api/directions/json?units=metric&origin=143%20River%20St,%20Jaffrey,%20NH%2003452,%20USA&alternatives=true&destination=75%20Lowell%20Rd,%20Salem,%20NH%2003079,%20USA&key=YOUR_API_KEYJust use your own API key and it should work.
I hope this helps.