Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

BingTrafficIncidentDataProvider.RequestTrafficIncidents(SearchBoundingBox, BingTrafficIncidentSeverity, BingTrafficIncidentType) Method

Requests incidents for the specified region.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v24.2.dll

NuGet Package: DevExpress.Win.Map

#Declaration

public void RequestTrafficIncidents(
    SearchBoundingBox boundingBox,
    BingTrafficIncidentSeverity severity,
    BingTrafficIncidentType type
)

#Parameters

Name Type Description
boundingBox SearchBoundingBox

Limits the area for which traffic incidents are requested.

severity BingTrafficIncidentSeverity

Specifies the severity level of incidents.

type BingTrafficIncidentType

Specifies the type of incidents.

#Example

#How to: Display Traffic Incidents on the Map

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();
            mapControl1.Layers.Add(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();
            mapControl1.Layers.Add(infoLayer);

            // 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),
                                                                incidentSeverity,
                                                                incidentType);
            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.
            mapControl1.ZoomToFitLayerItems();
        }
    }
}
See Also