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]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]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Routing

This document describes how to use the routing feature in the Map control. This feature allows you to calculate either a route between locations or routes from major roads in four directions on a map.

The document consists of the following sections.

Expanded Overview

The Map control supports the popular Microsoft 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 routing functionality in the Map control is performed by the Bing Route data provider. This provider is represented by the BingRouteDataProvider object. The section below explains how to use the BingRouteDataProvider in the map control.

Expanded Enable Routing

To enable routing in the Map control, do the following.

The code snippet below shows how this can be done.

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 on the map.

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 optimal routes from major roads in four directions for a specified destination location (latitude and longitude coordinates).

For instance, you have a UI that consists of 2 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) is passed to its argument.

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

Expanded Routing Result

The results from the Bing Route service are stored by the RequestResultBase object's RouteCalculationResult descendant inside the BingRouteDataProvider.RouteCalculated event handler's BingRouteCalculatedEventArgs.

For instance, you can receive all information about calculated routes. To accomplish this, do the following.

Handle the BingRouteDataProvider.RouteCalculated event. The BingRouteCalculatedEventArgs.CalculationResult property of the event arguments allows you to get the required parameters of the route.

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?​​​​​​​