Calculate Distances Intelligently With The Google Distance Matrix API

Allen Tipper, July 22nd, 2011

Google MapsThe Google Maps API naturally has a rich history on ProgrammableWeb. Over the last year or so, Google has released additional maps-related APIs as separate services. One of the latest ones is the Google Distance Matrix API. This allows a developer to submit a matrix of locations, as origins and destinations, and get a list of the distances in return.

The search giant says this about its API in the documentation:

The Google Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations. The information returned is based on the recommended route between start and end points, as calculated by the Google Maps API, and consists of rows containing duration and distance values for each pair.
This service does not return detailed route information. Route information can be obtained by passing the desired single origin and destination to the Directions API.

As we always expect of Google, the API returns data in the standard formats, JSON and XML, and is RESTful like most good APIs. This is exactly the API one would use to try to solve the classic “traveling salesman problem” in real life. One could use this in a lot of applications, especially in applications already using the Google Maps API and the Google Directions API in fun ways. Below is an example of the Google Distance Matrix in action.

Google Distance Matrix

This API requires no API key, but does have some basic transaction limits. It solves a simple problem that developers may want to solve often, and it does it elegantly. I’d expect nothing less from the King of Search and the creator of the most popular mapping API by far.

Both comments and pings are currently closed.

One Response to “Calculate Distances Intelligently With The Google Distance Matrix API”

August 7th, 2011
at 12:29 pm
Comment by: K.SIVA

I Like Google Maps An WikiMapia & WikiPidia,WikiMidiya And All Over The World Service InCuluding To All Service Ext….Tanks For ++K.Sivade France ++

Follow the PW team on Twitter

ProgrammableWeb
APIs, mashups and code. Because the world's your programmable oyster.

John Musser
Founder, ProgrammableWeb

Adam DuVander
Executive Editor, ProgrammableWeb. Author, Map Scripting 101. Lover, APIs.