ArcObject之添加矢量图层

(1)添加矢量图层——方法1

Dim sPath As String
sPath = "F:\AE 数据"    '"F:\AE 数据"为所有图层文件所在的文件夹目录
Me.AxMapControl1.AddShapeFile(sPath, "object_pt")     '"object_pt"为其中之一的图层文件

 

(2)添加矢量图层——方法2

Dim sPath As String
sPath = "F:\AE 数据"
Dim pWorkSpaceFactory As IWorkspaceFactory
pWorkSpaceFactory = New ShapefileWorkspaceFactory

   '利用ShapefileWorkSpaceFactory创建FeatureWorkSpace
Dim pFeatureWorkSpace As IFeatureWorkspace
pFeatureWorkSpace = pWorkSpaceFactory.OpenFromFile(sPath, 0)

   '将FeatureWorkSpace中的指定FeatureClass  赋予  FeatureLayer的FeatureClass属性

Dim pFeatureLayer As IFeatureLayer
pFeatureLayer = New FeatureLayer
pFeatureLayer.FeatureClass = pFeatureWorkSpace.OpenFeatureClass("object_pl")
pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName

   '添加图层
Me.AxMapControl1.AddLayer(pFeatureLayer)

 

(3)添加矢量图层——方法3

Dim pFileName As IFileName
pFileName = New FileName
pFileName.Path = "F:\AE 数据\object_pg.shp"

     '用LayerFactoryHelper来创建图层集(EnumLayer)

Dim pLayerFactoryHelp As ILayerFactoryHelper
pLayerFactoryHelp = New LayerFactoryHelper
Dim pEnumLayer As IEnumLayer
pEnumLayer = pLayerFactoryHelp.CreateLayersFromName(pFileName)

pEnumLayer.Reset()

     '将图层集(EnumLayer)中的特曾逐个添加到地图axMapControl中
Dim pLayer As ILayer
pLayer = pEnumLayer.Next
Do While Not pLayer Is Nothing
      Me.AxMapControl1.AddLayer(pLayer)
       pLayer = pEnumLayer.Next
Loop

你可能感兴趣的:(object)