[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Collapse]Map Control
   [Expand]Getting Started
    Layers
   [Expand]Coordinate Systems
   [Expand]Map Image Data
   [Expand]GIS Data
   [Expand]Vector Data
   [Expand]Visual Elements
   [Expand]End-User Interaction
   [Collapse]Examples
    [Expand]General
    [Expand]Map Image Data
    [Collapse]GIS Data
     [Expand]Searching
     [Expand]Geocoding
     [Expand]Routing
     [Expand]Elevation
     [Collapse]Using all GIS providers
       How to: Implement a Route Calculator Using GIS Providers
    [Expand]Vector Data
    [Expand]Printing and Exporting
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Implement a Route Calculator Using GIS Providers

This example demonstrates how to create a calculating routes application using GIS services.

Follow the steps below.

  • Add an ImageTilesLayer object to the MapControl.Layers collection and assign an instance of the BingMapDataProvider class to the ImageLayer.DataProvider property. Specify the valid Bing key using the BingMapDataProvider.BingKey property.
  • Add a VectorLayer object to the MapControl.Layers collection and assign a MapItemStorage object to the VectorLayer.Data property.
  • Add an InformationLayer object to the MapControl.Layers collection and assign an instance of the BingSearchDataProvider to the InformationLayer.DataProvider property. Create a handler of the BingSearchDataProvider.SearchCompleted event. Specify the valid Bing key using the BingMapDataProviderBase.BingKey property.
  • Add an InformationLayer object to the MapControl.Layers collection and assign an instance of the BingGeocodeDataProvider to the InformationLayer.DataProvider property. Create a handler of the BingGeocodeDataProvider.LocationInformationReceived event. Specify the valid Bing key using the BingMapDataProviderBase.BingKey property.
  • Add an InformationLayer object to the MapControl.Layers collection and assign an instance of the BingRouteDataProvider to the InformationLayer.DataProvider property. Create a handler of the BingRouteDataProvider.RouteCalculated event. Specify the valid Bing key using the BingMapDataProviderBase.BingKey property.
  • For each information layer data provider set the InformationDataProviderBase.GenerateLayerItems property value to False.

    The following XAML demonstrates this in code.

  • Create a helper class, which allows you to convert MapPushpin objects to RouteWaypoint and store the route using a MapPolyline object. Create a private member of this class in the MainWindow class.

  • Handle BingSearchDataProvider.SearchCompleted, BingGeocodeDataProvider.LocationInformationReceived and BingRouteDataProvider.RouteCalculated events. Also handle the MapPushpin.MouseLeftButtonDown event to add a location to waypoints.

Note

If you run the application, and see a window with the following error message: ”The specified Bing Maps key is invalid. To create a developer account, refer to https://www.microsoft.com/en-us/maps/create-a-bing-maps-key”, refer to the following tutorial: How to: Get a Bing Maps Key.

Expanded See Also

Is this topic helpful?​​​​​​​