Google Maps Android: How Do I Add Driving Or Walking Directions To A Specific Geopoint With A Button Onclick?
Solution 1:
There is no support in the Android SDK for driving directions, sorry.
Solution 2:
The easiest option would be to link out to the Google Maps application. The URL below will handle that.
Uri uri= Uri.parse( "http://maps.google.com/maps?saddr=" + startLocation.getLatitude() + "," + startLocation.getLongitude() + "&daddr="+mapItem.lat + "," + mapItem.lon );
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
mActivity.startActivity(intent);
Also check out this page for all the options in the maps url:
http://www.seomoz.org/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters
Solution 3:
I did this for an app at work.
I think your best bet is to use a MapView and with a Canvas draw a route over it.
To get the route, as have been pointed out, there is no native way in the Android SDK. So I would go for a public web service that does this for you. In my case, I used Google Directions API: https://developers.google.com/maps/documentation/directions/
It will give you step by step navigation from and to coordinates you give it. Steps include coordinates for each point and descriptions (i.e. continue in Foo Street 100 meters and then turn right towards Bar Street). You can use that to paint the route over a MapView (connecting the dots with lines...) and show written (or even spoken) directions. Check the documentation.
It gives you a lot of points in turns and curves. So it will look good even in roundabouts.
That will do it if you need to do it in your app. This worked perfectly for me.
And of course, as atreat has shown, you can use public intents enabled for this from apps of thirds (Google Maps Navigation...).
Post a Comment for "Google Maps Android: How Do I Add Driving Or Walking Directions To A Specific Geopoint With A Button Onclick?"