Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Collapse]Map Control
   [Expand]Getting Started
    Layers
   [Expand]Coordinate Systems
   [Expand]Map Image Data
   [Collapse]GIS Data
     Search
     Geocode
     Routing
     Elevation
   [Expand]Vector Data
   [Expand]Visual Elements
   [Expand]Examples
   [Expand]End-User Features
   [Expand]Product Information
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Routing

The Map control supports Microsoft's Bing Route service. This service provides the most optimal route, either from major roads in four directions, or calculated between two or more locations on a map.

The Bing Route data provider provides the Map control's routing functionality and is represented by the BingRouteDataProvider object. The sections below explain how to use the BingRouteDataProvider in the map control.

Important

Due to Bing canceled the SOAP service on July 30, the Map Control's Bing Routing provider does not work properly in versions earlier than 16.1.

Expanded Enable Routing

Do the following to enable routing in the Map control:

The code snippet below shows how to do this.

There are two ways to use the map routing feature in your application, depending on your task:

  • Calculate a route between two or more locations on a map;

  • Get a route from major roads to the specified destination.

The sections below describe each approach.

Expanded Calculate a Route between Locations

When the Map control is connected to the Bing Route service (see the section above for details), you can calculate a route between two or more locations on a map. To accomplish this, call the BingRouteDataProvider.CalculateRoute method and pass the list of locations (waypoints) as its argument, as shown below.

The image below shows the calculated route between the specified locations on the map.

Expanded Calculate Routes from Major Roads

The Map control allows you to obtain different routes to a specified location (latitude and longitude coordinates) using major roads from the north, east, south, and west. If it cannot find major roads coming from these directions, the response may contain more than one route from the same direction or fewer than four routes.

For instance, an application UI contains two text boxes named "tbLatitude" and "tbLongitude", and a button named "calculateRoutes".

To start a route calculation, click the Calculate Routes button. This calls the BingRouteDataProvider.CalculateRoutesFromMajorRoads method and a destination location (waypoint coordinates and description) and options are passed to its argument.

The results for San Francisco (Latitude - "37.783333" and Longitude - "-122.416667") are shown in the image below.

Expanded Routing Result

The RouteCalculationResult object that is provided by the BingRouteDataProvider.RouteCalculated event handler arguments' BingRouteCalculatedEventArgs.CalculationResult stores the route calculation results from the Bing Route service.

For instance, you can access a route path between locations calculated in the Calculate a Route between Locations section of this document.

To accomplish this, handle the BingRouteDataProvider.RouteCalculated event.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E5064.

The result is shown in the image below.

Expanded Examples

Expanded See Also

How would you rate this topic?​​​​​​​