Export (0) Print
Expand All

StepWarningStyle Enumeration

Bing

Contains types of route direction warnings.

Constants

Code Name Description

0

info

The warning is just information about the route direction.

1

minor

The warning is a minor warning, and may affect the route direction.

2

moderate

The warning is a moderate warning and is likely to affect the route direction.

3

major

The warning is a major warning, and is highly likely to affect the route direction.

4

ccZoneEnter

The warning indicates a congestion zone is being entered.

5

ccZoneExit

The warning indicates a congestion zone is being exited.

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

      <script type="text/javascript">
         
         var map = null;
         var directionsManager = null;

         function GetMap()
         {
            // Initialize the map
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Bing Maps Key"});
            Microsoft.Maps.loadModule('Microsoft.Maps.Directions', { callback: directionsModuleLoaded });

         }



         function directionsModuleLoaded()
         {
            // Initialize the DirectionsManager
            directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);

            // Create start and end waypoints and add them to the route
            var startWaypoint = new Microsoft.Maps.Directions.Waypoint({address:"Seattle, WA"});
            var endWaypoint = new Microsoft.Maps.Directions.Waypoint({address:"Bellevue, WA"});

            directionsManager.addWaypoint(startWaypoint);
            directionsManager.addWaypoint(endWaypoint);

            // Set directions options
            directionsManager.setRequestOptions({ avoidTraffic: true });
            directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('itineraryDiv') });

            // Specify a handler for when the directions are calculated
            Microsoft.Maps.Events.addHandler(directionsManager, 'directionsUpdated', displayMessage );
            Microsoft.Maps.Events.addHandler(directionsManager, 'directionsError', displayError);

            // Calculate directions, which displays a route on the map
            directionsManager.calculateDirections();


         } 



         function displayMessage(e)
         {
            // Variable for counting warnings
            var warningCount = 0;

            for( j=0; j< e.route[0].routeLegs.length; j++)
            {

               var i = 0;
               for (i=0; i < e.route[0].routeLegs[j].itineraryItems.length; i++)
               {
                  if (e.route[0].routeLegs[j].itineraryItems[i].warnings.length != 0 )
                  {
                     warningCount = warningCount + e.route[0].routeLegs[j].itineraryItems[i].warnings.length;

                     for (k=0; k< e.route[0].routeLegs[j].itineraryItems[i].warnings.length; k++)
                     {
                        if (e.route[0].routeLegs[j].itineraryItems[i].warnings[k].style == Microsoft.Maps.Directions.StepWarningStyle.major)
                        {
                           alert("Alert! There is a major warning in this route.");
                        }
                     }
                  }
               }
            }

            alert("There are " + warningCount + " warning(s) in this route.");             
         }


         function displayError(e)
         {
            alert(e.message);
         }




      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>       
      <div id='itineraryDiv' style="position:relative; width:400px;"></div>
   </body>
</html>
Show:
© 2014 Microsoft