Calculating long routes with Bing Maps V7

In the Bing Maps v7 control there is the Directions module which allows you to calculate a route with up to 15 waypoints and also generate a nice UI of the resulting directions. Before this module we would have to access the Bing Maps Routing REST service directly to calculate routes. For some this may be still may be the preferred method of requesting routes. The REST services allow you to calculate routes with up to 25 waypoints. In some situations support for routing between a larger number of waypoints may be required. This is where this module comes in. It wraps the Bing Maps Routing REST service and allows you to calculate a route with an unlimited number of waypoints. It accomplishes this by breaking the waypoints into batches and matching multiple routing requests. The results are then merged together into one route response.

This module is easy to use and has two public methods; GetRoute and IsProcessing. The GetRoute method takes in an array of waypoints, a Bing Maps key, a set of route options and a callback method. The IsProcessing method simply checks to see if the RouteServiceHelper class is processing a calculating a route.

This module, along with complete source code and an example implementation can be downloaded here. This module is part of the Bing Maps v7 Module community project on CodePlex, check this project out for other cool and useful Bing Maps v7 modules..

Below is an example of a route with 32 waypoints that was generated using this module.


Currently this module is limited to driving and walking directions, transit directions are not supported. User context information and route tolerances are also not supported. If this functionality is required outside of the Bing Maps V7 control the code in this module can easily be adopted to work on its own in other programming languages. This may be useful in cases where this functionality is needed in backend systems.

8 thoughts on “Calculating long routes with Bing Maps V7

  1. Hi,
    Thanx for nice solution and code,
    1) I’m trying to eliminate “Calculate Route” button click so that page can display Route on very first page load by calling CalculateRoute() in function GetMap() ‘s last line. but getting error “RouteServiceHelper” not Initialized.
    How I can achieve this functionality?

  2. Good article!
    Thanks for taking the time to always provide us with the latest update to Bing Maps V7. I just started diving into this a few months ago, and your blogs have been very helpful. Is this the same directions module that puts cool icons in a sidebar for each step of a route?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s