*** Instantiate the Mappoint Application loMP = CREATEOBJECT('MapPoint.Application') *** Create a new map loMap = loMP.NewMap() ******************************************************************** *** Create a route from One Point to Another ******************************************************************** *** Set the start point and create a pushpin for it loStart = loMap.FindAddress( "555 Westminster Circle", "Akron", "OH") loStartPin = lomap.AddPushpin( loStart.Location, 'Home' ) *** Make the pushpin visible and add it to the route loStartPin.BalloonState= 2 loMap.ActiveRoute.Waypoints.Add( loStartPin ) loEnd = loMap.FindAddress( "23905 Woodway Road", "Beachwood", "OH") loEndPin = loMap.AddPushpin( loEnd.Location, "Nancy's House" ) *** Make the pushpin visible and add it to the route loEndPin.BalloonState= 2 loMap.ActiveRoute.Waypoints.Add( loEndPin ) *** Add another Waypoint - by place name, not address loLannings = loMap.FindPlaceResults( 'Lannings Restaurant' ) *** Did we find anything IF loLannings.Count = 0 MESSAGEBOX( "Could not find 'Lannings'" ) ELSE *** Enumerate what we found... llFound = .F. FOR lnCnt = 1 TO loLannings.count loItem = loLannings.Item[lnCnt] loAddr = loItem.StreetAddress IF UPPER( ALLTRIM( loAddr.City )) == "AKRON" *** This is the right city, but what about the state IF ALLTRIM( GETWORDNUM( loAddr.Value, 3, ',' )) = "OH" *** It's the one we want! llFound = .T. EXIT ENDIF ENDIF NEXT *** If we found the place add it as a waypoint IF llFound loEatPin = lomap.AddPushpin( loItem.Location, 'Lannings' ) *** Make the pushpin visible and add it to the route loEatPin.BalloonState= 2 *** Note, this adds the waypoint to the END of the existing route loStop = loMap.ActiveRoute.Waypoints.Add( loItem.Location, 'Lannings' ) *** Now let map point know that we are stopping 2 hours for *** a liesurely lunch - times are in parts of a day between 0 and 1 loStop.StopTime = 1/12 ENDIF ENDIF *** Add another stop - you need at least 4 stops to *** optimize the route loAirport = loMap.FindPlaceResults( 'Cleveland-Hopkins International Airport' ) loItem = loAirport.Item[ 1 ] loFlyPin = lomap.AddPushpin( loItem.Location, 'Airport' ) *** Make the pushpin visible and add it to the route loFlyPin.BalloonState= 2 *** Note, this adds the waypoint to the END of the existing route loMap.ActiveRoute.Waypoints.Add( loFlyPin ) *** We are starting the trip at 12:30 PM on March 3rd loFirstStop = loMap.ActiveRoute.Waypoints[ 1 ] loFirstStop.PreferredDeparture = {^2006-03-03 12:30:00} *** Now we want to opttimize the route and re-calculate it loMap.ActiveRoute.Waypoints.Optimize() loMap.ActiveRoute.Calculate() *** Print the directions loWord = CREATEOBJECT( [Word.application] ) loDoc = loWord.Documents.Add() loWord.DisplayAlerts = 0 && wdAlertsNone loMap.CopyMap() loWord.Selection.Paste() loMap.CopyDirections() loWord.Selection.Endkey( 6 ) loWord.Selection.Paste() *** Make word visible so we can see the result loWord.Visible = .T. lnDist = lomap.ActiveRoute.Distance && This is in Miles by default lnTim = lomap.ActiveRoute.DrivingTime && This is in Days lnTim = INT( lnTim * 24 * 60 ) *** Fool Mappoint into thinking the map was saved *** so that we do not get locked up because of the *** invisible save dialog loMap.Saved = .T.