Google Maps API v3 Now Includes Driving Directions

Adam DuVander
Nov. 23 2009, 03:57AM EST

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.

Adam DuVander Hi! I'm Developer Communications Director for SendGrid and former Executive Editor of ProgrammableWeb. I currently serve as a Contributing Editor. If you have API news, or are interested in writing for ProgrammableWeb, please contact editor@programmableweb.com Though I'm a fan of anything API-related, my particular interest is in mapping. I've published a how-to book, Map Scripting 101, to get anyone started making maps on websites. In a not-so-distant past life I wrote for Wired and Webmonkey.

Comments

Comments(9)

User HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

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 ?

directionsRenderer.setPanel(document.getElementById('directionsPanel'));

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);

Hey,

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.

Hi

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.