Export (0) Print
Expand All

DirectionsEventArgs Object

Bing

Contains the arguments for directions events.

Properties

Name Type Description

routeSummary

RouteSummary[]

The route summary (or summaries) of the route(s) defined in the route property.

route

Route []

The calculated route (or routes, if the route mode is transit).

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;

         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
            var 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 - in this case, calculate a transit route.
            directionsManager.setRequestOptions({ routeMode: Microsoft.Maps.Directions.RouteMode.transit });

            // Set directions render options - in this case, specify the div 
            //    where the itinerary is displayed.
            directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('itineraryDiv') });

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

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

         } 


         function displayRouteNumber(e)
         {
            alert("Number of transit routes available: " + e.route.length);
       
         }

      </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:
© 2015 Microsoft