zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    sqlserver-一次updlock和withnolock和with check option 的报错原因分析
    类库文件引用web服务报错解决方法-在 ServiceModel 客户端配置部分中,找不到引用协定的默认终结点元素
    用timer自定义计划任务时间
    console 程序随系统启动及隐藏当前程序窗口
    爱积多合作农场正式上线试运营
    CSS-三列布局
    CSS-垂直居中
    form表单重置
    CSS3 选择器
    Tab选项卡
  • 原文地址:https://www.cnblogs.com/clgis/p/9907368.html
Copyright © 2011-2022 走看看