How to get total travelled distance and route from google map directions API to show user travelled path like Uber.
You can use the Google Maps Distance Matrix API that provides travel distance and time for a matrix of origins and destinations. It returns information based on the recommended route between start and end points, as calculated by the Google Maps API, and consists of rows containing duration and distance values for each pair.
A Google Maps Distance Matrix API request takes the following form:
https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters
where outputFormat
may be either of the following values:
Check this example from GitHub. The tutorial finds the distance and time taken to travel in driving mode and by avoiding tolls from origin to destination using Google Maps Distance Matrix API.
Here also are some related SO questions:
Hope this helps!