SaveToGPX

Hi, can you send me an example, how can I save any direction with all coordinates to GPX(Stream/File/Text)?

In TTMSFNCMaps, you have the ability to save your coordinates to a GPX file:

TMSFNCMaps1.SaveToGPXFile
TMSFNCMaps1.SaveToGPXStream
TMSFNCMaps1.SaveToGPXText

So for example, if you wish to save all polylines on the map to a GPX file you can:

TMSFNCMaps1.SaveToGPXFile(TMSFNCMaps1.Polylines.ToCoordinateArray, 'MyFile.gpx');

Thanks for your answer, but my question was how can i save a whole direction, not polyline.

TfFNCDirections.FNCGoogleMapsRetrievedDirectionsData(Sender: TObject;
AEventData: TTMSFNCMapsEventData;
ADirectionsData: TTMSFNCGoogleMapsDirectionsData);
...
Self.fGpx := Self.FNCGoogleMaps.SaveToGPXText(ADirectionsData.Routes[0].Path);
...

The result is the GPX header but no coordinates.

There was an issue with the ADirectionsData.Routes.Path value which has now been fixed.
The update will be available with the next release of TMS FNC Maps.

I found a solution. In the TTMSFNCCustomGoogleMaps.ParseDirectionsDataInt function, Result.Routes[I].Path is not filled with data.
That's why I wrote a workaround:

 SetLength(ADirectionsData.Routes[0].Path,steps);

//The number of steps must be calculated beforehand
steps := 0;
for I := 0 to Length(ADirectionsData.Routes[0].Legs) - 1 do
for J := 0 to Length(ADirectionsData.Routes[0].Legs[I].Steps) - 1 do
for K := 0 to Length(ADirectionsData.Routes[0].Legs[I].Steps[J].Path) - 1 do begin
ADirectionsData.Routes[0].Path[steps].Latitude := ADirectionsData.Routes[0].Legs[I].Steps[J].Path[K].Latitude;
ADirectionsData.Routes[0].Path[steps].Longitude := ADirectionsData.Routes[0].Legs[I].Steps[J].Path[K].Longitude;
Inc(steps);
end;
Self.FNCGoogleMaps.SaveToGPXFile(ADirectionsData.Routes[0].Path,'E:\out\tst.gpx');

It works fine.

Thank you for your feedback!

This is indeed a valid workaround.