31

Possible Duplicate:
J2ME/Android/BlackBerry - driving directions, route between two locations

I'm just writing an App for displaying the route between two coords (lat, long) in google maps view. Displaying an single coord (even with a marker) works fine, but how to draw route between two point with 2 markers?

I must admit that I'm quite new to Android and the maps-API...

Community
  • 1
  • 1
poeschlorn
  • 12,230
  • 17
  • 54
  • 65
  • I am doing a similar kind of app and like to know if using kml or using the api to return a json is better. – O__O Jun 10 '12 at 02:03

2 Answers2

27

this is working example link. check it out. it helps to create the route overlay on the map. here is the complete source code for that.

Community
  • 1
  • 1
Praveen
  • 90,477
  • 74
  • 177
  • 219
  • One note, you might be running afoul of the Google Maps api if you use it to obtain driving directions (they removed this capability from the android maps api). – Robby Pond Apr 15 '10 at 12:49
  • yep. but we can do manipulations with the kml file of maps. in my answer, they are retriving the coordinates points to the route from the google maps kml file. check the RoadProvider.java the are build the url to get the road coordintes from the kml file. – Praveen Apr 15 '10 at 13:02
  • Thank you, that's excactly the thing I was looking for :) I think this will help for understanding and re-program it by myself. Thanks again :) – poeschlorn Apr 16 '10 at 07:20
  • @praveen i have completely followed your above link for route map but i got null null pointer exception mpointsize .also am getting fatal exception as well here i have posted all my source code http://stackoverflow.com/questions/11928933/the-questions-is-related-to-routemap-path-names-displaying please anyone help me out of this error am getting fatal and null pointer exception at drawpath() .and send me rectified code thanks in advance. – KAREEM MAHAMMED Aug 13 '12 at 06:09
6

Your route will be a list of points so you have to create a route overlay class. And in the draw method of the overlay class you have to draw a Path between the points.

Robby Pond
  • 73,164
  • 16
  • 126
  • 119