Using Google Maps Directions in Android App

Go To StackoverFlow.com

0

I'm trying to develop an Android App to go with my web app www.scroutenise.com, so I made a backend API to mimic the behaviour of the Javascript app which returns

  1. A Google Maps DirectionsResult
  2. A bunch of Google Maps Places

Both are in the same format provided by the Google Maps API. Great - with JS I can easily render this on a Google Map.

So far in my App I'm successfully communicating with the API and getting the full results - keep in mind the API is a WebSockets API so there's no URL - and I've got a Google Map showing.

The only thing I can't find documentation or tutorials for is how to display directions on the map. I'm sure I could figure out how to place Markers, but the directions aspect is a pretty important aspect of my app. Is it even possible? Are there some Ts&Cs that Google has to stop people from making a directions-related app?

Thanks for reading, I hope somebody can help :)

2012-04-04 21:13
by basicallydan


1

I don't get what you means by directions here, But you can draw path using the way described in this post.

http://csie-tw.blogspot.com/2009/06/android-driving-direction-route-path.html

2012-04-04 21:55
by andunslg
This will do I suppose, as it seems showing directions on a map automatically is not supported. Thanks - basicallydan 2012-04-08 19:40


4

In Android, you can specify driving directions through the use of an Intent:

String geoUriString = "http://maps.google.com/maps?" + 
   "saddr=" + srcLat + "," + srcLng + "&daddr=" + dstLat + "," + dstLng;

Intent mapCall = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUriString));

Then based on the apps installed on your device (navigation, maps, etc) the user will be able to receive directions from one of those apps.

2012-04-05 01:40
by javram
I actually wanted to include the directions within my app, but thank you - basicallydan 2012-04-08 19:40
How to add Directions from a Lat Long to the location of the USE - Harsha M V 2013-01-21 19:32


0

String uri= "https://www.google.com/maps/dir/" + 
    fromLat + "," + fromLng + "/" + toLat + "," + toLng;

Intent mapCall = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));

OR only location of "to" and user must turn on GPS:

String uri= "https://www.google.com/maps/dir//" + toLat + "," + toLng;

Intent mapCall = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
2015-11-24 08:31
by NickUnuchek
Ads