W
weiyancheng1181
Unregistered / Unconfirmed
GUEST, unregistred user!
delphi+mapx 图元在地图与listbox之间关联出了问题
我的想法:在地图上新建一个图元,同时在listbox里添加一项,删除图元的时候同时删除listbox里对应的一项,但是始终出问题,请高手指点!
procedure TF_main.UpdateCarList;//刷新listbox
var iSelect,count:integer;
begin
iSelect := Listbox1.ItemIndex;
ListBox1.Clear;
for count := 1 to iCount do
ListBox1.Items.Add(fArray[count-1].sName);
ListBox1.ItemIndex := iSelect;
end;
后边是删除:
procedure Tf_main.BitBtn21Click(Sender: TObject);
var
select : variant;//cmapxselection;
i,j,k : integer;
lyr,l : cmapxlayer;
begin
i := 2;
begin
if (listbox1.ItemIndex=-1) then
messagedlg('没有标注目标被选中!',mtcustom,[mbok],0)
else
begin
lyr := map1.Layers.Item(i);
select := lyr.Selection; //选中图元
l:=map1.Layers.AnimationLayer;
lyr.Editable := true;
for j := 1 to select.count do
begin
lyr.DeleteFeature(select.item(j));
listbox1.Items.Delete(iNum);
// for k:=1 to lyr.AllFeatures.Count do
// if (listbox1.Items.Names[k] = select.item(j).name) then
// listbox1.Items.Delete(k);
// map1.Layers.AnimationLayer.Refresh;
// end;
end;
end;
end;
end;
我的想法:在地图上新建一个图元,同时在listbox里添加一项,删除图元的时候同时删除listbox里对应的一项,但是始终出问题,请高手指点!
procedure TF_main.UpdateCarList;//刷新listbox
var iSelect,count:integer;
begin
iSelect := Listbox1.ItemIndex;
ListBox1.Clear;
for count := 1 to iCount do
ListBox1.Items.Add(fArray[count-1].sName);
ListBox1.ItemIndex := iSelect;
end;
后边是删除:
procedure Tf_main.BitBtn21Click(Sender: TObject);
var
select : variant;//cmapxselection;
i,j,k : integer;
lyr,l : cmapxlayer;
begin
i := 2;
begin
if (listbox1.ItemIndex=-1) then
messagedlg('没有标注目标被选中!',mtcustom,[mbok],0)
else
begin
lyr := map1.Layers.Item(i);
select := lyr.Selection; //选中图元
l:=map1.Layers.AnimationLayer;
lyr.Editable := true;
for j := 1 to select.count do
begin
lyr.DeleteFeature(select.item(j));
listbox1.Items.Delete(iNum);
// for k:=1 to lyr.AllFeatures.Count do
// if (listbox1.Items.Names[k] = select.item(j).name) then
// listbox1.Items.Delete(k);
// map1.Layers.AnimationLayer.Refresh;
// end;
end;
end;
end;
end;