Create new polygon by code

417 views Asked by At

I have look into MegaDemo code, but could not find a way to create Polygon by code. Can someone help me how this is done .

I have tried

GMPolygon1.Add.AddLinePoint(5.54491313409736, 100.162353515625);
GMPolygon1.Add.AddLinePoint(5.34805212812321, 100.483703613281);
GMPolygon1.Add.AddLinePoint(5.23318714302897, 100.1953125);

no polygon displayed, I also need to make it editable and captured the editable coordinates. Some direction mmuch appreciated.

1

There are 1 answers

0
cadetill On BEST ANSWER

Try with this

procedure TForm1.Button1Click(Sender: TObject);
begin
  with GMPolygon1.Add do
  begin
    AddLinePoint(5.54491313409736, 100.162353515625);
    AddLinePoint(5.34805212812321, 100.483703613281);
    AddLinePoint(5.23318714302897, 100.1953125);
    Editable := True;
  end;
end;

procedure TForm1.GMMap1AfterPageLoaded(Sender: TObject; First: Boolean);
begin
  if first then GMMap1.DoMap;
end;

procedure TForm1.GMPolygon1PathChange(Sender: TObject; Index: Integer;
  LinkedComponent: TLinkedComponent);
begin
  ShowMessage('Path change!!');
end;