Road Distance calculation available to Java

1.9k views Asked by At

I am developing an Android app and want to get the road distance between 2 locations. If I understand correctly, the options are:

  1. Using the distanceTo() or distanceBetween() methods of the Location class — but this only provides the direct line instance.
  2. Using the Google Directions API — but this only seems to be available to Javascript, and I am developing in Java.

Are there any other options available? If so, an example would be appreciated.

1

There are 1 answers

6
Papuass On BEST ANSWER

You can get that response in JSON or XML from Maps API Web Services: http://code.google.com/intl/lv/apis/maps/documentation/directions/

The response will contain Legs (further divided in Steps) of calculated route and each leg will contain a distance field with value in meters. If there are multiple legs, You will need to add them together. If you do not have waypoints, there will be only one Leg.