Google Maps API v3 Now Includes Driving Directions

Google continues to expand its third version of the maps API to include features already in the second version. Most recently, they've added driving directions, which gives programmatic access to the routing data between two points. As with the rest of Maps V3, which was released in May, the team took a fresh approach, so some interfaces have changed.

We've split the GDirections object from v2 into two separate classes that work together to give you routing goodness. DirectionsService passes directions queries to our server and returns the results in JSON format, while DirectionsRenderer displays the results on your map. The 'load' event from v2 has been removed; instead, a callback function containing your rendering code is passed to the DirectionsService when making a new query.

The result is the data is simpler for a developer to access, while also providing options to make it easy to display the directions with the default look. Multiple routes, a feature available in Google's flagship map site, is also available in the new version of the directions API. Oh, and want those results in metric? You got it.

Google Maps V3 Driving Directions API

Somehow they've managed to fit in more features when the apparent motto of V3 has been less. To get a feel for the code, view the source of the new directions examples or check out the directions section of the reference guide.

Maps V3 was built with mobile applications in mind. As such, it is meant to be focused on speed, which means not every Maps V2 feature is supported (and even then, sometimes not the same way). Google is still supporting both versions, which means developers have a choice (or have to choose depending on how you look at it), which version to support. The open source wrapper API Mapstraction (our Mapstraction API profile) could help smooth the transition (disclosure: I am a project contributor).

The addition of driving directions to the V3 suite of features is a welcome sign that Google may be getting ready to make clear the future of its powerful map API.

Be sure to read the next Mapping article: Visit Your Favorite Twilight Locations on a Bing Map


Comments (9)

[...] has added new takes on V2 services to the V3 API, such as driving directions in November. Recently, new features, like elevation data, have come to only V3, which prompted us to write that [...]

Good Lord...I've been trying to find driving directions for 2 hours, but always reach a dead end. It shouldn't be too difficult.

I want the shortest route, using US 32 (Appalachian Corridor) across Ohio from 228 Pike Street in Marietta. to Christina Holmes Memorial Hospital, 231 Albert Sabin Way, Cincinnati,Ohio 45267-2827. Can you help me? At least give me a clue what to do. I've tried Google, MapQuest, Rand McNally, etc........

someon know how to change the image from the markers A and B from the panel ? I tried and found this way, but exist another way ?


setTimeout('$("#directionsPanel div div table tbody tr td img").attr("src", "_layouts/Map/images/markers/house.png")', 90);

setTimeout('$("#directionsPanel div div div table tbody tr td img").attr("src", "_layouts/Map/images/markers/tree.png")', 100);


One help please. If I want the main areas coming between the route when direction is found can I get through this API. For eg. In my application user input place A and place F and clicks on "Get Directons", he gets the route where B, C, D comes in between. Will my application by any how be able to retrieve all these values as B,C,D? Thank you for Tutorial.


Anyone have problems with setPanel displaying in gray? When I try to use one address twice, the fist time the text is displaying correctly in the panel, the second time only shows a gray box. Only happening in FF 3.6.

I don't see the alternative to the ‘load’ event which has been removed. Could you make an example? Thanks.