0

I have an application where I gather a bunch of geopoints and show them on a map, based off where the user goes. I want to be able to give turn by turn directions for all of those geopoints. Basically I want turn by turn directions of the path they took. The problem is everything I see, and I have looked a lot of place, only shows how to do this for 2 points start and destination.

user638049
  • 189
  • 2
  • 10

1 Answers1

0

If you want the direction between to geopoints you have to calculate it. First you need to get the difference of the north/south direction and the the difference of the eas/west direction. Then you can calculate the angle between the two geopoints by using the atan2.

double north_south = point1.getLatitude() - point2.getLatitude();
double east_west = point1.getLongitude() - point2.getLongitude();
int angle = (int) (Math.atan2(east_west, north_south) /
            Math.PI * 180.0 + 360.0f);

This is how you get the direction between 2 points (in degrees). If you want to navigate the user, you have to write a whole navigation software, which is far more complicated.

Franziskus Karsunke
  • 4,948
  • 3
  • 40
  • 54
  • Ok, I understand that, but is there a way to pass more than 2 addresses to google maps to get the turn by turn directions. Meaning if I have 10 geopoints, converting them to addresses and then passing them to google maps or something elese to either get the turn by turn directions in google maps, or get the turn by turn directions given back to me from the service? – user638049 Nov 07 '11 at 16:15
  • You can start a navigation intent (as you can see here: http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android) But as far as i know this is not possible for more than one geopoint. – Franziskus Karsunke Nov 07 '11 at 16:24