◆ SetRoute() [1/3]

static int SetRoute ( out SError  Error,
string  strItineraryName,
Int32  Flags,
bool  bShowApplication,
Int32  MaxTime 

The function computes route based on taken itinerary. If Drive has valid GPS signal it starts navigation.

ErrorAdditional error information returned from Drive.
strItineraryNameName of the itinerary which will be used to compute route.
MaxTimeMaximum time (in milliseconds) function can take. If MaxTime=0 function execution is not time limited.
bShowApplicationFlag determining whether Drive should be brought to foreground automatically.
true - Drive will be brought to foreground.
false - Drive will stay in background.
FlagsParameter Flags determines route computing properties.
Possible values are enumerated in: NavigationParams.
1 if successful, other value otherwise.
If Drive does not have valid GPS signal first waypoit in itinerary must be marked as START.

Parameter Flags determines route computing properties.
For example it is possible to ask user to avoid toll roads or (later) notify user that not all toll roads can be avoided.

To join more flags together use logical or operator (|). For more informations see NavigationParams enum.

If waypoint is in restricted area , the function will return lX,lY coordinates of closest reached point in error description (truck attributes enabled)

Itinerary used to compute route must contain item of type "finish". If you do not have valid GPS position itinerary must contain also item of type "start".

When in navigation the events from ApplicationEvents enumeration occur.

Possible error codes returned from Drive are:
  • 0 - Function not succeeded.
  • 1 - Function succeeded.
  • 2 - Drive not succeeded.
  • 3 - Function reached timeout.
  • -1 - Navigation not started because address was not found or closest reached point was found
  • -3 - Navigation not started. Drive is already navigating.
  • -5 - User canceled route computing.
  • -6 - Drive is waiting for valid GPS signal.
  • -7 - Itinerary is empty
  • -8 - Itinerary has invalid format (from version 15j)
  • -9 - One or more waypoints were not found (from version 15j)
  • -10 - Itinerary was not found (from version 15j)


SErorr error;
string strItineraryName = "MyItin";
int nFlags = NavigationParams.NpMessageAvoidTollRoadsUnable;
bool bShowApplication = true;
int nMaxTime = 10000;
CApplicationAPI.SetRoute(error, strItineraryName, nFlags, bShowApplication, nMaxTime);

This code brings drive to foreground and computes route according to itinerary MyItin. If computed route contains toll roads Drive ask user to avoid them. If not toll roads can be avoided Drive notify user about this.

References SError.SizeOf().