增加图元

时间:2022-04-23
本文章向大家介绍增加图元,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

        以前增加图元,总是用复制图元的方式,受的限制较大。今天试着用创建的方式来增加,效果还行,需要注意:

  • 用datasets太麻烦
  • 用keyfield必须是对map1下的layer的,即对已经加入的ftr的。
  • 默认情况下,keyvalue是对第一列的。
  • 写了一半的代码:

'添加图元

   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