Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Google Map Distance and Directions API

Google provides APIs for 1. Distance Matrix and 2. Direction service

I tried to search about difference between 1 and 2

My task is "When user moves from Source S to Destination D using some path. We need to show the actual path user has traversed on Google Map"

What is best way to accomplish it ?

Using 1. Distance Matrix APIs or 2. Direction service

like image 808
Kushal Avatar asked Mar 10 '15 04:03

Kushal


Video Answer


2 Answers

According to Google Maps API picker

You use Directions service for getting directions from origin to destination location using various forms of transport: walking, driving, cycling, public transit. Get a route from point A to point B.

For Distance Matrix it calculate the travel distance and travel time for multiple origins and destinations, optionally specifying various forms of transport: walking, driving, cycling.

For your case, I will suggest Directions service since you don't need travel time.

like image 141
Verma Avatar answered Sep 28 '22 10:09

Verma


I got answer to my question.

Google Maps V2 provides 2 sets of APIs for developers

1. Distance Matrix APIs : this is useful for computing distance(walking/travelling via bycycle,bus), cost of travel, time of travel

But this is not useful for this scenario.

2. Direction Service : this is useful for this scenario.

Through direction service, we can get the path of User on Google Map in Real Time

If we get the path through Distance Matrix, then Google Map returns the shortest established path between S Source and D Destination, this is not desirable in this scenario. User may not use shortest path due to some trafic, personal reasons and Diatance Matrix API output fails here.

So, I should use Direction Service API which give me real time Output for User location on Google Map

Thank you for your replies

like image 36
Kushal Avatar answered Sep 28 '22 10:09

Kushal