View Full Version : Letting MapPoint choose the waypoint sequence

10-21-2005, 07:21 PM

I can add wappoints to a MapPoint.Route object, then call Calculate() to figure the best directions to go. But now I need it to feed back to me the most efficient stop sequence, minimizing the travel time. The problem I have is that MapPoint uses the waypoints in the order I added them, and as fart as I know is not re-organizing them according to the preferred order.

Would I still use Calculate()? If not, what other functions would I use instead? Or am I just not looking in the correct place?


10-21-2005, 07:37 PM
Beantown Bob

Sub OptimizeRoute()

Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objRoute As MapPoint.Route

'Set up the application
Set objMap = objApp.ActiveMap
Set objRoute = objMap.ActiveRoute
objApp.Visible = True
objApp.UserControl = True

'Add route stops and calculate route
With objRoute.Waypoints
.Add objMap.FindResults("Seattle, WA").Item(1)
.Add objMap.FindResults("Redmond, WA").Item(1)
.Add objMap.FindResults("Tacoma, WA").Item(1)
.Add objMap.FindResults("Bellevue, WA").Item(1)
End With

'Optimize the route
objRoute.Waypoints.Optimize '<--- Optimize!

End Sub

So how are the Bruins doing?


10-21-2005, 07:43 PM
How are the Bruins doing? Hopefully better than the Red Sox and the Patriots. :(

But "Optimize" sounds like a very good thing to do. Thanks.