'1创建图层
Dim lyr As Layer
Set lyr = Map1.Layers.CreateLayer("Car")
Set Map1.Layers.AnimationLayer = lyr '定义为动态图层
'2新建图元
Dim newobj As New MapXLib.Feature 'stand-alone object
Dim obj As MapXLib.Feature 'to hold feature added to layer
Dim NewStyle As New MapXLib.Style
Dim str As String
newobj.Attach Map1
With NewStyle
.SymbolType = miSymbolTypeBitmap
.SymbolBitmapSize = 24
.SymbolBitmapTransparent = True
.SymbolBitmapName = "CAR1-32.BMP"
End With
newobj.Style = NewStyle '设置图元样式
newobj.Type = miFeatureTypeSymbol '设置图元类型
newobj.Point.Set Text1.Text,Text2.Text '设置图元位置
Set obj = Map1.Layers(1).AddFeature(newobj)
obj.Update
'3移动图元
Dim lyr As MapXLib.Layer
Set lyr = Map1.Layers("Car")
Dim ftr As New MapXLib.Feature
Set ftr = lyr.AllFeatures.Item(1)
'ftr.Point.Set 116,40 '重置图元位置
ftr.Offset 1#,1# '移动图元
ftr.Update
'4删除图元
Dim lyr As Layer
Set lyr = Map1.Layers("Car")
lyr.DeleteFeature (lyr.AllFeatures.Item(1))
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/thomas0yang/archive/2010/09/10/5875494.aspx