O
okgxsh
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, MapXLib_TLB;
const
miMDistanceRuler=501;
type
TForm1 = class(TForm)
Map1: TMap;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Memo1: TMemo;
Button5: TButton;
Button6: TButton;
procedure Map1PolyToolUsed(Sender: TObject;
ToolNum: Smallint;
Flags: Integer;
const Points: IDispatch;
bShift, bCtrl: WordBool;
var EnableDefault: WordBool);
procedure Map1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Map1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Map1ToolUsed(Sender: TObject;
ToolNum: Smallint;
X1, Y1, X2,
Y2, Distance:do
uble;
Shift, Ctrl: WordBool;
var EnableDefault: WordBool);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
mScreenX,mScreeny:single;
//miMDistanceRuler:integer;
mRulerStart:Boolean;
mLongitude, mLatitude,mDistance,mTotalDistance:double;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Map1PolyToolUsed(Sender: TObject;
ToolNum: Smallint;
Flags: Integer;
const Points: IDispatch;
bShift, bCtrl: WordBool;
var EnableDefault: WordBool);
var
ftrsFinds : Features;
Newobj : Feature;
begin
if ToolNum = 501 then
//测距离
case Flags of
miPolyToolbegin
: begin
mRulerStart := true;
mTotalDistance := 0;
end;
miPolyToolInProgress: mTotalDistance :=mTotalDistance + mDistance;
miPolyToolEnd: mRulerStart := false;
end;
end;
procedure TForm1.Map1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
mScreenX := X;
mScreenY := Y;
Map1.ConvertCoord(mScreenX, mScreenY, mLongitude, mLatitude, miScreenToMap);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Map1.CurrentTool :=miMDistanceRuler;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
unusedParam: OleVariant;
begin
map1.Layers.CreateLayer('temp', EmptyParam,1, EmptyParam, EmptyParam);
Map1.Layers.Item(1).Editable := True;
Map1.Layers.InsertionLayer := Map1.Layers.Item(1);
Map1.CreateCustomTool(1, miToolTypeLine, miSizeCursor, miSizeCursor, miSizeCursor, unusedParam);
Map1.CreateCustomTool(miMDistanceRuler, miToolTypePoly, miLabelCursor, EmptyParam, EmptyParam, EmptyParam);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
map1.Layers.Remove ('temp');
end;
procedure TForm1.Map1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
var
d, m : integer;
mLon, mLat :do
uble;
begin
mScreenX := X;
mScreenY := Y;
Map1.ConvertCoord(mScreenX, mScreenY, mLon, mLat, miScreenToMap);
if (Map1.CurrentTool=miMDistanceRuler) and mRulerStart then
begin
mDistance := Map1.Distance(mLongitude, mLatitude, mLon, mLat);
memo1.Lines.Add(FloatToStrF(mDistance, ffNumber, 10, 3)+' 公里');
memo1.Lines.Add(FloatToStrF(mDistance+mTotalDistance, ffNumber, 10, 3)+' 公里');
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Map1.CurrentTool :=1;
end;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, MapXLib_TLB;
const
miMDistanceRuler=501;
type
TForm1 = class(TForm)
Map1: TMap;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Memo1: TMemo;
Button5: TButton;
Button6: TButton;
procedure Map1PolyToolUsed(Sender: TObject;
ToolNum: Smallint;
Flags: Integer;
const Points: IDispatch;
bShift, bCtrl: WordBool;
var EnableDefault: WordBool);
procedure Map1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Map1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Map1ToolUsed(Sender: TObject;
ToolNum: Smallint;
X1, Y1, X2,
Y2, Distance:do
uble;
Shift, Ctrl: WordBool;
var EnableDefault: WordBool);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
mScreenX,mScreeny:single;
//miMDistanceRuler:integer;
mRulerStart:Boolean;
mLongitude, mLatitude,mDistance,mTotalDistance:double;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Map1PolyToolUsed(Sender: TObject;
ToolNum: Smallint;
Flags: Integer;
const Points: IDispatch;
bShift, bCtrl: WordBool;
var EnableDefault: WordBool);
var
ftrsFinds : Features;
Newobj : Feature;
begin
if ToolNum = 501 then
//测距离
case Flags of
miPolyToolbegin
: begin
mRulerStart := true;
mTotalDistance := 0;
end;
miPolyToolInProgress: mTotalDistance :=mTotalDistance + mDistance;
miPolyToolEnd: mRulerStart := false;
end;
end;
procedure TForm1.Map1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
mScreenX := X;
mScreenY := Y;
Map1.ConvertCoord(mScreenX, mScreenY, mLongitude, mLatitude, miScreenToMap);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Map1.CurrentTool :=miMDistanceRuler;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
unusedParam: OleVariant;
begin
map1.Layers.CreateLayer('temp', EmptyParam,1, EmptyParam, EmptyParam);
Map1.Layers.Item(1).Editable := True;
Map1.Layers.InsertionLayer := Map1.Layers.Item(1);
Map1.CreateCustomTool(1, miToolTypeLine, miSizeCursor, miSizeCursor, miSizeCursor, unusedParam);
Map1.CreateCustomTool(miMDistanceRuler, miToolTypePoly, miLabelCursor, EmptyParam, EmptyParam, EmptyParam);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
map1.Layers.Remove ('temp');
end;
procedure TForm1.Map1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
var
d, m : integer;
mLon, mLat :do
uble;
begin
mScreenX := X;
mScreenY := Y;
Map1.ConvertCoord(mScreenX, mScreenY, mLon, mLat, miScreenToMap);
if (Map1.CurrentTool=miMDistanceRuler) and mRulerStart then
begin
mDistance := Map1.Distance(mLongitude, mLatitude, mLon, mLat);
memo1.Lines.Add(FloatToStrF(mDistance, ffNumber, 10, 3)+' 公里');
memo1.Lines.Add(FloatToStrF(mDistance+mTotalDistance, ffNumber, 10, 3)+' 公里');
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Map1.CurrentTool :=1;
end;