Skip to main content
All docs
V24.1

BingTrafficIncidentDataProvider.RequestTrafficIncidents(SearchBoundingBox, BingTrafficIncidentSeverity, BingTrafficIncidentType) Method

Requests incidents for the specified region.

Namespace: DevExpress.Xpf.Map

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

NuGet Package: DevExpress.Wpf.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 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();
        }
    }
}
See Also