arcengine标注转注记

只是将在arcmap中添加注记的方式模拟了一遍,因此,首先显示标注(Label),而后将其转换为注记(Annotation)(Convert Label To Annotation)

/*****************************************************/

SHP文件不支持标注!

SHP文件不支持标注!

SHP文件不支持标注!

public void ShowLabels(IMap pMap,string pDisplayField,int index)
        {
            ILayer pLayer = pMap.get_Layer(index);
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
            pGeoFeatureLayer.DisplayField = pDisplayField;
            pGeoFeatureLayer.DisplayAnnotation = true;
        }
        public void ConvertLabelToAnnotation(IMap pMap,int layerindex,bool featureLinked,string AnnoName)
        {
            IConvertLabelsToAnnotation pConvertLabelToAnnotation = new ConvertLabelsToAnnotationClass();
            ITrackCancel pTrackCancel = new CancelTrackerClass();
            pConvertLabelToAnnotation.Initialize(pMap, esriAnnotationStorageType.esriDatabaseAnnotation, esriLabelWhichFeatures.esriAllFeatures, true, pTrackCancel, null);
            ILayer pLayer = pMap.get_Layer(layerindex);

            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;
            if (pGeoFeatureLayer == null) return;
            IFeatureClass pFeatureClass = pGeoFeatureLayer.FeatureClass;
            IDataset pDataset = pFeatureClass as IDataset;
            IWorkspace pWorkspace = pDataset.Workspace;
            IWorkspaceEdit pWorkspaceEdit = pWorkspace as IWorkspaceEdit;
            IFeatureWorkspace pFeatureWorkspace = pDataset.Workspace as IFeatureWorkspace;
            pConvertLabelToAnnotation.AddFeatureLayer(
                pGeoFeatureLayer,
                pGeoFeatureLayer.Name + "_"+AnnoName,
                pFeatureWorkspace,
                pFeatureClass.FeatureDataset,
                featureLinked,
                false,
                false,
                true,
                true,
                "");
            pConvertLabelToAnnotation.ConvertLabels();
            IEnumLayer pEnumLayer = pConvertLabelToAnnotation.AnnoLayers;
            pGeoFeatureLayer.DisplayAnnotation = false;
            pMap.AddLayers(pEnumLayer, true);
            IActiveView pActivew = pMap as IActiveView;
            pActivew.Refresh();
        }

实现简单,复制保存cs文件 就可用,Visual Studio 2010 +ArcEngine 10.1.

转载于:https://www.cnblogs.com/clgis/p/9907368.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值