I am developing an Android app and want to get the road distance between 2 locations. If I understand correctly, the options are:
- Using the distanceTo() or distanceBetween() methods of the Location class — but this only provides the direct line instance.
- 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.
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.