//一下这种方法画完折线后,只能计算第一个点和最后一个点之间的距离!
//如何才能把折线的折点按顺序的采集下来并按顺序的计算距离,然后再累加??
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, MapXLib_TLB, StdCtrls;
type
TForm1 = class(TForm)
Map1: TMap;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Map1ToolUsed(Sender: TObject;
ToolNum: Smallint;
X1, Y1, X2,
Y2, Distance:do
uble;
Shift, Ctrl: WordBool;
var EnableDefault: WordBool);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
map1.Layers.CreateLayer('temp', EmptyParam,1, EmptyParam, EmptyParam);
Map1.Layers.Item(1).Editable := True;
Map1.Layers.InsertionLayer := Map1.Layers.Item(1);
Map1.CurrentTool := miAddPolylineTool;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
map1.Layers.Remove ('temp');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Map1.Layers.Remove ('temp');
end;
procedure TForm1.Map1ToolUsed(Sender: TObject;
ToolNum: Smallint;
X1, Y1,
X2, Y2, Distance:do
uble;
Shift, Ctrl: WordBool;
var EnableDefault: WordBool);
var
distStr: string;
sngTemp : Single;
begin
begin
memo1.Lines.Add(floattostr(x1)+'==='+floattostr(y1));
memo1.Lines.Add(floattostr(x2)+'==='+floattostr(y2));
sngTemp := sngTemp +Map1.distance(x1,y1,x2,y2);
showmessage(floattostr(sngtemp));
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Map1.Currenttool := 1;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
unusedParam: OleVariant;
begin
Map1.CreateCustomTool(1, miToolTypeLine, miSizeCursor, miSizeCursor, miSizeCursor, unusedParam);
end;
end.