I\'ve worked with google maps before, but when implementing it, I\'ve never found any documentation on how to get the exact distance between 2 given locations via Javascript
This posting gives a way and a warning.
To break it down you use google maps to query a URL like this
http://maps.google.com/maps?q=from+A+to+B&output=kml
and then you view the data retrieved from that url (in kml format) and look at the placemark tags (run it through simplexml) each placemark tag will have a description child that will have a text description of the next step in the route from A to B.
Also mentioned in the article is that by using this method you are bound by the google maps T&C which states
Also, you may not use Google Maps in a manner which gives you or any other person access to mass downloads or bulk feeds of numerical latitude and longitude coordinates.
So you may want to keep that in mind.