Issue
I am using google maps intent to get directions. The problem is that the directions come up with whatever the last type of directions I searched on the google maps app.
For example if i used google maps to get walking directions last, when i use my app the directions will automatically search walking directions.
I want to give the user the ability to choose their direction type.
Here is a code snippet:
String directions = "http://maps.google.com/maps?saddr=" + myLocationString + "&daddr=" + officeLocationString;
// Create Google Maps intent from current location to target location
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(directions));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
fcontext.startActivity(intent);
Solution
Edit: As of January 2013, the Google Directions API has updated and the results are now provided in JSON. The URL format now looks something like this:
http://maps.googleapis.com/maps/api/directions/xml?origin=Chicago,IL&destination=Los+Angeles,CA&waypoints=Joplin,MO|Oklahoma+City,OK&sensor=false
More info is available here.
Adding the directionsmode
parameter to your URI should do what you're looking for.
From the URL scheme docs:
directionsmode: Method of transportation. Can be set to: driving, transit, or walking.
So perhaps you could try something like:
String directions = "http://maps.google.com/maps?saddr=" + myLocationString + "&daddr=" + officeLocationString + "&directionsmode=" + directionsMode;
Answered By - Ben Siver
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.