Skip to main content
All docs
V25.1
  • BingTrafficIncidentResult.Type Property

    Returns the incident type.

    Namespace: DevExpress.XtraMap

    Assembly: DevExpress.XtraMap.v25.1.dll

    NuGet Package: DevExpress.Win.Map

    Declaration

    public BingTrafficIncidentType Type { get; }

    Property Value

    Type Description
    BingTrafficIncidentType

    A value that specifies the incident type.

    Available values:

    Show 11 items
    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

    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 MemoEdit control.

    A traffic incident map

    • Create an InformationLayer object and add it to the MapControl.Layers collection.

    • Initialize the layer’s DataProvider property with a BingTrafficIncidentDataProvider object.

    • Specify the provider’s BingKey property.

    • Call the provider’s RequestTrafficIncidents method to receive a list of incidents.

    • Handle the BingTrafficIncidentDataProvider.TrafficIncidentCalculated event to access the list of incidents and display incident-related information in a MemoEdit control.

    using DevExpress.Map;
    using DevExpress.XtraMap;
    using System;
    using System.Text;
    using System.Windows.Forms;
    
    namespace TrafficAndIncidents {
        public partial class Form1 : Form {
    
            private void Form1_Load(object sender, EventArgs e) {
                // Create a background image layer.
                ImageLayer imageLayer = new ImageLayer();
                mapControl1.Layers.Add(imageLayer);
                BingMapDataProvider provider = new BingMapDataProvider();
                imageLayer.DataProvider = provider;
                provider.BingKey = "Insert your Bing Key.";
                provider.Kind = BingMapKind.RoadLight;
    
                // Create an information layer.
                InformationLayer infoLayer = new InformationLayer();
                mapControl1.Layers.Add(infoLayer);
    
                // Create a BingTrafficIncidentDataProvider and assign it to the information layer.
                BingTrafficIncidentDataProvider trafficIncidentDataProvider = new BingTrafficIncidentDataProvider();
                infoLayer.DataProvider = trafficIncidentDataProvider;
                trafficIncidentDataProvider.BingKey = "Insert your Bing Key."
                BingTrafficIncidentSeverity incidentSeverity = BingTrafficIncidentSeverity.LowImpact | BingTrafficIncidentSeverity.Minor | BingTrafficIncidentSeverity.Moderate | BingTrafficIncidentSeverity.Serious;
                BingTrafficIncidentType incidentType = BingTrafficIncidentType.Accident | BingTrafficIncidentType.Construction | BingTrafficIncidentType.Miscellaneous
                                                        | BingTrafficIncidentType.Weather;
                // Request a list of incidents in the specified area.
                trafficIncidentDataProvider.RequestTrafficIncidents(new SearchBoundingBox( -115.338457, 36.268745, -114.988268, 36.1010376),
                                                                    incidentSeverity,
                                                                    incidentType);
                trafficIncidentDataProvider.TrafficIncidentCalculated += OnTrafficIncidentCalculated;
                infoLayer.DataRequestCompleted += OnDataRequestCompleted;
            }
    
            private void OnDataRequestCompleted(object sender, RequestCompletedEventArgs e) {
                // Call the ZoomToFitLayerItems method to zoom the map so that it displays all the obtained incidents.
                mapControl1.ZoomToFitLayerItems();
            }
    
            private void OnTrafficIncidentCalculated(object sender, BingTrafficIncidentCalculatedEventArgs 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 (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++;
                }
                memoEdit1.Text = resultList.ToString();
            }
        }
    }
    
    See Also