Microsoft KB Archive/286020

= How To Automate Trip Routing in Microsoft MapPoint =

Article ID: 286020

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition, when used with:
 * Microsoft MapPoint 2001 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition, when used with:
 * Microsoft MapPoint 2001 Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition, when used with:
 * Microsoft MapPoint 2001 Standard Edition
 * Microsoft Visual FoxPro 5.0a, when used with:
 * Microsoft MapPoint 2001 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition, when used with:
 * Microsoft MapPoint 2001 Standard Edition

-



This article was previously published under Q286020



SUMMARY
Microsoft MapPoint is an Automation server, which means that other programs can control its behavior. One of these behaviors is Trip Routing, which this article will demonstrate.



MORE INFORMATION
The following code provides driving instructions and maps for a trip between Bangor, ME and Snohomish, WA, with a stop in Riverside, RI. *!* Q286020: How To Automate Trip Routing in Microsoft MapPoint
 * !* This code adds three locations to a map and gives driving directions
 * !* between them.


 * 1) DEFINE geoPrintStripMaps 3
 * 2) DEFINE geoPrintLandscape 1
 * 3) DEFINE geoPrintQualityNormal 0

LOCAL loApp, loMap, loRoute, loBgr, loPvd, loSea

loApp = CREATEOBJECT(&quot;MapPoint.Application&quot;) loMap = loApp.NewMap loRoute = loMap.ActiveRoute

loBgr = loMap.Find(&quot;116 Main St., Bangor, ME 04401&quot;) loRoute.Waypoints.Add(loBgr, &quot;Bangor&quot;)

loPvd = loMap.Find(&quot;18 Turner Ave., Riverside, RI 02915&quot;) loRoute.Waypoints.Add(loPvd, &quot;Riverside&quot;)

loSea = loMap.Find(&quot;602 Avenue B, Snohomish, WA 98290&quot;) loRoute.Waypoints.Add(loSea, &quot;Snohomish&quot;)

loRoute.Calculate

loApp.Visible = .T.
 * !* The following few lines assume that you want to look at the
 * !* map you just created before you quit the program. If not, remove the
 * !* .Visible line, the MESSAGEBOX call, and the opening and closing
 * !* lines of the IF/ENDif block.

loMap.PrintOut(, &quot;Stars across the land&quot;, 1, geoPrintStripMaps, ;  geoPrintQualityNormal, geoPrintLandscape, .F., .F., .T., .F.)
 * !* Do not print to file, do supply a relevant title, print only
 * !* one copy, use strip maps format, use normal quality, use Landscape
 * !* orientation, do not collate, do not include legend, do include
 * !* Overview map, and do not make the printout faxable.

=MESSAGEBOX(&quot;Hit Enter to close MapPoint...&quot;)

IF TYPE(&quot;loApp.Visible&quot;) = &quot;L&quot; && Was MapPoint closed? loMap.Saved = .T. && To close without saving loApp.Quit ENDif

If you choose to run the code that makes the MapPoint object visible, you may need to move the MapPoint object to see the MessageBox dialog box.

