Add an Annotation FeatureClass from a Personal Geodatabase to ArcMap with ArcObjects
2009-05-15 12:34
609 查看
Procedure
Start ArcMap.Create a new UIButtonControl.
Right-click the UIButtonControl and select View Source.
Copy below code into the UIButtonControl's click event.
Dim strPathName As String
strPathName = "D:"temp"yellowstone.mdb" ' Replace with the name of your Personal Geodatabase
Modify the value of strPathName to reflect the location of your Personal Geodatabase.
Copy the code below into the UIButtonControl's click event, immediately after the code you entered in Step 4.
Dim strData As String
strData = "AnnoRoad" ' Replace with the name of your annotation FeatureClass
Modify the value of strData to point to the annotation Feature Class in your Personal Geodatabase.
Copy the code below into the UIButtonControl's click event, immediately after the code you entered in Step 6.
' Set up the WorkspaceFactory
Dim pWorkspaceName As IWorkspaceName
Set pWorkspaceName = New WorkspaceName
pWorkspaceName.WorkspaceFactoryProgID = "esricore.AccessWorkspaceFactory"
pWorkspaceName.PathName = strPathName
Dim pDatasetName As IDatasetName
Set pDatasetName = New FeatureClassName
pDatasetName.Name = strData
Set pDatasetName.WorkspaceName = pWorkspaceName
' Use a lightweight Name object to open the table.
Dim pName As IName
Set pName = pDatasetName ' QI
Dim pTable As ITable
Set pTable = pName.Open
Dim pFeatClass As IDataset
Set pFeatClass = ptable
Dim pFeatLay As IFeatureLayer
'IFDOGraphicsLayerFactory::OpenGraphicsLayer IS THE KEY to accessing the data!
Dim pFDOGraphicsLayerFactory As IFDOGraphicsLayerFactory
Set pFDOGraphicsLayerFactory = New FDOGraphicsLayerFactory
'*****************************************
' Modify this line of code
Set pFeatLay = pFDOGraphicsLayerFactory.OpenGraphicsLayer(pfeatclass.Workspace, Nothing, "AnnoRoad")
'*****************************************
'Assign the name in the Table of Contents
pFeatLay.Name = pFeatClass.Name
' Add the annotation to ArcMap
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pMap As IMap
Set pMap = pMxDoc.ActiveView
pMap.AddLayer pFeatLay
Dim pAV As IActiveView
Set pAV = pMap
pAV.Refresh
Modify the third argument passed to the OpenGraphicsLayer method to point to the input annotation Feature Class.
Test the code.
相关文章推荐
- a universal class to complete import data from an excel file into a database
- Creating An Instance Of The Com Component With Clsid {b9425246-4131-11d2-be48-004005a04edf} From The Iclassfactory Failed Due To The Following Error
- 基于Personal Geodatabase中的Feature class创建一个MXD文档
- 错误 An association from the table STUDENT refers to an unmapped class: com.pb.hibernate.po.Grade
- org.hibernate.MappingException: An association from the table tuser refers to an unmapped class: Role
- [Resolved] TF254006: No usable accounts are present in your configuration database. Use TfsConfig accounts /add to add an account and return to this wizard.
- hibernate错误:An association from the table ....... refers to an unmapped class
- An association from the table refers to an unmapped class
- How to create physical standby database with 11g RMAN DUPLICATE FROM ACTIVE DATABASE [ID 747250.1]
- weka Trying to add database driver (JDBC): jdbc.idbDriver - Error, not in CLASSPATH?
- An association from the table PersonAddress refers to an unmapped class
- Spring boot 报Add an implement,such as Hibernate Validator, to the classpath
- 出现此错误An association from the table refers to an unmapped class
- An association from the table work_output refers to an unmapped class: org.ejs.sys.model.Part
- ArcMap (ArcInfo) - How to Perform a Network Trace over a Geometric Network in a Geodatabase
- Add extra standby database to complete database migration to new servers with minimal outage
- An association from the table student refers to an unmapped class: com.test.model.Team
- Exception in thread "main" org.hibernate.AnnotationException: List/array has to be annotated with an
- Ubuntu无法升级An upgrade from 'vivid' to 'xenial' is not supported with this tool.
- An association from the table refers to an unmapped class