Export (0) Print
Expand All

TrafficManager class

Bing

Contains methods for managing traffic incidents.

Public Methods

Name Definition Return Type Description

ClearTrafficIncident

ClearTrafficIncident()

None

Clears all traffic incident pushpins from the map.

GetIncidentSymbol

GetIncidentSymbol( IncidentType incidentType)

string

Returns a description of the symbol used for the specified traffic incident type.

GetTrafficIncidentsAsync

GetTrafficIncidentsAsync( TrafficIncidentRequestOptions options)

IAsyncOperation<TrafficIncidentResponse>

Makes an asynchronous request for traffic incidents based on the specified request options.

ShowTrafficIncidents

ShowTrafficIncidents( TrafficIncidentCollection trafficIncidents)

None

Adds pushpins to the map representing the traffic incidents in the specified collection.

Code Example

        public async void DisplayTraffic() 
        { 
            // Set the map view, then get the current bounds
            myMap.Center = new Bing.Maps.Location(47.5, -122.3);
            myMap.ZoomLevel = 9;
            Bing.Maps.LocationRect currentMapView = myMap.Bounds;

            // Request traffic incidents for the current view
            Bing.Maps.Traffic.TrafficIncidentRequestOptions requestOptions = new Bing.Maps.Traffic.TrafficIncidentRequestOptions(currentMapView);

            Bing.Maps.Traffic.TrafficManager trafficManager = myMap.TrafficManager;
            Bing.Maps.Traffic.TrafficIncidentResponse response = await trafficManager.GetTrafficIncidentsAsync(requestOptions);

            // Display the traffic on the map
            trafficManager.ShowTrafficIncidents(response.TrafficIncidents);

        }
Show:
© 2014 Microsoft