15

Some questions about Android and Google Directions Service:

  • Is there a native way on Android to use the Directions Service from Google or are there any nice Wrapper Frameworks? I would like to retrieve the time needed to get from A to B and maybe show the route in a table and/or map.

  • As far as I know directions can only be retrieved for "walking" and "driving". Is there a way (maybe not from google) to get this Information also for public transports or "biking" ?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
georam
  • 494
  • 2
  • 5
  • 14

1 Answers1

18

I don't know exactly if this is what you want, but you could fire up an intent like this:

String url = "http://maps.google.com/maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url));

To get biking directions add "&dirflg=b" to the url. For public transport add "dirflg=r".

This will display the route in the google Maps app. If you want to get this in your app inside a mapview, please see this code at github. You could hack into the code to add biking and public transport functionality.

Hope this helps somehow.

Jan S.
  • 10,328
  • 3
  • 31
  • 36
  • 1
    If this answer satisfies you, you could mark your question as answered :) This is how StackOverflow works. BTW here there is another way of doing this: http://stackoverflow.com/questions/2023669/j2me-android-blackberry-driving-directions-route-between-two-locations/2023685#2023685 – Jan S. May 19 '10 at 22:18
  • 5
    Certainly helped me! And an alternative to saddr=some+address is saddr=[lat],[long] (e.g. saddr=51.2648524,-1.0877917). If you miss saddr altogether and specify only daddr, the directions will start from your current location. – teedyay Oct 14 '10 at 19:44
  • home.ameliemedia.com is now a parked page with no content. What to do now? – Greg Ennis Jan 18 '12 at 19:23
  • 1
    I uploaded the source to github: https://github.com/janfsd/DrivingDirsMapActivity – Jan S. Jan 21 '12 at 04:32
  • @JanS. I removed the link to the parked page; please rollback if there's any reason to keep it. – Marijn Oct 16 '12 at 09:54
  • Where did you find documentation for this? – Johan S Apr 16 '13 at 08:45
  • There is nothing at http://www.github.com/janfsd/DrivingDirsMapActivity. Any way to get it? – iTurki Jul 17 '13 at 20:21
  • @iturki I updated the link. Should be now https://github.com/jansanz/DrivingDirsMapActivity – Jan S. Aug 12 '13 at 19:52