Share via


Distance property

Returns the total distance of a route or route segment, in GeoUnits (miles or kilometers). Returns 0 if a route is not currently calculated. Read-only Double.

Applies to

Objects: Direction, Route

Syntax

object.Distance

Parameters

Part

Description

object

Required. An expression that returns a Direction or Route object.

Remarks

Example

  Sub TotalRouteDistance()

  Dim objApp As New MapPoint.Application
  Dim objMap As MapPoint.Map
  Dim objRoute As MapPoint.Route

  'Set up 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

  'Output the total length of the route
  MsgBox "The route distance is: " + CStr(objRoute.Distance)

  End Sub

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