Skip to main content
All docs
V24.1

BingTrafficIncidentType Enum

Lists traffic incident types.

Namespace: DevExpress.Xpf.Map

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

NuGet Package: DevExpress.Wpf.Map

Declaration

[Flags]
public enum BingTrafficIncidentType

Members

Name Description Icon
Accident

The type of incident is Accident.

Accident Icon

Congestion

The type of incident is Congestion.

Warning Icon

DisabledVehicle

The type of incident is Disabled Vehicle.

Warning Icon

MassTransit

The type of incident is Mass Transit.

Warning Icon

Miscellaneous

The type of incident is Miscellaneous.

Warning Icon

OtherNews

The type of incident is Other News.

Warning Icon

PlannedEvent

The type of incident is Planned Event.

Warning Icon

RoadHazard

The type of incident is Road Hazard.

Warning Icon

Construction

The type of incident is Construction.

Construction Icon

Alert

The type of incident is Alert.

Warning Icon

Weather

The type of incident is Weather.

Warning Icon

Related API Members

The following properties accept/return BingTrafficIncidentType values:

Example

How to: Obtain and Display a List of Traffic Incidents

This example obtains a list of incidents in the specified area from the Bing Maps service and displays information about obtained incidents in a TextEdit control.

A map with a list of incidents.

<Window xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
        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>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="5*"/>
            <ColumnDefinition Width="2*"/>
        </Grid.ColumnDefinitions>    
            <dxm:MapControl x:Name="mapControl" Grid.Column="0">
                <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." 
                                                         TrafficIncidentCalculated="OnTrafficIncidentCalculated" />
                </dxm:InformationLayer>
            </dxm:MapControl>
            <dxe:TextEdit x:Name="textEdit" TextWrapping="Wrap" Grid.Column="1"/>
    </Grid>
</Window>
using DevExpress.Xpf.Map;
using System.Text;
using System.Windows;

namespace TrafficIncidents {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
        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();
        }
        private void OnTrafficIncidentCalculated(object sender, BingTrafficIncidentCalculatedEventArgs e) {
            if (e.Cancelled) return;
            if (e.RequestResult.ResultCode != RequestResultCode.Success) {
                textEdit.Text = "Traffic incidents were not found for this area.";
                return;
            }
            StringBuilder resultList = new StringBuilder("");
            int resCounter = 1;
            foreach (BingTrafficIncidentResult resultInfo in e.RequestResult.IncidentResults) {
                resultList.Append(string.Format("Incident {0}: \r\n", resCounter));
                resultList.Append(string.Format("Type: {0}\r\n", resultInfo.Type));
                resultList.Append(string.Format("Description: {0}\r\n", resultInfo.Description));
                resultList.Append(string.Format("Start Time: {0}\r\n", resultInfo.StartTime));
                resultList.Append(string.Format("End Time: {0}\r\n", resultInfo.EndTime));
                resultList.Append(string.Format("Lat: {0}, Lon: {1}\r\n", resultInfo.Point.Latitude, resultInfo.Point.Longitude));
                resultList.Append(string.Format("______________________________\r\n"));
                resCounter++;
            }
            textEdit.Text = resultList.ToString();
        }
    }
}
See Also