以前增加图元,总是用复制图元的方式,受的限制较大。今天试着用创建的方式来增加,效果还行,需要注意:
- 用datasets太麻烦
- 用keyfield必须是对map1下的layer的,即对已经加入的ftr的。
- 默认情况下,keyvalue是对第一列的。
- 写了一半的代码:
'添加图元
代码语言:js复制 Public Function AddFeature(keyword As String) As Feature
Dim ftr As New Feature
Dim addftr As Feature
ftr.Attach Map1
ftr.Type = miFeatureTypeSymbol
ftr.Style = mainlayer.Style
ftr.Point.Set Map1.CenterX, Map1.CenterY
Dim ds As Dataset
Set addftr = mainlayer.AddFeature(ftr)
mainlayer.KeyField = NameField
addftr.KeyValue = keyword
addftr.Update
Set AddFeature = addftr
End Function