Export (0) Print
Expand All

DirectionsStepRenderEventArgs Object

Bing

Contains arguments for directions step render events.

Properties

Name Type Description

containerElement

object

The DOM element which contains the directions step. You can use this property to add custom content.

handled

boolean

A boolean indicating whether the event is handled. This property is only available for the beforeStepRender event. Set this property to true to override the default behavior.

lastStep

boolean

A boolean indicating whether the step is the last directions step.

routeIndex

number

A number indicating the index of the route to which this step belongs.

routeLegIndex

number

A number indicating the index of the route leg to which this step belongs.

step

DirectionsStep

The directions step.

stepIndex

number

The index of this directions step within the route leg step array.

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({ routeMode: Microsoft.Maps.Directions.RouteMode.transit});
            directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('itineraryDiv') });

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

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


         } 


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


         function displayStepMessage(e)
         {
            var message = "A directions step has rendered.";

            if (e.lastStep)  { message = message + "  This is the last itinerary step."; }

            alert(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