Arcengine在Map里面加载注记图层

        IMapDocument pMapDocment = new MapDocument();
        pMapDocment.Open(madPathCopyTo);//打开mxd工程   madPathCopyTo为mxd路径
        IMap pMap = pMapDocment.get_Map(0);//获取第一个Layers
        IAnnotationLayer pAnnotationLayer;//声明一个注记图层
        IFeatureWorkspace pFeatureWorkspace = GetWorkspace(mdbPathCopy) as IFeatureWorkspace;//获取mdb数据库工作空间
        pAnnotationLayer = GetAnnoationFeatureLayer(pFeatureWorkspace,"T_point");//打开数据库中注记图层T_point
        pMap.AddLayer(pAnnotationLayer as ILayer);//加载到map中
        pMapDocment.Save();//保存

        /// <summary>
        /// 加载注记图层
        /// </summary>
        /// <param name="Path"></param>
        /// <returns></returns>
        public IAnnotationLayer GetAnnoationFeatureLayer(IFeatureWorkspace pFeatureWorkspace, string name)
        {
            IAnnotationLayerFactory pAnnotationLayerFactory = new FDOGraphicsLayerFactory() as IAnnotationLayerFactory;
            IAnnotationLayer pAnnotationLayer = pAnnotationLayerFactory.OpenAnnotationLayer(pFeatureWorkspace,null,name);
            return pAnnotationLayer;
        }

        这里打开注记图层要传三个参数进去,第一个是工作空间,第二个是数据集(可用null代替),第三个是名字。

        /// <summary>
        /// 获取Workspace
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public IWorkspace GetWorkspace(string path)
        {
            IWorkspace pWorkspace;
            if (path.Contains(".mdb"))
            {
                IWorkspaceFactory pWorkspaceFactory = new AccessWorkspaceFactory();
                pWorkspace = pWorkspaceFactory.OpenFromFile(path, 0);
            }
            else
            {
                IWorkspaceFactory pWorkspaceFactory = new FileGDBWorkspaceFactoryClass();
                pWorkspace = pWorkspaceFactory.OpenFromFile(path, 0);
            }
            return pWorkspace;
        }

 

 

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值