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

AzureTrafficIncidentDataProvider.TrafficIncidentCalculated Event

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

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v24.2.dll

NuGet Package: DevExpress.Win.Map

#Declaration

public event AzureTrafficIncidentCalculatedEventHandler TrafficIncidentCalculated

#Event Data

The TrafficIncidentCalculated event's data class is AzureTrafficIncidentCalculatedEventArgs. 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 Gets traffic incident results received from the Microsoft Azure service.
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.

#Remarks

After you obtain a list of incidents in the RequestTrafficIncidents method, the provider raises the TrafficIncidentCalculated event. You can handle the event to access the collection of received incidents or add custom logic.

This example obtains a list of incidents in the specified area from the Azure Maps service and displays information about obtained incidents in a MemoEdit control:

Display a list of traffic incidents

using DevExpress.XtraMap;
using System.Text;
// ...
const string key = "your key";
AzureTrafficIncidentDataProvider trafficIncidentProvider;
// ...
public Form1() {
    InitializeComponent();
    trafficIncidentProvider = new AzureTrafficIncidentDataProvider {
        AzureKey = key 
    };
    imageLayer2.DataProvider = new AzureMapDataProvider() {
        AzureKey = key,
        Tileset = AzureTileset.BaseHybridRoad
    };
    imageLayer1.DataProvider = new AzureMapDataProvider() {
        AzureKey = key,
        Tileset = AzureTileset.Imagery,
    };
    informationLayer1.DataProvider = trafficIncidentProvider;
    informationLayer1.DataRequestCompleted += OnDataRequestCompleted;
    trafficIncidentProvider.TrafficIncidentCalculated += OnTrafficIncidentCalculated;  
    trafficIncidentProvider.RequestTrafficIncidents(new SearchBoundingBox(-115.338457, 36.268745, 
      -114.988268, 36.1010376), 18, -1,
      new AzureTrafficIncidentOptions {
          OriginalPosition = false,
          IncidentGeometryType = AzureTrafficIncidentGeometryType.Shifted
      });
}
void OnDataRequestCompleted(object sender, RequestCompletedEventArgs e) {
    mapControl1.ZoomToFitLayerItems();
}
private void OnTrafficIncidentCalculated(object sender, AzureTrafficIncidentCalculatedEventArgs e) {
    if (e.Cancelled) return;
    if (e.RequestResult.ResultCode != RequestResultCode.Success) {
        memoEdit1.Text = "Traffic incidents were not found for this area.";
        return;
    }
    StringBuilder resultList = new StringBuilder("");
    int resCounter = 1;
    foreach (AzureTrafficIncidentResult resultInfo in e.RequestResult.IncidentResults) {
        resultList.Append(string.Format("Incident {0}:  \r\n", resCounter));
        resultList.Append(string.Format("Cause: {0}\r\n", resultInfo.Cause));
        resultList.Append(string.Format("Description: {0}\r\n", resultInfo.Description));
        resultList.Append(string.Format("Start Time: {0}\r\n", resultInfo.StartDate));
        resultList.Append(string.Format("End Time: {0}\r\n", resultInfo.EndDate));
        resultList.Append(string.Format("Lat: {0}, Lon: {1}\r\n", resultInfo.Point.Latitude, resultInfo.Point.Longitude));
        resultList.Append(string.Format("_______________________\r\n"));
        resCounter++;
    }
    memoEdit1.Text = resultList.ToString();
}
See Also