MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




driving directions

This is a discussion on driving directions within the MapPoint 2006/2009 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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-10-2004
Junior Member
White Belt
 
Join Date: Dec 2004
Posts: 1
Send a message via AIM to impala454
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 12-11-2004
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
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));
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
directions, driving


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT -5. The time now is 04:23 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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