All docs
V21.2
21.2
21.1
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

BingTrafficIncidentDataProvider.TrafficIncidentCalculated Event

Occurs after the provider has received a list of traffic incidents.

Namespace: DevExpress.Xpf.Map

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

Declaration

public event BingTrafficIncidentCalculatedEventHandler TrafficIncidentCalculated

Event Data

The TrafficIncidentCalculated event's data class is BingTrafficIncidentCalculatedEventArgs. The following properties provide information specific to this event:

Property Description
Cancelled Gets a value indicating whether an asynchronous operation has been canceled. Inherited from AsyncCompletedEventArgs.
Error Gets a value indicating which error occurred during an asynchronous operation. Inherited from AsyncCompletedEventArgs.
RequestResult Returns results of a request to a web service for traffic incident information.
UserState Gets the unique identifier for the asynchronous task. Inherited from AsyncCompletedEventArgs.

The event data class exposes the following methods:

Method Description
RaiseExceptionIfNecessary() Raises a user-supplied exception if an asynchronous operation failed. Inherited from AsyncCompletedEventArgs.

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