procedure TForm1.Map1ToolUsed(ASender: TObject; ToolNum: Smallint; X1,
Y1, X2, Y2, Distance: Double; Shift, Ctrl: WordBool;
var EnableDefault: WordBool);
Var
i : Integer;
fID : String;
searchType : Integer;
dist : OleVariant;
pt : Variant;
curFeatures : Variant;
rc : Variant;
obj : Variant;
featureSearchLayer : Variant;ftrNew: CmapXFeature;
arrVals: Variant; //leee 030621
idx,NodeCnt:integer;
NodeString:String;
ds: CMapxDataset;
rv: CMapxRowvalue;
rvs: CMapxRowvalues;
ftr :CMapxFeature;
ftrLayer :CmapxLayer;
begin
pt := CreateOleObject('MapX.Point.5');
// Clear Search Results listif ToolNum <> SEARCH_POINT_TOOL then
begin
// Set SearchType based on what key user may have down
if (Shift And Not Ctrl) then
searchType := miSearchTypePartiallyWithin
else if (Ctrl And Not Shift) then
searchType := miSearchTypeEntirelyWithin
else
searchType := miSearchTypeCentroidWithin;
end;
if(ToolNum=miSelectTool ) then
begin
ftrLayer:=Map1.Layers.Item[1];
if (ctrl) thenftrLayer.Selection.SelectByPoint(X1, Y1, miSelectionAppend,emptyparam)
else if (Shift) then
ftrLayer.Selection.SelectByPoint(X1, Y1, miSelectionRemove,emptyparam)
else
ftrLayer.Selection.SelectByPoint(X1, Y1, miSelectionNew,emptyparam);if (ftrLayer.selection.count >= 1) //0306 lee 设计
then
begin
ds := Map1.Datasets.Add(miDataSetLayer, ftrLayer,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam);obj:=ftrLayer.Selection.Item[ftrLayer.selection.count]; //此处示例取得最后一个Feature ,也可用循环语句取得所有Feature
// ftrLayer.BeginAccess( miAccessReadWrite);
rvs:=ds.Rowvalues[obj];rvs._Item(1).value:=aaaaa; //为第一个字段赋值(本例图元有三个属性)
rvs._Item(2).value:=bbbbb;//为第二个字段赋值rvs._Item(3).value:=ccccc;//为第三个字段赋值
obj.Update(true,rvs);
// ftrLayer.EndAccess( miAccessEnd);end;
end;
end;
再在一个BUTTON的CLUCK事件中加入以下代码:
map1.CurrentTool:=miSelectTool;当点击这个BUTTON后,再点选图元,被选中图元的属性就可以被修改
MAPX中修改图元的属性值
最新推荐文章于 2022-11-17 18:04:39 发布