zoukankan      html  css  js  c++  java
  • arcEngine添加标注(上)

      arcEngine添加标注有3个技术点:1,获得图层的属性字段;2,初始化符号显示控件;3,添加标注。

    获得图层的属性字段:
      //每个图层都是一个表的图形化显示,ILayer跟ITale可以互相转换
        ITable pTable = pLayer as ITable;
                IField pField = null;
                for (int i = 0; i < pTable.Fields.FieldCount; i++)
                {
                    pField = pTable.Fields.get_Field(i);   
    //下面3种类型的字段不能显示                      
                  if(pField.Type!=esriFieldType.esriFieldTypeXML&&
                          pField.Type!=esriFieldType.esriFieldTypeRaster&&pField.Type!=esriFieldType.esriFieldTypeGeometry)
                    cmbField.Items.Add(pField.AliasName);
                }
    初始化符号显示控件:
    string sInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;   //获得arcgis的安装路径        
             axSymbologyControl1.LoadStyleFile(sInstall + "\\Styles\\ESRI.ServerStyle");  //打开样式文件
    //显示文字符号(esriStyleClassTextSymbols
            axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassTextSymbols).SelectItem(0);
     
    添加标注:
    IGeoFeatureLayer geoFeatureLayer = pLayer as IGeoFeatureLayer;
             //AnnotationProperties属性控制标注的内容、格式
                geoFeatureLayer.AnnotationProperties.Clear();
      //标注放置的位置
                IBasicOverposterLayerProperties blProperty = new BasicOverposterLayerPropertiesClass();
                ILabelEngineLayerProperties llProperty = new LabelEngineLayerPropertiesClass();
     
                ITextSymbol textSymbol = new TextSymbolClass();   
                textSymbol = (ITextSymbol)styleGalleryItem.Item;     
                IColor ic = new RgbColorClass();
                ic.RGB = colorPickerButton1.SelectedColor.B * 65536 + colorPickerButton1.SelectedColor.G * 256 + colorPickerButton1.SelectedColor.R;
                textSymbol.Color = ic;
     
                stdole.IFontDisp tempFont = new stdole.StdFont() as stdole.IFontDisp;
                tempFont.Name = cmbFont.SelectedNode.Text;
                DevComponents.Editors.ComboItem cmbItem = (DevComponents.Editors.ComboItem)cmbSize.SelectedItem;
                tempFont.Size = Convert.ToDecimal(cmbItem.Text);
                textSymbol.Font = tempFont;
                textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
     
       //标注内容表达式
                string pLabel = "[" + (string)cmbField.SelectedItem + "]";
                llProperty.Expression = pLabel;
               //复杂表达式,下次博客内容
                if (cmbField.SelectedIndex == cmbField.Items.Count - 1)
                {
                    llProperty.IsExpressionSimple = false;
                    IAnnotationExpressionEngine annoEE = new AnnotationJScriptEngine();
                    llProperty.ExpressionParser = annoEE;
                    llProperty.Expression = fieldExpression;
                }
                //llProperty.ExpressionParser
     
                blProperty.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;
                llProperty.BasicOverposterLayerProperties = blProperty;
                llProperty.Symbol = textSymbol;
                geoFeatureLayer.AnnotationProperties.Add(llProperty as IAnnotateLayerProperties);
                geoFeatureLayer.DisplayAnnotation = true;
                pMap.Refresh();
  • 相关阅读:
    觅踪8
    觅踪7
    团队开发进度报告1
    团队计划会议
    团队nabcd卡片制作及小组讨论
    团队项目NABCD
    软件需求分析
    团队电梯演讲视频
    团队开篇博客
    团队简介
  • 原文地址:https://www.cnblogs.com/lovebay/p/4921597.html
Copyright © 2011-2022 走看看