‘释放
SET Pnt = Nothing
SET FeaFac = Nothing
SET Lyr = Nothing
SET Ftr = Nothing
‘以上代码放在MapX的ToolUsed事件下
单独修改某个图元的样式:SET Ftr.Style=NewStyle,再用Update 即可
2、 创建一个线矩形
Dim Pnts AS MapXLib.Points
With NewStyle
.LineColor=Rgb(0, 0,255)
End With
‘第一个点
Pnt.Set X1,Y1
Pnts.add Pnt
‘第二个点
Pnt.Set X2,Y1
Pnts.add Pnt
‘第三个点
Pnt.Set X2,Y2
Pnts.add Pnt
‘第四个点
Pnt.Set X1,Y2
Pnts.add Pnt
‘第五个点
Pnt.Set X1,Y1
Pnts.add Pnt
‘创建线矩形
SET Ftr=FeaFac.CreateLine(Pnts,NewStyle)
Lyr.AddFeature Ftr
Lyr.Refresh
3、 上面创建对象中存在的问题:并未对其数据数据进行赋值
创建对象的同时创建其数据集合
Dim Pnt AS MapXLib.Point
Dim FeaFac AS MapXLib.FeatureFactory
Dim Lyr AS MapXLib.Layer
Dim Ftr AS MapXLib.Feature
Dim NewStyle AS MapXLib.Style
Dim ds AS MapXLib.Dataset
Dim Flds AS MapXLib.Fields
‘绑定
SET Lyr=MainMap.Layers.Item(LayerName)
SET ds=Lyr.Datasets.Item(1)
Set Flds=ds.Fields
SET FeaFac=mainmap.featurefactory
‘设置点对象样式
With NewStyle
.SymbolType = miSymbolTypeBitmap
.SymbolBitmapSize = 24
.SymbolBitmapTransparent = False
.SymbolBitmapName = "YIEL2-32.BMP"
End With
Mainmap.AutoRedraw=False ‘禁止自动刷新
Lyr.Editable=True ‘置当前图层为可写状态
‘创建点对象
pnt.set X1,Y1
‘创建图形
Set Ftr=FeaFac. CreateSymbol (Pnt,Newstyle) ‘创建符号
‘Set Ftr=FeaFac. CreateSymbol (Pnt,MainMap.DefaultStyle)
‘设置属性
For I=1 to Flds.Count
Lyr.KeyFields=Flds.Item(i).Name
Ftr.KeyValue=ValueStr(I) ‘这里并没有对字段类型进行判断
Next
‘另外一种方法:使用RowValues和RowValue对象
‘添加
Lyr.AddFeature Ftr
Lyr.Refresh
Mainmap.AutoRedraw=True
Lyr.Editable=False
‘释放
SET Pnt = Nothing
SET FeaFac = Nothing
SET Lyr = Nothing
SET Ftr = Nothing
SET ds = Nothing
SET Flds = Nothing
4、 创建表
(1) 临时表:
A、用MainMap.Layers.CreateLayer方法创建临时表。但这个临时表只有一个字段:GeoName( Char 24)。程






