Reputation: 99
When I use the Google Maps directions API (server-side) the distance and duration are almost always different then the embedded (iframe) maps tells me.
I use the embedded version to show to the customer, and I use the API version to calculate the taxi price. It is therefore necessary that I get the same distance and duration from both services.
I am using the following origin address: Straße des 17. Juni, Berlin, Germany
I am using the following destination address: Amsterdam Airport Schiphol, Netherlands
With the above route, this is the output:
Embedded (iframe): 6 hours 31 mins - 661km
API (server-side): 6 hours 3 mins - 662km
Directions API: https://developers.google.com/maps/documentation/directions/
Directions Embed: https://developers.google.com/maps/documentation/embed/start
Hope somebody can help me out.
Upvotes: 2
Views: 1234
Reputation: 31209
Different distance:
the embedded changes your destination to "Schiphol Amsterdam Airport, Evert van de Beekstraat 202, 1118 CP Schiphol, Netherlands" while the API call leaves it exactly like you entered it. The resulting coordinates are different
API call with slightly modified destination
Different time:
Looks like the embed is taking into account traffic conditions and departure_time and the API call does not. Are you using an API key?
For driving directions: Google Maps API for Work customers can specify the departure_time to receive trip duration considering current traffic conditions
Upvotes: 2