Public Sub AddSDECoverageLayer()
Dim pWorkFact As IWorkspaceFactory2
Dim pFWorkspace As IFeatureWorkspace
Dim pFClass As IFeatureClass
Dim pFLayer As IFeatureLayer
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pAV As IActiveView
'Open Feature Class
Set pWorkFact = New SdeWorkspaceFactory
Set pFWorkspace = pWorkFact.OpenFromString("server=swfcln;instance=5151;user=sde;password=sde;version=sde.default", 0)
Set pFClass = pFWorkspace.OpenFeatureClass("cities")
'Create new layer
Set pFLayer = New FeatureLayer
Set pFLayer.FeatureClass = pFClass
pFLayer.Name = pFClass.AliasName
'Add layer to map
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
Set pAV = pMap
pMap.AddLayer pFLayer
pAV.Refresh
End Sub
本文介绍了一种使用 ArcGIS 的方法来从 SDE 数据库中加载“cities”图层,并将其添加到当前地图文档的活动视图中。通过创建 SDE 工作空间工厂对象并打开指定的工作空间字符串,可以获取到特征类。接着创建新的图层对象,并将该特征类设置为图层的数据源。最后将新建的图层添加到地图中。
4371

被折叠的 条评论
为什么被折叠?



