Router / Direction

Good evening ! I need to generate a route with FNCDirections , I need to assemble an array of points for example (10 points) and make his route. I'm not finding an example of how to do this, I used WebGmaps, but as it stopped, I had to migrate. What's the right way to do this? It would be a script. Thank you.

Hi,

You can use the WayPoints parameter of the GetDirections call to add points to your route.
Once the OnGetDirections event is triggered you can visualize the route on the map.

Example:

procedure TForm1.Button1Click(Sender: TObject);
var
  Origin, Destination: TTMSFNCMapsCoordinateRec;
  WayPoints: TTMSFNCMapsCoordinateRecArray;
begin
  Origin.Latitude := 43;
  Origin.Longitude := 3;
  Destination.Latitude := 45;
  Destination.Longitude := 5;
  SetLength(waypoints, 1);
  waypoints[0].Latitude := 44;
  waypoints[0].Longitude := 4;
  TMSFNCDirections1.GetDirections(Origin, Destination, nil, '', nil, False, tmDriving, WayPoints);
end;

procedure TForm1.TMSFNCDirections1GetDirections(Sender: TObject;
  const ARequest: TTMSFNCDirectionsRequest;
  const ARequestResult: TTMSFNCCloudBaseRequestResult);
begin
  if (ARequestResult.Success) and (ARequest.Items.Count > 0) then
  begin
    TMSFNCMaps1.AddPolyline(ARequest.Items[0].Coordinates.ToArray);
    TMSFNCMaps1.ZoomToBounds(ARequest.Items[0].Coordinates.ToArray);
  end;
end;