Table of Contents

Getting started with TMS FNC Toll Cost

Prerequisites

  • TMS FNC Core installed and the runtime package added to the project.
  • TMS FNC Maps installed and the runtime package added to the project.
  • Credentials for the toll cost backend: a HERE API key for tcsHere, or PTV xServer user name, token, and service endpoint for tcsPTVxServer.

Add the component

  1. Drop TTMSFNCTollCost from the TMS FNC Maps palette page onto a form.
  2. Set the APIKey property (HERE), or UserName, Token, and ServiceEndpoint (PTV xServer).
  3. Set the Service property to choose the toll cost backend (tcsHere or tcsPTVxServer).

Request toll costs for a route

{ Inside a button click handler: }
begin
  TMSFNCTollCost1.OnGetTollCostResult := TMSFNCTollCost1GetTollCostResult;

  { Origin and destination are parameters of the call, not properties: the
    TollCostRequests collection is filled in by the component with the result. }
  TMSFNCTollCost1.GetTollCostResult(
    CreateCoordinate(40.7128, -74.0060),   { New York }
    CreateCoordinate(42.3601, -71.0589),   { Boston }
    nil, 'ny-boston');
end;

procedure TForm1.TMSFNCTollCost1GetTollCostResult(Sender: TObject;
  const AResult: TTMSFNCTollCostRequest);
begin
  if AResult.Items.Count > 0 then
    ShowMessage(Format('Toll cost: %.2f %s',
      [AResult.Items[0].TotalCost, AResult.Items[0].Currency]));
end;

Next steps

  • Guides — vehicle options, emission type, and result handling.
  • API reference — full class reference.