***Updated July 15, 2022***
At Microsoft Ignite we announced the Bing Maps Distance Matrix API solution, a service that provides travel time and distances to and from a set of origins and destinations. We are happy to announce that it is now available for general use!
Looking to develop a solution for a Travelling Salesman Problem (TSP) or Vehicle Routing Problem (VRP)? The Bing Maps Distance Matrix API service assists in calculating travel time and distances in many-to-many scenarios with an optional travel-time histogram. The Distance Matrix API can help answer questions as varied as where a commercial bakery should open their next location to optimize daily deliveries or helping a school district select the optimal pick up locations for their fleet of school buses.
How it works
The Bing Maps Distance Matrix API calculates the distances and times based on the routes calculated by the Bing Maps Route API. Times are based on predictive traffic information, depending on the start time specified in the request. Bing Maps API’s distance matrices to and from locations are calculated for different modes of transportation, such as driving, walking and public transit routes.
As addition to being used as a distance calculator, this API can also be used to generate an optional histogram of travel times over a period of time with a set interval. These calculations take into consideration the predicted traffic at those times
Below is a screenshot from our travelling salesman demo, including the travel-time histogram:
Bing Maps API’s distance matrices to and from multiple locations are used in several applications. Some common examples include:
- Sorting search results by their actual travel distance or time.
- Determining arrival times based on travel times.
- Calculating the difference in commute times between locations. For example: We are looking to move to a new office, what is the impact on commute times for our staff?
Calculating a route with traffic data
Using the Bing Maps Distance Matrix API, you can calculate a route using traffic data to determine a distance matrix based on travel time or distance for many scenarios, such as store locators, job search sites, location scoring, and more. Whether you’re looking up the commute distance to work or the travel time from home, Bing Maps API makes these calculations effortless.
In the first image below, location one is clearly closer than location two visually on a map; however, in calculating time and distance, the second location is actually a shorter distance away and takes less driving time than location one.
A developer-friendly API
Even if you haven’t used other Bing Maps APIs before, it’s easy to jump in and make the most of the Distance Matrix API. We provide free code samples, developer documentation, and even a lively forum to flatten the learning curve and speed up development cycles.
Say you’d like to perform a simple distance calculation with Bing Maps API to and from a set of origin and destination coordinates. Getting a quick response from the API is as easy as sending out a single line of code:
The HTTP GET request URL specifies the set of coordinates, as well as the mode of travel. In this case, the API will calculate travel times and distances for driving. It’s worth mentioning that the Bing Maps API also supports to and from distance calculations for other modes of travel such as walking or public transit.
Once the request has been sent out, here’s what a typical JSON response would look like:
"copyright": "Copyright © 2017 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
These concise responses remove any ambiguity and make it effortless to work with complicated sets of locations. Responses in XML are also supported. Visit our example documentation to take a look at other distance calculation scenarios with the API.
Customer Story: Distance Matrix API For Commute Analysis
Whether it’s to and from distance calculations or itinerary optimization, Bing Maps API helps businesses solve everyday problems with actionable business insight. There’s no better way to understand how Distance Matrix API can make life easier for business owners than with a practical example.
In search of the ideal place for collocation, a Microsoft subsidiary turned to the Distance Matrix API for an answer. The perfect location had to be a viable commute for all the employees involved, and so they needed an API that could calculate distances and travel times with a high degree of accuracy.
As it turns out, the API was the right choice for the job. After a quick anonymous survey of addresses, the team was able to use Bing Maps API’s features to quickly calculate the average distance traveled to and from the office, as well as the difference in travel time during rush hour.
Ultimately, the team used this data to narrow down their options and pick an office that would cut down average commute times. For a more detailed look at the solution, head over to our case study.
To learn more about travel time and distance calculations with the Bing Maps REST Service, view the API documentation. Coverage for Bing Maps Distance Matrix API is available in most places where Bing Maps supports routing. For details on coverage, please refer to the documentation.
Additionally, take a look at this project on GitHub, as it makes it easy to use the Bing Maps Distance Matrix API in .NET , including examples for multiple to and from location calculations.. For more information on the Bing Maps Distance Matrix API, how to get licensed, and frequently asked questions, visit our website.
We are always working to improve upon our APIs and look forward to seeing how people use the API and getting your feedback. Connect with us on the Windows Maps Forum to share your thoughts and let us know what you would like to see in future versions.
To get started with Distance Matrix and other exciting APIs, create your free Bing Maps API key today.
- Bing Maps team
In what ways can requests be made to the API?
The Bing Maps Distance Matrix API supports calculations to and from multiple locations in two ways. Most of these requests can be sent synchronously via. GET or POST. For a look at asynchronous requests with the API, check out our async documentation.
When should I use synchronous requests?
Synchronous requests are ideal if your mode of travel is walking, driving, or transit, and if the number of origin-destination pairs is less than or equal to 2,500 (for Basic keys) and 10,000 (Enterprise keys).
If your mode of travel is driving and the number of location pairs exceeds 10,000 as an Enterprise user, sending an asynchronous request might work best. If your particular use case doesn’t fit into either of these scenarios, consider breaking your requests into smaller chunks for a smoother experience. Head over to our documentation for a detailed look at these scenarios.
Can the API be used for calculations over a period of time?
Bing Maps Distance Matrix API can also calculate histograms of travel times and distances to and from a set of locations over a period of time, including predictive traffic data. Developers will also be able to specify the intervals used in these histograms. For an example, consult the histogram documentation.