TMS FNC trying to add coordinates of polylines crashes in google map

Hi,

I add the first two coordinates of the polyline as following:

             SetLength(arr_track, tracking_polyline_length);
              arr_track[0] := CreateCoordinate(Current_LAT,Current_LONG);
              arr_track[1] := CreateCoordinate(Current_LAT,Current_LONG);

              tracking_polyline := Map.AddPolyline(arr_track);

and it works.. then when I try to add another coordinate as following it crouches at the first code line below:

             tracking_polyline_item := tracking_polyline.Coordinates.Add;
             tracking_polyline_item.coordinate.Latitude  :=  Current_Lat;
              tracking_polyline_item.coordinate.Longitude  :=  Current_Long;




              //Force the polyline to update
              tracking_polyline.Recreate := True; 

can someone help me please?

Hi,

The tracking_polyline variable probably is not initialized correctly in your code. Can't say for sure without seeing the full code.
Please have a look at the following sample which is working as expected:

  private
    FTrackingPolyline: TTMSFNCMapsPolyline;
    Current_Lat, Current_Long: Double;
    procedure IncCoord;

procedure TForm1.IncCoord;
begin
  Current_Lat := Current_Lat + 0.01;
  Current_Long := Current_Long + 0.01;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  arr_track: TTMSFNCMapsCoordinateRecArray;
  item: TTMSFNCMapsCoordinateItem;
begin
  SetLength(arr_track, 1);
  arr_track[0] := CreateCoordinate(Current_Lat, Current_Long);
  FTrackingPolyline := TMSFNCMaps1.AddPolyline(arr_track);
  IncCoord;
  item := FTrackingPolyline.Coordinates.Add;
  item.Coordinate.Latitude  := Current_Lat;
  item.Coordinate.Longitude := Current_Long;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  item: TTMSFNCMapsCoordinateItem;
begin
  if not Assigned(FTrackingPolyline) then
    Exit;

  TMSFNCMaps1.BeginUpdate;
  try
    IncCoord;
    item := FTrackingPolyline.Coordinates.Add;
    item.Coordinate.Latitude  := Current_Lat;
    item.Coordinate.Longitude := Current_Long;
  finally
    FTrackingPolyline.Recreate := True;
    TMSFNCMaps1.EndUpdate;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Current_Lat := TMSFNCMaps1.Options.DefaultLatitude;
  Current_Long := TMSFNCMaps1.Options.DefaultLongitude;
end;