添加图元的问题(100分)

  • 主题发起人 主题发起人 衣雪峰
  • 开始时间 开始时间

衣雪峰

Unregistered / Unconfirmed
GUEST, unregistred user!
我在图层上添加了一个图元:并且添加了它的ID,NAME,经纬度等信息。
VB的代码是:执行没问题但是如果换成DELPHI7就有问题了(红色的部分)
Dim lyrNew As MapXLib.Layer
Dim ptNew As New MapXLib.Point
Dim ftrNew As MapXLib.Feature
Dim ff As MapXLib.FeatureFactory
Dim li As New MapXLib.LayerInfo
Dim rvs As New MapXLib.RowValues
Dim ds As MapXLib.Dataset
Dim NewStyle As New MapXLib.Style
Dim i As Integer
Set ff = Map1.FeatureFactory
Set lyrNew = Map1.Layers.Item(layname)
Set ds = Map1.Datasets.Add(miDataSetLayer, lyrNew)
Set rvs = ds.RowValues(ds.RowCount)
With NewStyle
.SymbolType = miSymbolTypeBitmap
.SymbolBitmapSize = DrawNum
.SymbolBitmapTransparent = True
.SymbolBitmapName = PictureName
End With
Map1.AutoRedraw = False
lyrNew.Editable = True
[red] rvs.Item(1).value = StationID 就是这里VB执行没问题
rvs.Item(2).value = StationName
rvs.Item(3).value = StationX
rvs.Item(4).value = StationY
rvs.Item(5).value = PlaceID_For_Update
rvs.Item(6).value = RoadID_For_Update[/red]
ptNew.Set StationX, StationY

Set ftrNew = ff.CreateSymbol(ptNew, NewStyle)
Set ftrNew = lyrNew.AddFeature(ftrNew, rvs)
Call ShowLabel
Map1.AutoRedraw = True
lyrNew.Refresh
lyrNew.Editable = False
 
rvs.Item(1).value = StationID
rvs.Item(2).value = StationName
rvs.Item(3).value = StationX
rvs.Item(4).value = StationY
rvs.Item(5).value = PlaceID_For_Update
rvs.Item(6).value = RoadID_For_Update
在DELPHI7中只能执行rvs.Item(1).value = StationID
执行其他的就报错。。。。请问该如何解决
 
直接能在delphi这样执行吗?
 
[:(!]
拜托我还没有笨到那种程度:
rvs.Item(1).Value:=IntToStr(borough_ID);
rvs.Item(2).Value:=IntToStr(borough_ID);
rvs.Item(3).value:=zoomx;
rvs.Item(4).value:=zoomy;
 
当执行到
rvs.Item(2).Value:=IntToStr(borough_ID);
时出错。
错误信息是
No object was found using the index specified
 
[:)]能不能把你delphi中实现的unit代码粘来看看呀
 
给你一段添加图元的代码:
pt := CoPoint.Create;
pt.Set_(X1, Y1);
lyr := MapCtrl.Layers.Item['station_' + strCurrentMapNbr];

if get_symbol('station',INDEX_STATION,1) then

ftr := MapCtrl.FeatureFactory.CreateSymbol(pt, m_stlFeatures[INDEX_STATION,1])
else

ftr := MapCtrl.FeatureFactory.CreateSymbol(pt,mapctrl.defaultstyle);

labData:= MapCtrl.Datasets['station_'+strCurrentMapNbr];
vrowvalue:=corowvalue.create;
vrowvalues:=corowvalues.Create;
vrowvalue.Dataset:= labData;
vrowvalue.Field:=labData.Fields['id'];
vrowvalue.Value:=strOID;
vrowvalues.Add(vrowvalue);
vrowvalue.Field:=labData.Fields['name'];
vrowvalue.Value:=strName;
vrowvalues.Add(vrowvalue);
vrowvalue.Field:=labData.Fields['MAPNBR'];
vrowvalue.Value:=strCurrentMapNbr;
vrowvalues.Add(vrowvalue);
vrowvalue.Field:=labData.Fields['AreaId'];
vrowvalue.Value:=gsAreaId;
vrowvalues.Add(vrowvalue);
ftrUpdate := lyr.AddFeature(ftr,vrowvalues);

//设置选中状态——闪烁
ftrUpdate.Layer.Selection.SelectByID(ftrUpdate.FeatureKey, miSelectionNew);

AddLog('1600502','新建局站成功!局站名称:'+strName,'C');
 
多人接受答案了。
 
后退
顶部