zoukankan      html  css  js  c++  java
  • 图层的自动标注

            /// <summary>
            /// 自动标注图层
            /// </summary>
            /// <param name="pGeoFlyr">矢量图层对象</param>
            /// <param name="pAutoLbl">动态标注对象</param>
            public void SetLayerAutoLabel(IGeoFeatureLayer pGeoFlyr)
            {
                try
                {
                    if (pGeoFlyr == null)
                        return;
                    IAnnotateLayerPropertiesCollection pAnnoProps = pGeoFlyr.AnnotationProperties;

                    pAnnoProps.Clear();

                    IAnnotateLayerProperties pAnnoLayerProps;
                    ILineLabelPosition pPosition;
                    ILineLabelPlacementPriorities pPlacement;
                    IBasicOverposterLayerProperties pBasic;
                    ILabelEngineLayerProperties pLabelEngine;

                    ITextSymbol pTextSymbol = new TextSymbolClass();
                    IRgbColor pColor = new RgbColorClass() { Red = 250, Blue = 0, Green = 0 };
                    stdole.StdFont pFont = new StdFontClass();
                    pFont.Name = "文鼎CS细等线";
                    pFont.Size = 50;
                    pTextSymbol.Font = pFont as stdole.IFontDisp;
                    pTextSymbol.Color = pColor;

                    pPosition = new LineLabelPositionClass();
                    pPosition.Parallel  = true   ;
                    pPosition.InLine = false ;
                    pPosition.Perpendicular = false ;
                    pPosition.Above = true;
                    pPlacement = new LineLabelPlacementPrioritiesClass();
                    pPlacement.AboveStart = 5;
                    pPlacement.BelowAfter = 4;
                    pBasic = new BasicOverposterLayerPropertiesClass();
                    pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
                    pBasic.LineLabelPlacementPriorities = pPlacement;
                    pBasic.LineLabelPosition = pPosition;
                    pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;

                    pLabelEngine = new LabelEngineLayerPropertiesClass();
                    pLabelEngine.Symbol = pTextSymbol;
                    pLabelEngine.BasicOverposterLayerProperties = pBasic;
                    string annoField = "[Shape_Length]";
                    pLabelEngine.Expression = annoField;
                    pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;
                    pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriSelectedFeatures;
                    pAnnoLayerProps.WhereClause = "Shape_Length>40";
                    pAnnoProps.Add(pAnnoLayerProps);
                    pGeoFlyr.AnnotationProperties = pAnnoProps;
                    pGeoFlyr.DisplayAnnotation = true;

                }
                catch (Exception Err)
                {
                    MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
    注意红色部分字段格式以及条件的书写方式

  • 相关阅读:
    远程桌面连接偶尔无法连接的解决方案
    事物复制遇到的几个错误
    几条关于查看和删除发布和分发的命令
    Winform- TreeView的使用例子
    Winform- 界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用
    Winform- IrisSkin.dll轻松实现窗体换肤功能
    Oracle- 备份单表结构和单表数据
    MSSQLSERVER数据库- 作业调度定时备份数据库
    Oracle- plsql developer如何查询SQL语句执行历史记录
    MSSQLSERVER数据库- SQL删除重复数据的五种方式
  • 原文地址:https://www.cnblogs.com/sdustyuleyi/p/2652470.html
Copyright © 2011-2022 走看看