Share via


Segment.Distance Property

Segment.Distance Property

The distance of the specified route segment, in distance units (DistanceUnit enumeration) as specified in the UserInfoRouteHeader.DefaultDistanceUnit property.


Public Distance As System.Double


[C#]

public System.Double Distance;

Example

[Visual Basic]

'Calculate a route and print the distance
'from the first waypoint to the second
Dim latLongs(1) As LatLong
latLongs(0) = New LatLong()
latLongs(0).Latitude = 40
latLongs(0).Longitude = -120
latLongs(1) = New LatLong()
latLongs(1).Latitude = 41
latLongs(1).Longitude = -121

Dim myRoute As Route
myRoute = routeService.CalculateSimpleRoute(latLongs, "MapPoint.NA", SegmentPreference.Quickest)

Console.WriteLine("Distance from the first waypoint to the second: " _
 + myRoute.Itinerary.Segments(0).Distance.ToString())



[C#]

//Calculate a route and print the distance
//from the first waypoint to the second
LatLong[] latLongs = new LatLong[2];
latLongs[0] = new LatLong();
latLongs[0].Latitude = 40;
latLongs[0].Longitude = -120;
latLongs[1] = new LatLong();
latLongs[1].Latitude = 41;
latLongs[1].Longitude = -121;

Route myRoute;
myRoute = routeService.CalculateSimpleRoute(latLongs, "MapPoint.NA", SegmentPreference.Quickest);

Console.WriteLine("Distance from the first waypoint to the second: " 
 + myRoute.Itinerary.Segments[0].Distance.ToString());


See Also

  Segment Class   |   DistanceUnit Enumeration   |   UserInfoRouteHeader.DefaultDistanceUnit Property