下面是完整代码,求高人指点,在网上找了一上午 没找到解决方法,在下是新手,刚接触gis 求大侠们不吝赐教,谢谢了……非常感谢!!
unit gis1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, MapXLib_TLB, ComCtrls;
type
TForm1 = class(TForm)
Map1: TMap;
Button1: TButton;
StatusBar1: TStatusBar;
procedure FormCreate(Sender: TObject);
procedure Map1PolyToolUsed(Sender: TObject; ToolNum: Smallint;
Flags: Integer; const Points: IDispatch; bShift, bCtrl: WordBool;
var EnableDefault: WordBool);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
MYTOOL_DISTANCE=100;
implementation
{$R *.dfm}
//{$WARN SYMBOL_PLATFORM OFF}
procedure TForm1.FormCreate(Sender: TObject);
begin
map1.CurrentTool:=miPanTool;
Map1.CreateCustomTool(MYTOOL_DISTANCE, miToolTypePoly,miCrossCursor, EmptyParam, EmptyParam, EmptyParam);
end;
procedure TForm1.Map1PolyToolUsed(Sender: TObject; ToolNum: Smallint;
Flags: Integer; const Points: IDispatch; bShift, bCtrl: WordBool;
var EnableDefault: WordBool);
var
DisSum : Double ;
i: Integer;
x1, y1, x2 , y2: Double ;
begin
DisSum:=0;
if Flags=miPolyToolInProgress then
begin
if ToolNum= MYTOOL_DISTANCE then
begin
for i:=1 to CMapXPoints(Points).Count-1 do //应该就是for循环这一片的问题
begin
x1:=CMapXPoints(Points).Item[i].X;
y1:=CMapXPoints(Points).Item[i].Y;
x2:=CMapXPoints(Points).Item[i+1].X;
y2:=CMapXPoints(Points).Item[i+1].Y;
DisSum:=DisSum+Map1.Distance(x1,y1,x2,y2);
end;
Statusbar1.Panels[0].Text:=floattostr(dissum);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
map1.CurrentTool :=MYTOOL_DISTANCE;
end;
end.
å¤è°¢ä½ çåçï¼å·²ç»è§£å³äº 谢谢ï¼
多谢你的回答,已经解决了 谢谢!
多谢你的回答,已经解决了 谢谢!
多谢你的回答,已经解决了 谢谢!
...运行的时候每当我点到第二个点到时候开始报错list index out...
2、既然怀疑在这部分出问题了,你可以试着修改数组相关的变量,或者单行屏蔽程序执行看下到底是哪个出的问题啊