Hi,
This should give what you want I think:
Code:
double Lat;
double Lon;
double Alt = 1;
Location Loc;
Waypoint Way;
// set start point
MP.ActiveMap.ActiveRoute.Clear();
Lat = 51.24943;
Lon = 4.48300;
Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
Way = MP.ActiveMap.ActiveRoute.Waypoints.Add(Loc, "");
Way.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;
// set waypoints
Lat = 51.22609;
Lon = 4.51859;
Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
Way = MP.ActiveMap.ActiveRoute.Waypoints.Add(Loc, "");
Way.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;
// set endpoint
Lat = 51.22727;
Lon = 4.52579;
Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
Way = MP.ActiveMap.ActiveRoute.Waypoints.Add(Loc, "");
Way.SegmentPreferences = GeoSegmentPreferences.geoSegmentPreferred;
// set preferred roads
MP.ActiveMap.ActiveRoute.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadArterial, 0.1);
MP.ActiveMap.ActiveRoute.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadFerry, 0.1);
MP.ActiveMap.ActiveRoute.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadInterstate, 0.9);
MP.ActiveMap.ActiveRoute.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadOtherHighway, 0.9);
MP.ActiveMap.ActiveRoute.DriverProfile.set_PreferredRoads(GeoRoadType.geoRoadToll, 0.2);
// set preferred speed
MP.ActiveMap.ActiveRoute.DriverProfile.set_Speed(GeoRoadType.geoRoadArterial, 120);
MP.ActiveMap.ActiveRoute.DriverProfile.set_Speed(GeoRoadType.geoRoadInterstate, 150);
MP.ActiveMap.ActiveRoute.DriverProfile.set_Speed(GeoRoadType.geoRoadLimitedAccess, 150);
MP.ActiveMap.ActiveRoute.DriverProfile.set_Speed(GeoRoadType.geoRoadOtherHighway, 150);
MP.ActiveMap.ActiveRoute.DriverProfile.set_Speed(GeoRoadType.geoRoadStreet, 50);
MP.ActiveMap.ActiveRoute.DriverProfile.StartTime = System.DateTime.Now;
MP.ActiveMap.ActiveRoute.Calculate();
Directions dir = MP.ActiveMap.ActiveRoute.Directions;
foreach (MapPoint.Direction d in dir) {
if (d.Type == GeoDirectionType.geoDirectionWaypoint)
Console.WriteLine("This is a waypoint");
Console.WriteLine("Start time: " + Convert.ToString(d.StartTime));
Console.WriteLine("Distance: " + Convert.ToString(d.Distance));
Console.WriteLine("Instruction: " + d.Instruction);
}
Console.WriteLine("Driving time: " + Convert.ToString(MP.ActiveMap.ActiveRoute.DrivingTime));
Console.WriteLine("Distance: " + Convert.ToString(MP.ActiveMap.ActiveRoute.Distance));