mapx中监控车辆时,如何画多个点+附加小图+附加文字标注(动态更新)(50分)

O

okfly

Unregistered / Unconfirmed
GUEST, unregistred user!
delphi mapx中监控车辆时,如何画多个车辆点+附加小图+附加文字标注(动态更新坐标)
最好有点代码谢谢!!!
 
定义几个Feature(车辆点+附加小图+附加文字标注),然后把它们加到图层中。当位置改变时,改变Feature的位置就行了
 
这个思路我也知道!单是不知道如何写代码!?yostgxf:能不能写点带吗?多谢!!!
 
procedure TMapsForm.MovePoint(X, Y:do
uble);
var
DrawPoint:CMapXPoint;
//创建点
CarFeature:CMapXFeature;
//点对象类型
TempFeature:CMapXFeature;
aaa:CMapXStyle;
begin

if CurrentKey>0 then
begin
//移动
TempFeature:=MapLayerAni.GetFeatureById(CurrentKey);
//在图形上得到需要移动的点对象
TempFeature.Point.Set_(X,Y);
//更改坐标
TempFeature.Update(EmptyParam, EmptyParam);
//更新图显示
end
else

begin

DrawPoint:=CoPoint.Create;
//创建点
DrawPoint.Set_(X,Y);
//GPS打点
CarFeature:=CreateOleObject('MapX.Feature.4') as CMapXFeature;
//创建图对象
aaa:=CreateOleObject('MapX.Style.4') as CMapXStyle;
aaa.SymbolType:=1;
aaa.SymbolBitmapTransparent:=true;
aaa.SymbolBitmapName:='stop1-32.BMP';
aaa.SymbolBitmapSize:=10;
Map1.DefaultStyle:=aaa;
CarFeature:= Map1.FeatureFactory.CreateSymbol(DrawPoint,Map1.DefaultStyle);
//点形状
TempFeature:=MapLayerAni.AddFeature(CarFeature,EmptyParam);
//加载到图形上
CurrentKey:=TempFeature.FeatureID;
//得到新加载图象的ID
end;

CheckPoint(X,y,TempFeature);
//判断是否超出窗口视图范围
end;

 
楼上的代码应该可行,可能效率低了点。(我现在忙 :))
 
yostgxf: 大哥:能否百忙之中,写点效率高的代码?谢谢谢谢!
 
特此鸣谢:zcroot_0411大虾帮忙!谢谢!!
 
不好意思,下午有时间一定给你贴上,最晚到晚上
 
这样行了吧
private
GoalFeature : array of Feature;
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
i : Integer;
Bitmaps: BitmapSymbols;
StyleBitmap : Style;
pt:point;
fNewSymbol: Variant;
fMapSymbol: Feature;
lyrLayer :Layer;
begin

Bitmaps := CoBitmapSymbols.Create;
//Bitmaps.Count
StyleBitmap := coStyle.Create;
with StyleBitmapdo

begin

SymbolType := miSymbolTypeBitmap;
SymbolBitmapTransparent := True;
SymbolBitmapSize := 24;
end;

//显示目标图标
pt:=CoPoint.Create;
pt.Set_(0, 0);

SetLength(GoalFeature, 10);//你车的数量
for i:=0 to Length(GoalFeature)-1do

begin

StyleBitmap.SymbolBitmapName := Bitmaps.Item(2).Name;
//你选的图标
fNewSymbol := Map1.FeatureFactory.CreateSymbol(pt, StyleBitmap);
fNewSymbol.KeyValue := '你的文本';
// fNewSymbol := lyrLayer.AddFeature(fNewSymbol, EmptyParam);
//你可以重复往里面加你的Feature
GoalFeature := lyrLayer.AddFeature(fNewSymbol, EmptyParam);
end;

VarClear(fNewSymbol);
end;


procedure TForm1.Timer1Timer(Sender: TObject);
var
i : Integer;
begin

for i:=0 to Length(GoalFeature)-1do

begin

GoalFeature.Point.Set_(Lon, Lat);// Lon, Lat是你的位置
GoalFeature.Update(EmptyParam, EmptyParam);
end;

end;


 
yostgxf:大哥真是个热心肠·!!

谢谢谢谢,亿万分的感谢!支持yostgxf!
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
顶部