只是将在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.
本文详细介绍如何在ArcMap中将动态标注转换为永久注记,包括显示标注及转换过程。通过具体代码演示,适用于使用VisualStudio2010与ArcEngine10.1进行地理信息系统开发的人员。
842

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



