Can distance and duration be received outside the OnGetDirections Method from TTMSFNCDirections


I have tried to receive the distance and duration from outside the GetDirection mehthod by calling the following code after Get Direction was executed.

Directions.GetDirections(ActiveMarker.Coordinate.ToRec, NewMarker.Coordinate.ToRec);
for I := 0 to Directions.DirectionsRequests.Count-1 do
for II := 0 to Directions.DirectionsRequests.Items[I].Items.Count-1 do
showmessage('I='+I.ToString+'/II='+II.ToString+' - '+Directions.DirectionsRequests.Items[i].Items[II].Distance.ToString);

I thought I would get, every distance for every single Route, but the Length of the Routes can never be right is there some Sort of Indexfailure or something.
I am using Mapbox for every Service.

Best regards


Can you please make sure to use the OnGetDirections event after calling GetDirections?

But that was my Question. So it is not posible to get that Information outside the GetDirection Method?
The OnGetDirection Method is Fired and inside that method erverithing that gets returned seams valid. Outside the Method it behave "strange". Is it because of asynchron execution? Is there a Way to prevent that?

GetDirections is an asynchronous method by design. Accessing the DirectionsRequests data before the OnGetDirections event was triggered will produce unexpected results.

Have Changed my Workflow, thanks for advice.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.