Driving Directions Support Added to the Google Maps API

Tuesday, May 29, 2007 at 3:09:00 PM


This morning, we updated the Google Maps API to add support for driving directions. The simplest way to add driving directions to your page is to create a map, create a DIV for the directions panel, attach both of them to the new GDirections object, and fire off a query to it!

var map = new GMap2(document.getElementById("map"));
var panel = document.getElementById("panel");
var dir = new GDirections(map, panel);
dir.load("San Francisco to Los Angeles");

In addition to the simple API above, the GDirections API provides richer ways of interacting with the driving directions to allow you to build your own directions panel in whichever way you'd like. Some cool features of the API are:

  • You can request directions between a pair of points or a longer sequence of points. Multi-point directions are requested using an array of endpoints to GDirections.loadFromWaypoints()
  • You can request results in multiple languages. We support most major languages including English, French, Spanish, German, Italian, Japanese, and more.
  • You can fine-tune responses for your application by choosing to request only the directions text or the polyline for the route.
  • The API is available for directions in the US, Canada, France, Germany, Italy, Spain, and Australia. More countries will be added as Google Maps launches in new countries.
  • Unfortunately, you can't route from New York to Paris. But perhaps you can make a mashup that gives a better suggestion than "Swim across the Atlantic Ocean."

For now, directions requests are limited to 10,000 requests per day per API key. Since this is a new service, we've set a conservative limit and will reassess as usage picks up. For more information on the directions API, check out the documentation. As always, we welcome your feedback. Meanwhile, here is a demo of GDirections for your enjoyment! (courtesy Chris Schalk, Developer Programs)