在两个已知点之间画线
问题描述:
使用Delphi XE3和GMLib 1.2.4。应该是基本的问题。如何绘制两个给定点之间的基本非连接线。我目前在WebBrowser上显示GMMap并且有GMPolyline组件。使用两个经纬度对的已知值。只需要帮助两者之间的标线。用它来绘制方位线。这是我到目前为止有:在两个已知点之间画线
procedure TMainGMForm.ButtonPlotLineClick(Sender: TObject);
var
CurLat,CurLon,DisLat,DisLon: Double;
P1,P2: TLatLng;
begin
CurLat := StrToFloat(EditLat.Text);
CurLon := StrToFloat(EditLon.Text);
DisLat := StrToFloat(EditLat2.Text);
DisLon := StrToFloat(EditLon2.Text);
P1 := TLatLng.Create(CurLat,CurLon);
Inc(PointIndex);
P2 := TLatLng.Create(DisLat,DisLon);
Inc(PointIndex);
//what goes here to plot a line between these two points?
//
FreeAndNil(P1);
FreeAndNil(P2);
end;
答
你需要一个TPolyline添加到您的TGMPolyline,像这样
var
Poly: TPolyline;
begin
Poly := TPolyline(GMPolyline1.Add);
和两个点添加到LinePoints阵列
Poly.AddLinePoint(CurLat, CurLon);
Poly.AddLinePoint(DisLat, Double);
正是我需要的。谢谢! – user3550032