N
neverdeath
Unregistered / Unconfirmed
GUEST, unregistred user!
这是本论坛的帖子,我试了下不行,请教!
在With m_Fea.Parts.Item[1]do
出现 Not enough actual parameters,不知怎么回事,看了其他一些,差不多都是这样,但为什么不行么?
delphi+mapx5的鹰眼
加入两个mapx控件,然后粘贴如下代码就可以实现鹰眼
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, MapXLib_TLB;
type
TForm1 = class(TForm)
Map1: TMap;
Map2: TMap;
procedure Map1MapViewChanged(Sender: TObject);
procedure Map2MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
m_Layer:Layer;
//鹰眼图上临时图层
m_Fea:MapXLib_tlb.Feature;
//鹰眼图上反映主地图窗口位置的Feature
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Map1MapViewChanged(Sender: TObject);
var
tempFea:MapXLib_tlb.Feature;
//声明Feature变量
//tempPnts:MapXLib_tlb.Points;
//声明Points变量
tempStyle:MapXLib_tlb.Style;
//声明Style变量
begin
if map1.geoset='' then
exit;
//矩形边框还没有创建时
If m_Layer.AllFeatures.Count = 0 then
//设置矩形边框样式
begin
tempstyle:=Mapxlib_tlb.CoStyle.Create
tempStyle.RegionPattern := miPatternNoFill;
//设置Style的矩形内部填充样式
tempStyle.RegionBorderColor := 255;
//设置Style的矩形边框颜色
tempStyle.RegionBorderWidth := 1
//设置Style的矩形边框宽度
//在图层创建大小为Map1的边界的Rectangle对象
tempFea :=Map1.FeatureFactory.CreateRegion(Map1.Bounds, tempStyle)
m_Fea := m_Layer.AddFeature(tempFea,EmptyParam);//添加矩形边框
end
else
//否则,根据Map1的视野变化改变矩形边框的大小和位置
begin
With m_Fea.Parts.Item[1]do
begin
m_fea.Parts.Item[1].RemoveAll
m_fea.Parts.Item[1].AddXY(map1.Bounds.XMin ,map1.Bounds.YMin,EmptyParam );
m_fea.Parts.Item[1].AddXY(map1.Bounds.XMax ,map1.Bounds.YMin,EmptyParam );
m_fea.Parts.Item[1].AddXY(map1.Bounds.XMax ,map1.Bounds.YMax,EmptyParam );
m_fea.Parts.Item[1].AddXY(map1.Bounds.XMin, map1.Bounds.YMax,EmptyParam );
m_Fea.Update(EmptyParam,EmptyParam);
end;
m_Fea.Update(EmptyParam,EmptyParam);
//更新显示
end;
end;
procedure TForm1.Map2MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
ScreenX,ScreenY:Single;
MapX :do
uble;
//定义x坐标变量
MapY :do
uble;
//定义y坐标变量
begin
ScreenX :=x
ScreenY :=y
//把屏幕坐标转换为地图坐标
Map2.ConvertCoord(ScreenX,ScreenY,MapX,MapY,1 );
//设置主图的中心x坐标和y坐标
Map1.ZoomTo(map1.Zoom,MapX ,MapY);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
m_Layer := Map2.Layers.CreateLayer('Rectlayer',EmptyParam,EmptyParam,EmptyParam,EmptyParam);
//在Map2创建图层
end;
end.
在With m_Fea.Parts.Item[1]do
出现 Not enough actual parameters,不知怎么回事,看了其他一些,差不多都是这样,但为什么不行么?
delphi+mapx5的鹰眼
加入两个mapx控件,然后粘贴如下代码就可以实现鹰眼
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, MapXLib_TLB;
type
TForm1 = class(TForm)
Map1: TMap;
Map2: TMap;
procedure Map1MapViewChanged(Sender: TObject);
procedure Map2MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
m_Layer:Layer;
//鹰眼图上临时图层
m_Fea:MapXLib_tlb.Feature;
//鹰眼图上反映主地图窗口位置的Feature
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Map1MapViewChanged(Sender: TObject);
var
tempFea:MapXLib_tlb.Feature;
//声明Feature变量
//tempPnts:MapXLib_tlb.Points;
//声明Points变量
tempStyle:MapXLib_tlb.Style;
//声明Style变量
begin
if map1.geoset='' then
exit;
//矩形边框还没有创建时
If m_Layer.AllFeatures.Count = 0 then
//设置矩形边框样式
begin
tempstyle:=Mapxlib_tlb.CoStyle.Create
tempStyle.RegionPattern := miPatternNoFill;
//设置Style的矩形内部填充样式
tempStyle.RegionBorderColor := 255;
//设置Style的矩形边框颜色
tempStyle.RegionBorderWidth := 1
//设置Style的矩形边框宽度
//在图层创建大小为Map1的边界的Rectangle对象
tempFea :=Map1.FeatureFactory.CreateRegion(Map1.Bounds, tempStyle)
m_Fea := m_Layer.AddFeature(tempFea,EmptyParam);//添加矩形边框
end
else
//否则,根据Map1的视野变化改变矩形边框的大小和位置
begin
With m_Fea.Parts.Item[1]do
begin
m_fea.Parts.Item[1].RemoveAll
m_fea.Parts.Item[1].AddXY(map1.Bounds.XMin ,map1.Bounds.YMin,EmptyParam );
m_fea.Parts.Item[1].AddXY(map1.Bounds.XMax ,map1.Bounds.YMin,EmptyParam );
m_fea.Parts.Item[1].AddXY(map1.Bounds.XMax ,map1.Bounds.YMax,EmptyParam );
m_fea.Parts.Item[1].AddXY(map1.Bounds.XMin, map1.Bounds.YMax,EmptyParam );
m_Fea.Update(EmptyParam,EmptyParam);
end;
m_Fea.Update(EmptyParam,EmptyParam);
//更新显示
end;
end;
procedure TForm1.Map2MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
ScreenX,ScreenY:Single;
MapX :do
uble;
//定义x坐标变量
MapY :do
uble;
//定义y坐标变量
begin
ScreenX :=x
ScreenY :=y
//把屏幕坐标转换为地图坐标
Map2.ConvertCoord(ScreenX,ScreenY,MapX,MapY,1 );
//设置主图的中心x坐标和y坐标
Map1.ZoomTo(map1.Zoom,MapX ,MapY);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
m_Layer := Map2.Layers.CreateLayer('Rectlayer',EmptyParam,EmptyParam,EmptyParam,EmptyParam);
//在Map2创建图层
end;
end.