Share via


Calculate method

Calculates a route based on two or more waypoints (stops) and generates driving directions; similar to clicking Get Directions in the Route Planner pane.

Applies to

Objects:  Route

Syntax

object.Calculate

Parameters

Part Description
object Required. An expression that returns a Route object.

Remarks

To add a waypoint, use the Add method on a Waypoints collection.

The Directions collection cannot be accessed until after the Calculate method is performed.

To capture when a route has been calculated, use the RouteAfterCalculate event of the Map or MappointControl object.

Example

    Sub CalculateARoute()

  Dim objApp As New MapPoint.Application   Dim objMap As MapPoint.Map   Dim objRoute As MapPoint.Route
  'Set up the application   Set objMap = objApp.ActiveMap   Set objRoute = objMap.ActiveRoute   objApp.Visible = True   objApp.UserControl = True
  'Add route stops and calculate the route   objRoute.Waypoints.Add objMap.FindResults("Seattle, WA").Item(1)   objRoute.Waypoints.Add objMap.FindResults("Redmond, WA").Item(1)   objRoute.Calculate
  End Sub

Note  This sample code is specifically for use in MapPoint North America; it is for illustration purposes only.