DirectionsManager Class
> [!NOTE] > Bing Maps Web Control SDK retirement > > Bing Maps Web Control SDK is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps Web Control SDK until June 30th, 2025. Enterprise account customers can continue to use Bing Maps Web Control SDK until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps Web Control SDK will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type. For detailed migration guidance, see Migrate from Bing Maps Web Control SDK and Migrate Bing Maps Enterprise applications to Azure Maps with GitHub Copilot. > > Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.s
The DirectionsManager is the primary class in the Directions module. It contains methods for calculating directions and displaying a route on a map.
Constructor
DirectionsManager(map:Map, waypoints?:Waypoint[])
Methods
Name | Type | Description |
---|---|---|
addWaypoint(waypoint: Waypoint, index?: number) | Waypoint | Adds a waypoint to the route at the given index, if specified. If an index is not specified, the waypoint is added as the last waypoint in the route. The maximum number of walking or driving waypoints is 25. The maximum number of transit waypoints is 2. Up to 10 via points are allowed between two stop waypoints. To recalculate the route, use calculateDirections . |
calculateDirections() |
Calculates directions based on request and render options set (setRequestOptions , setRenderOptions ) and the waypoints added (addWaypoint ). The directionsUpdated event fires when the calculation is complete and the route is displayed on the map.You must call this method after making any changes to the route options or waypoints for these changes to take effect. |
|
clearAll() |
Clears the directions results, request and render options and removes all waypoints. | |
clearDisplay() |
Clears the directions displayed and removes the route line from the map. This method does not remove waypoints from the route and retains all calculated direction information and option settings. To clear the calculated directions and options, use clearAll . |
|
dispose() |
Deletes the DirectionsManager object and releases any associated resources. | |
getAllPushpins() |
Pushpin[] | Returns all current pushpins for the rendered route. This includes pushpins created by addWaypoint and viaPoints created due to drag and drop. |
getAllWaypoints() |
Waypoint[] | Returns the waypoints for the route. |
getCurrentRoute() |
Route | Returns the currently displayed route information. |
getRenderOptions() |
DirectionsRenderOptions | Returns the route render options. |
getRequestOptions() |
DirectionsRequestOptions | Returns the directions request options. |
getRouteResult() |
Route[] | Returns the current calculated route(s). If the route was not successfully calculated, null is returned. |
removeWaypoint(waypointOrIndex: Waypoint or number) | Sets the specified render options for the route. Use calculateDirections to update the route once a waypoint has been removed. |
|
setRenderOptions(options: DirectionsRenderOptions) | Sets the specified render options for the route. | |
setRequestOptions(options: DirectionsRequestOptions | Sets the specified route calculation options. | |
showInputPanel(inputContainerId: string) |
Displays an input panel for calculating directions in the specified container. |
Events
Name | Arguments | Description |
---|---|---|
directionsError |
DirectionsErrorEventArgs | Occurs when calculating the directions caused an error. |
directionsUpdated |
DirectionsEventArgs | Occurs when the directions calculation was successful and the itinerary and route on the map have been updated. |