Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on How do you loop through the stops on a route? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I need to associate the address to the stop number on the route so that I can then print a ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| How do you loop through the stops on a route? Is there a way to see what address has which stop number? |
| |||
| You need to loop through the Waypoints collection of the Rou
If you're using the Mappoint Object model in your own APP: Here's how I do it: (VB psuedocode) 'Declare and initialize a new Map Dim MyMap As MapPoint.Map Set MyMap = MPC.NewMap(geoMapNorthAmerica) 'Now Declare and initialize a Route on that map Dim MyRoute As MapPoint.Route 'Tie the two things together. Now you've got a Route to work with Set MyRoute = MyMap.ActiveRoute 'Now clear the Route MyRoute.Clear 'You can now begin Adding WayPoints to your new clean Route 'A Waypoint consists of a Location and a Name 'I use a Ticket# - Description for the name of my waypoints MyRoute.WayPoints.Add "Location Address...", "Ticket 12345 - Someplace" 'Keep adding waypoints till your done. 'Now your route is polulated with Waypoints, you can optimize and recalc MyRoute.Waypoints.Optimize '...This could take a while... MyRoute.Calculate 'This will create new driving directions 'Now your route contains a collection of waypoints in the optimized order. 'You can loop back through them. 'In this example, I have a table of Ticket #'s that I'm going to update with the optimized Order. Then I can just print the data from the table sorted in that order 'You need a counter. The waypoints are in ordinal position in an array CountWaypoints = 1 Do While CountWaypoints < MyRoute.Waypoints.Count 'ThisTicket is a function that strips the Ticket# that's been embedded into the Name property for each waypoint. StopTicket = ThisTicket(MyRoute.Waypoints.Item(CountWaypoints). Name) 'MarkRouteOrder is a subroutine that actually updates the Access table with the counter for the given Ticket# MarkRouteOrder StopTicket, CountWaypoints 'Now move forward in the collection CountWaypoints = CountWaypoints + 1 Loop Done! You can now print your stuff from the table in the optimized order. I would strongly suggest some sort of identifier on the items you want to sort (like I used Ticket #). Trying to update the table with some sort of matching on an address could be problematic. As always, YMMV. |
![]() |
| Tags |
| loop, route, stops |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| retrieving directions in a route with stops | couso | MapPoint 2006/2009 Discussion | 3 | 11-04-2006 03:19 PM |
| Route Optimizing with 2 identical stops | cwrude | MapPoint 2006/2009 Discussion | 0 | 01-19-2005 01:28 PM |
| Connect Route Stops? | swberman | MapPoint 2006/2009 Discussion | 1 | 01-11-2003 09:29 PM |
| I have been using MapPoint to sequence route stops.... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 02-04-2002 10:31 AM |
| We created a route of 700+ stops and optimized it..... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 09-07-2001 05:27 PM |
Hurghada Holiday
Enjoy sunny Egypt when you book a Hurghada holiday through UlookUbook at a good price!