user396707
user396707

Reputation: 439

Road Distance calculation available to Java

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.

Upvotes: 2

Views: 1954

Answers (1)

Papuass
Papuass

Reputation: 327

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.

Upvotes: 3

Related Questions