ArcObject之添加向量圖層

來源:互聯網
上載者:User

(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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.