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