googlemaps / google-maps-services-java

Java client library for Google Maps API Web Services
Apache License 2.0
1.72k stars 946 forks source link

How we can get actual driving distance between two points using lat and lng? #90

Closed ghost closed 9 years ago

ghost commented 9 years ago

I am to get the actual distance between two points / coordinates using REST web services call like following http://maps.googleapis.com/maps/api/distancematrix/json?origins=54.406505,18.67708&destinations=54.446251,18.570993&mode=driving&language=en-EN&sensor=false

{ "destination_addresses" : [ "Kuby Kwiatkowskiego, Sopot, Poland" ], "origin_addresses" : [ "Majora Henryka Sucharskiego 70, 80-601 Gdańsk, Poland" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "24.4 km", "value" : 24412 }, "duration" : { "text" : "38 mins", "value" : 2300 }, "status" : "OK" } ] } ], "status" : "OK" }

But now I would like to get the "traveling distance" between them, how can I get this? Please guide me asap.

broady commented 9 years ago

isn't that 24.4km in that example? On Jun 19, 2015 3:58 PM, "pashtika" notifications@github.com wrote:

I am to get the actual distance between two points / coordinates using REST web services call like following

http://maps.googleapis.com/maps/api/distancematrix/json?origins=54.406505,18.67708&destinations=54.446251,18.570993&mode=driving&language=en-EN&sensor=false

{ "destination_addresses" : [ "Kuby Kwiatkowskiego, Sopot, Poland" ], "origin_addresses" : [ "Majora Henryka Sucharskiego 70, 80-601 Gdańsk, Poland" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "24.4 km", "value" : 24412 }, "duration" : { "text" : "38 mins", "value" : 2300 }, "status" : "OK" } ] } ], "status" : "OK" }

But now I would like to get the "traveling distance" between them, how can I get this? Please guide me asap.

— Reply to this email directly or view it on GitHub https://github.com/googlemaps/google-maps-services-java/issues/90.

broady commented 9 years ago

Also, this is a bug tracker for the java library. General questions about the maps api should go to stack overflow. On Jun 19, 2015 4:10 PM, "Chris Broadfoot" cbro@google.com wrote:

isn't that 24.4km in that example? On Jun 19, 2015 3:58 PM, "pashtika" notifications@github.com wrote:

I am to get the actual distance between two points / coordinates using REST web services call like following

http://maps.googleapis.com/maps/api/distancematrix/json?origins=54.406505,18.67708&destinations=54.446251,18.570993&mode=driving&language=en-EN&sensor=false

{ "destination_addresses" : [ "Kuby Kwiatkowskiego, Sopot, Poland" ], "origin_addresses" : [ "Majora Henryka Sucharskiego 70, 80-601 Gdańsk, Poland" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "24.4 km", "value" : 24412 }, "duration" : { "text" : "38 mins", "value" : 2300 }, "status" : "OK" } ] } ], "status" : "OK" }

But now I would like to get the "traveling distance" between them, how can I get this? Please guide me asap.

— Reply to this email directly or view it on GitHub https://github.com/googlemaps/google-maps-services-java/issues/90.

ghost commented 9 years ago

Ok, I will ask same on stack-overflow as well, 24.4 km is the actual distance between two points. I am not finding (after researching) anything about getting traveling distance. Do you know how to get traveling distance?

markmcd commented 9 years ago

As per the docs: "distance indicates the total distance covered by this leg", as opposed to the straight-line distance, which could be calculated mathematically (with fairly high accuracy) without an API call.

hashimgocharlie commented 9 years ago

Can you please provide the java code for the this driving distance calculation... my id is hashim2512@gmail.com

gnoi45 commented 8 years ago

using this api does give accurate distance between two location address?