2

I am looking to integrate Directions between a Lat, Long and the present location of the User. I would want at the click of the button to direct the user to the installed Google Maps/ Other Apps and show the directions.

I search SO and Google but couldn't find a good source and hence am posting this Question.

Tour Bangalore seems to be able to do it. Couldnt find documentation on how to achieve this

2
  • did you mean you wanted to integrated the MapFragment and the Google Maps Android Api into your app? Commented Jan 21, 2013 at 19:39
  • @CTulip nope. on click Directions. I want to throw up an Intent that will take the user to Maps App and show the directions. I saw this in a few apps. But could not find the documentation for the same.
    – Harsha M V
    Commented Jan 21, 2013 at 19:40

2 Answers 2

2

There is no documented and supported Intent structure for this, sorry. You can bring up a map on a point, but not force Maps to obtain directions.

Also, bear in mind that:

  • not all devices have Google Maps
  • the user might not want to use Google Maps, even if it is installed (e.g., they bought some third-party mapping app that they wish to use)
5
  • I can see that this app has done it somehow :( play.google.com/store/apps/…
    – Harsha M V
    Commented Jan 21, 2013 at 19:41
  • yeah am sorry i meant MAPS app not Google MAps in particular. i will edit my Question
    – Harsha M V
    Commented Jan 21, 2013 at 19:42
  • @HarshaMV: "I can see that this app has done it somehow :(" -- and then their app will break when Google changes the Maps app. Commented Jan 21, 2013 at 19:47
  • oh. Which is the best way to achieve this and the closest one ? i have a co-ordinate destination. And the user should be able to get the directions to the place from his location.
    – Harsha M V
    Commented Jan 22, 2013 at 1:44
  • 1
    @HarshaMV: One advantage of using iagreen's answer is that, even if Maps stops honoring that URL (or Maps is not on the device), the URL should still work to bring up the Web-based Maps in the browser. How well that will work for the user (e.g., mobile-optimized) is another matter. Commented Jan 22, 2013 at 12:27
2

The only official intents documented are given here. They do not include directions.

It has been noted that the following intent structure works with Google Maps. It seems the current Google Maps ingests the google maps http requests. It is probably the method used by the apps you've seen. However, it likely only works with Google Maps, and since it appears to be undocumented, there is no guarantee it will continue to work with future version of Google Maps.

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://maps.google.com/maps?daddr=33.881894,-92.199623&saddr=My+Location"));

where daddr is the destination location, and saddr is the source location. They can either be lat/lng's or search terms. "My+Location" is a search term in the above example, so it unlikely to work in locales with a language other than English.

Not the answer you're looking for? Browse other questions tagged or ask your own question.