1

How can I show shortest path in my code like it is in the picture? enter image description here

I'm using this code to find shortest distance between two points.

Location locationA = new Location("point A");

locationA.setLatitude(lat);
locationA.setLongitude(long);

Location locationB = new Location("point B");

locationB.setLatitude(lat);
locationB.setLongitude(long);

distance = locationA.distanceTo(locationB);
Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92
J_Haskin
  • 116
  • 2
  • 11

1 Answers1

0

The distance you're calculating with Location is essentially 'as the crow flies'. That's the distance it takes to get from A to B traveling through the air. In the picture you noted, it appears you want the shorting driving distance from A to B, in which case you want navigation with roads, interstates, etc. This post is similar; it addresses the possibility of getting driving directions.

Community
  • 1
  • 1
crocboy
  • 2,887
  • 2
  • 22
  • 25