The following link shows how to add polylines to a map.
https://developers.google.com/maps/documentation/android/lines
But how do we get these to snap to the closest street? It is possible in javascript implementations of maps, as shown here:
http://econym.org.uk/gmap/example_snappath.htm
Thanks
You cannot do that on default maps. you can do that only when you have the vector data of the streets, and you will not get them from tomtom(teleatlas) or nokia(navteq).
You can do that only for maps where vectors are available, e.g OpenStreetMap.
That what you showed in the link, is another thing:
They got the unsnapped start and end position that the user clicked, and passed that to google web service, which did first snap start and end to the nearest road, then calculated the route, and google drawed the route on its map. So i assume they even did not draw a polyline, they used only the google web service.
Since GPS receivers are today very accurate (3-6m) it is not neccessary any more to snap to next road. Further such snapping introduces errors, when driving on a road that does not exist on the map.