What is the Distance Matrix?
May 5th, 2011 | Published in Google Maps
When I was young, I often found myself on long car journeys with nothing to occupy me but a dog-eared UK road atlas. On the back page, there was a chart that showed the driving distance and journey time between pairs of major cities, and I would amuse myself figuring out which pair was furthest apart, and how long it takes to drive the length and breadth of the country.
Thanks to the new Distance Matrix service, which we are launching today, I can now relive these moments from my youth. The Distance Matrix service is a simple and efficient way to obtain the travel distance and time between many locations when you do not need the full route details for any individual pair. The below applications generates a distance matrix for walking from major London railway stations to several London landmarks. Roll your mouse over the matrix cells, or tap a cell, to see the relevant route.
The Distance Matrix service is also useful for sorting or filtering search results. For example, let’s say your Maps API application enables users to find nearby grocery stores and you want to present the results sorted by drive time. The locations are stored in a spatial database such as Google Fusion Tables, which can return all stores within a given straight line distance. Using the Distance Matrix service you only need one more query to obtain the drive time from the user's location to each of those stores in order to sort them accordingly.
The Distance Matrix service is available for use directly in the JavaScript Maps API as well as a web service returning JSON or XML. To get started, take a look at the Maps API services documentation, and the Distance Matrix API web service documentation. If you need further assistance, you can also discuss this service with fellow Maps API developers in the Maps API forums.