Home AI Smarter Location Services With The Bing Maps APIs

Smarter Location Services With The Bing Maps APIs


Bing Maps has a range of new APIs that give you everything from travel times to truck routes. It has also improved the coverage of many of its REST services so they have information for more parts of the world.

The new Distance Matrix API is available for calculating not just the distance between two locations but how long it will take to get there, whether you’re driving, working or talking public transport. That includes how long traffic is likely to add to the journey, based on the date you choose for the journey (travel time is calculated in 15 minute intervals), and you can choose points of interest like hotels as the locations, not just specific addresses. This is available for most of the 174 countries where Bing Maps supports routing (not just the 55 countries with traffic coverage).

The Distance Matrix API shows travel times between locations with predicted traffic (Source: Microsoft)

You can plug the information into existing algorithms like traveling salesperson and fleet vehicle routing problems, optimising routes for single drivers or an entire fleet of vehicles. That includes things like calculating the best time of day to make deliveries, or the best locations for pickups and deliveries, as well as planning vehicle capacity and whether trucks are going back to the depot without a load, as well as working out whether to split deliveries or hold onto one package for a customer until the rest of their order is ready because – sometimes, traffic will mean the second driver will arrive with the rest of the order not long after the driver who left earlier but was stuck in traffic.

“You can use it to determine arrival times based on travel times, so you can ask questions like ‘when will my pizza arrive?’,” senior program manager for Bing Maps Ricky Brundritt told Grey Matter. If you’re already using Bing Maps services to retrieve travel time information, as some large delivery services do, the Distance Matrix API means you get more accurate results, more efficiently. “You’ll use less bandwidth because you’re just getting a time and a distance back, not a massive response [that you have to extract that from], so this is a speedup for them.”

Or you could sort a list of locations to see how convenient they are to get to, clustering them by travel time rather than just how far away they are. That could help you decide between possible locations for new shops and stores, or see what impact moving to a new office location would have on the commute time of your staff.

A number of other Bing Maps APIs only covered the US while they were in preview but will be available for more countries now they’re launched. The truck routing service calculates routes for commercial vehicles, taking into account the length, width, height, axle weight and maximum weight of trucks, hazardous cargoes, tunnel restrictions, number of trailers and other things that you don’t have to worry about with the average car. The number of countries in which Bing Maps has good routing coverage now stands at 80.

 A new Local Insights API is in the pipeline too. Initially it will only cover the US, but in time it will expand to more countries in time, letting you create a custom list of points of interest and score locations for how many of those are nearby. That’s useful for planning for real estate and business locations, especially combined with the new Isochrone API, launching around the same time and covering the same countries as the Distance Matrix APIs. This produces a travel-time polygon using traffic prediction, which makes it easy to see the distance you can travel in a certain time by driving, walking or using public transport.
The Isochrone API shows how far you can travel in a set time, again with predictive traffic (Source: Microsoft)

“Where can I get from here if I go fifteen minutes in every direction?” Brundritt explains. That’s useful for a wide range of scenarios, from asset tracking. “A common one is stolen vehicle recovery: someone stole my truck, where could it have gone in the last 30 minutes? There’s real estate: Propertywide in the UK has travel time map search; you can say ‘I work here, I want to take public transport and not travel more than 30 minutes’ and you can do it for your spouse as well. There are other areas like law enforcement, school zone and bus planning, dating and job search sites…” He notes that LinkedIn has already started using the API while it’s in preview to show available jobs within a certain travel time. You can also use it to decide where to place triggers for geofencing, so you get alerts when someone is 15 minutes away – which is more useful than knowing how far away they are.

In spring 2018, Bing Maps will offer a Time zone API that lets you look up what time zone any location is in, with the current time and an offset to show daylight savings time, plus metadata about the time zone and the polygon boundary for where that time zone covers.

The Bing Maps v8 Web control continues to add new features; the latest are custom maps styles, to give maps your own look and feel, and the GeoXml module that lets you import and export KML, KMZ, GPX, GeoRSS, and GML data with very little code required. The recent Fall Creators Update version of the Windows 10 UWP control for building maps into your apps also adds support for layers, the Place Info API and custom 3D models in the 3MF format for buildings and vehicles, as well as improvements to the 3D buildings shown on maps.

The new time zones API returns the current time, DST offset and time zone for a specific location (Source:Microsoft) 

Microsoft has also recently open sourced several Bing Maps projects, like a repo of 200 code samples for the Bing Maps v8 control and a REST Toolkit for .NET. The new Spatial Data Services toolkit simplifies using these somewhat demanding APIs with .NET. The REST toolkit for .NET released in January already serves over 200 million requests a month for the Bing Maps APIs and Brundritt expects this will be just as popular. “The spatial data services are extremely complex to develop again on their own and this will make it a lot easier. If you want to do something as simple as geocoding a file and uploading it, it takes three lines of code [with the toolkit], as opposed to several hundred lines of code before.”

The recently released Truck Routing API is an open source vehicle tracking system that includes truck routing, geofences so you can trigger alerts when a vehicle enters or leaves an area, and analytics. At the moment it uses mobile devices to track vehicle location and the team is looking at supporting OBD-II (on-board diagnostics) connections to get readings like mileage directly from vehicles. “One day it might be a one-click solution for basic scenarios, but for now this is a starting point for our partners who want to work in this area but don’t have the knowledge so they have to pass up the work.”

Project Hurghada is an open source project for asset tracking and transit planning (Source: Microsoft)

There are more open source projects on the roadmap too; that might include a Maps Spatial Toolbox to simplify importing various spatial file formats into Bing Maps for multiple platforms including Windows 10, and open modules for extra functionality with the v8 control. Modules mean you can load just the code for the Bing Maps functionality that you want, which speeds up page load times. “With open modules, the idea is let’s take the module framework and make it so anyone can extend it.” Some of the modules Microsoft created with the development community for Bing Maps v7 have become features in the v8 control; others will be distributed through GitHub so they’re available to developers, like a solar terminator showing the shadow of the sun. That will give you yet another way to extend Bing Maps to give you the features you need for your apps.

Want to learn more about the Bing Maps APIs? Please call the Grey Matter mapping specialists:

+44 (0)1364 655 133 or email: mapping@greymatter.com

All images credit: Microsoft


Find out more about how Grey Matter Ltd can help you with this subject. Send us a message:

By completing this form you are agreeing to our Privacy Notice.

Previous articleWelcome To Code Matters
Next articleBing APIs let you pick and choose the search you want
Mary Branscombe has been a technology writer for more than two decades, covering everything from early versions of Windows and Office to the first smartphones, the arrival of the Web and most things in between, including enterprise architecture and cloud services. She also dabbles in mystery fiction about the world of technology and startups.