Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top