We have a component in our application where we show a route. Now we want to show the duration and distance for this route.
As i found out, this should work via the OnRouteRetrievedDirectionsData-Event. In general, this looks good. AEventData is holding the information we need.
I tried to get tha data out of ADirectionsData as it is more convenient. But i always get an AccessViolation when trying to access .Distance.
I am using C++ Builder 13 with the latest TMS.FNC.Maps-Package.
void __fastcall TFormGoogleMapsAnfahrtsbeschreibung::wgmRouteRetrievedDirectionsData(TObject *Sender, TTMSFNCMapsEventData *AEventData,
TTMSFNCGoogleMapsDirectionsData ADirectionsData)
{
auto routes = ADirectionsData.Routes;
if (routes.Length == 0)
return;
auto legs = routes[0].Legs;
if (legs.Length > 0)
{
int d = legs[0].Distance;
ShowMessage(d);
}
}
//---------------------------------------------------------------------------
Seems to be only a Problem with C++ Builder and the 32bit-Target (CLANG-based compiler). Changing the Target to 64bit (Modern) works as expected.
In Delphi both Targets work fine.
Can you please try setting the Use 'classic' Borland compiler option to true in the Project options>C++ Compiler?
This should make your code work as expected.
This works indeed with my Sample-Project but isn't an option for our Application as we ware using newer C++ Functions which are not available with older Compilers.