Skip to main content
All docs
V24.2

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.Xpf.Map

Assembly: DevExpress.Xpf.Map.v24.2.dll

NuGet Package: DevExpress.Wpf.Map

Declaration

public class BingTrafficIncidentDataProvider :
    BingMapDataProviderBase

Remarks

Important

On May 21, 2024, Microsoft announced that Bing Maps for Enterprise and its API will be discontinued. Azure Maps will be a single unified enterprise mapping platform available from Microsoft.

We are working on API compatible with Azure Maps and expect to ship it with our next major release (v24.2).

If you have an existing license to Bing Maps for Enterprise, you can continue using our existing API. You need to transition to new API until June 30, 2025 (free and basic license) or until June 30, 2028 (enterprise license).

The last date you can get a new license to Bing Maps for Enterprise is June 30, 2025. If you do not have an existing license after that date, you would not be able to use our map controls with Bing Maps or Azure Maps (until we release the new API). During that time, you can use other map providers supported by our controls, such as OpenStreetMap.

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.

Example

How to: Display Traffic Incidents on the Map

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

A map that displays traffic incidents.

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TrafficIncidents"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map" x:Class="TrafficIncidents.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800" Loaded="OnWindowLoaded">
    <Grid>
        <dxm:MapControl x:Name="mapControl">
            <dxm:ImageLayer>
                <dxm:BingMapDataProvider BingKey="Insert your Bing Key." 
                                         Kind="RoadLight"/>
            </dxm:ImageLayer>
            <dxm:InformationLayer DataRequestCompleted="OnDataRequestCompleted">
                <dxm:BingTrafficIncidentDataProvider x:Name="incidentProvider" 
                                                     BingKey="Insert your Bing Key." />
            </dxm:InformationLayer>
        </dxm:MapControl>
    </Grid>
</Window>
using DevExpress.Xpf.Map;
using System.Windows;

namespace TrafficIncidents {
    public partial class MainWindow : Window {
        private void OnWindowLoaded(object sender, RoutedEventArgs e) {
            BingTrafficIncidentSeverity incidentSeverity = BingTrafficIncidentSeverity.LowImpact | BingTrafficIncidentSeverity.Minor | 
                                                                BingTrafficIncidentSeverity.Moderate | BingTrafficIncidentSeverity.Serious;
            BingTrafficIncidentType incidentType = BingTrafficIncidentType.Accident | BingTrafficIncidentType.Construction | 
                                                        BingTrafficIncidentType.Miscellaneous | BingTrafficIncidentType.Weather;
            SearchBoundingBox searchArea = new SearchBoundingBox { WestLongitude = -115.338457, NorthLatitude = 36.268745, 
                                                                    EastLongitude = -114.988268, SouthLatitude= 36.1010376 };
            incidentProvider.RequestTrafficIncidents( searchArea, incidentSeverity, incidentType);
        }
        private void OnDataRequestCompleted(object sender, RequestCompletedEventArgs e) {
            // Zoom the map so that it displays the obtained incidents.
            mapControl.ZoomToFitLayerItems();
        }
    }
}

Implements

See Also