zoukankan      html  css  js  c++  java
  • ArcEngine 图层标注 (根据字段、角度)

    转自chanyinhelv原文 ArcEngine 图层标注 (根据字段、角度)

    今天做了一个用AE来控制图层是否显示标注,以及已哪一个字段作为标注的字段,以哪一个字段作为标注的角度,现将代码写下来,以备以后差用。

    public void EnableFeatureLayerLabel(IFeatureLayer pFeaturelayer, string sLableField, IRgbColor pRGB, int size, string angleField)  
    {  
        //判断图层是否为空  
        if (pFeaturelayer == null)  
            return;  
        IGeoFeatureLayer pGeoFeaturelayer = (IGeoFeatureLayer)pFeaturelayer;  
        IAnnotateLayerPropertiesCollection pAnnoLayerPropsCollection;  
        pAnnoLayerPropsCollection = pGeoFeaturelayer.AnnotationProperties;  
        pAnnoLayerPropsCollection.Clear();  
      
        //stdole.IFontDisp  pFont; //字体  
        ITextSymbol pTextSymbol;  
      
        //pFont.Name = "新宋体";  
        //pFont.Size = 9;  
        //未指定字体颜色则默认为黑色  
        if (pRGB == null)  
        {  
            pRGB = new RgbColorClass();  
            pRGB.Red = 0;  
            pRGB.Green = 0;  
            pRGB.Blue = 0;  
        }  
      
        pTextSymbol = new TextSymbolClass();  
        pTextSymbol.Color = (IColor)pRGB;  
        pTextSymbol.Size = size; //标注大小  
      
        IBasicOverposterLayerProperties4 pBasicOverposterlayerProps4 = new BasicOverposterLayerPropertiesClass();  
        switch (pFeaturelayer.FeatureClass.ShapeType)//判断图层类型  
        {  
            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:  
                pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;  
                break;  
            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:  
                pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint;  
                break;  
            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:  
                pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;  
                break;  
        }   
        pBasicOverposterlayerProps4.PointPlacementMethod = esriOverposterPointPlacementMethod.esriRotationField;  
        pBasicOverposterlayerProps4.RotationField = angleField;  
      
        ILabelEngineLayerProperties pLabelEnginelayerProps = new LabelEngineLayerPropertiesClass();   
        pLabelEnginelayerProps.Expression = "[" + sLableField + "]";  
        pLabelEnginelayerProps.Symbol = pTextSymbol;  
        pLabelEnginelayerProps.BasicOverposterLayerProperties = pBasicOverposterlayerProps4 as IBasicOverposterLayerProperties;  
        pAnnoLayerPropsCollection.Add((IAnnotateLayerProperties)pLabelEnginelayerProps);  
        pGeoFeaturelayer.DisplayAnnotation = true;//很重要,必须设置   
        //axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null); }  
    }  
  • 相关阅读:
    机器学习概要
    Latex公式压缩
    MATLAB多项式运算
    利用MathType为公式编号并引用
    MATLAB符号对象与符号运算
    MATLAB矩阵运算
    MATLAB绘制函数图
    MATLAB程序控制语句
    MATLAB关系运算符和逻辑运算符
    Raspberry pi之wifi设置-3
  • 原文地址:https://www.cnblogs.com/arxive/p/6262450.html
Copyright © 2011-2022 走看看