The Google Directions API

The Google Directions API is a service that calculates directions between locations using an HTTP request.

Note the following:

This service is generally designed for calculating directions for static (known in advance) addresses for placement of application content on a map; this service is not designed to respond in real time to user input, for example. For dynamic directions calculations (for example, within a user interface element), consult the documentation for the JavaScript API V3 Directions Service.

Still, by using the Google Directions API, you can get directions through putting URLs into the address bar on JSON or XML format. Here are som tests:

Home to Purpose:
http://maps.googleapis.com/maps/api/directions/json?origin=519+5th+st,+brooklyn,NY&destination=224+centre+st,NY&mode=bicycling&sensor=false

Home to Purpose – via Brooklyn bridge using waypoints:
http://maps.googleapis.com/maps/api/directions/json?origin=519+5th+st,+brooklyn,NY&destination=224+centre+st,NY&waypoints=brooklyn+bridge,NY&mode=bicycling&sensor=false
…though this breaks the route into two legs, and the directions says “destination will be on your left” also when I’m on Brooklyn Bridge…

Home to Purpose – alternative routes:
http://maps.googleapis.com/maps/api/directions/json?origin=519+5th+st,+brooklyn,NY&destination=224+centre+st,NY&alternatives=true&mode=bicycling&sensor=false

XML instead of json (json is recommended though):
http://maps.googleapis.com/maps/api/directions/xml?origin=519+5th+st,+brooklyn,NY&destination=224+centre+st,NY&mode=bicycling&sensor=false

This was the service I used when getting directions for the Low-fi prototyping, part II, which I then turned into a text file ready to be read by the guy from Speak It!

Some issues:

  • The directions do not seem to have information about bike path/lane in Google Maps. The Ride the City app does have this information.
  • For knowing the user’s current location, we might need to use the Official Google JavaScript API.

Comments are closed.