Skip to main content
All docs

BingTrafficIncidentDataProvider Class

Allows you to receive information about traffic incidents within a specified area from the Bing Maps service and display incident icons on the map.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v23.1.dll

NuGet Package: DevExpress.Win.Map


public class BingTrafficIncidentDataProvider :


Follow the steps below to create a map with traffic incidents:

To include traffic location codes in the method’s result, enable the BingTrafficIncidentDataProvider.Options.IncludeLocationCodes property.

After you obtain a list of incidents, the provider raises the TrafficIncidentCalculated event. You can handle the event to access the collection of received incidents or add custom logic.


The following code displays traffic incidents that occur in the specified area:

A map that displays traffic incidents.

using DevExpress.Map;
using DevExpress.XtraMap;
using System;
using System.Windows.Forms;

namespace TrafficIncidents {
    public partial class Form1 : Form {

        private void Form1_Load(object sender, EventArgs e) {
            // Create and configure a background layer.
            ImageLayer imageLayer = new ImageLayer();
            BingMapDataProvider provider = new BingMapDataProvider();
            imageLayer.DataProvider = provider;
            provider.BingKey = "Insert your Bing Key.";
            provider.Kind = BingMapKind.RoadLight;

            // Create an information layer and add it to the map.
            InformationLayer infoLayer = new InformationLayer();

            // Create and configure a BingTrafficIncidentDataProvider. Assign it to the information layer.
            BingTrafficIncidentDataProvider trafficIncidentDataProvider = new BingTrafficIncidentDataProvider();
            infoLayer.DataProvider = trafficIncidentDataProvider;
            trafficIncidentDataProvider.BingKey = "Insert your Bing Key.";
            BingTrafficIncidentSeverity incidentSeverity = BingTrafficIncidentSeverity.LowImpact | BingTrafficIncidentSeverity.Minor | BingTrafficIncidentSeverity.Moderate | BingTrafficIncidentSeverity.Serious;
            BingTrafficIncidentType incidentType = BingTrafficIncidentType.Accident | BingTrafficIncidentType.Construction | BingTrafficIncidentType.Miscellaneous;
            trafficIncidentDataProvider.RequestTrafficIncidents(new SearchBoundingBox( -115.338457, 36.268745, -114.988268, 36.1010376),
            infoLayer.DataRequestCompleted += OnDataRequestCompleted;
        private void OnDataRequestCompleted(object sender, RequestCompletedEventArgs e) {
            // Call the ZoomToFitLayerItems method to zoom the map so that it displays the obtained incidents.


See Also