Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 2 of 2

driving directions

This is a discussion on driving directions within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have searched the forums here and haven't quite found what I've been looking for. I have MapPoint 2004 (not ...

  1. #1
    impala454 is offline Junior Member White Belt
    Join Date
    Dec 2004
    Posts
    1

    driving directions

    I have searched the forums here and haven't quite found what I've been looking for. I have MapPoint 2004 (not LS and not Web Service), and program in C#.NET. I would like to create a function that will take in 2 pairs of (Lat,Long) and return the driving directions. I just want to create the class members to do it, I don't want to have to drag and drop the control onto a windows form. It is for internal use only and will not be over the internet. Does anybody know how I could accomplish this?

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    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));

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I get the driving distance of two addresses?
    By dawa in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 04-18-2008, 02:23 AM
  2. Driving time between each waypoint
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-10-2005, 06:42 AM
  3. Pocket Streets 2003 Driving Directions
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-25-2004, 08:49 PM
  4. Traffic Congestion Considered in Driving Directions?
    By Justin in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-28-2004, 10:17 AM
  5. Driving Day - How to turn off?
    By Clive2004 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-06-2004, 06:42 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66