当前位置: 代码迷 >> GIS >> c#+AE中TextElement标注不显示解决方案
  详细解决方案

c#+AE中TextElement标注不显示解决方案

热度:154   发布时间:2016-05-05 06:14:40.0
c#+AE中TextElement标注不显示
在看兰小机和刘德儿两位老师编著的ArcObjects GIS应用开发这本书的时候,在做到TextElement标注时运行时并没有显示,但是我的代码和书上都是一样的,不知道是怎么回事,请高手帮助分析一下,谢谢。
代码:

 private void btnTextElementLabel_Click(object sender, EventArgs e)
        {
            IMap pMap;
            IFeatureLayer pFeatureLyr;
            IFeatureClass pFeatureClass;
            string pFieldName = "原村名";
            pMap = axMapControl1.Map;
            pFeatureLyr = pMap.get_Layer(0) as IFeatureLayer;
            pFeatureClass = pFeatureLyr.FeatureClass;
            TextElementLabel(pMap, pFeatureClass, pFieldName);
           
        }


 private void TextElementLabel(IMap pMap, IFeatureClass pFeatureClass, string strName)
        {
            //查询条件
            //IQueryFilter pQueryFilter = new QueryFilterClass();
            //pQueryFilter.WhereClause = "OBJECTID>";
             //获取要素查询后的要素有表对象
            IFeatureCursor pFeatCursor;
            pFeatCursor = pFeatureClass.Search(null,true);//全部地物
            IFeature pFeature;
            pFeature = pFeatCursor.NextFeature();
            while (pFeature != null)
            {
                IFields pFields = pFeature.Fields;
                int i;
                //找出标注字段的索引号
                i = pFields.FindField(strName);
                //得到要素的Envelope
                IEnvelope pEnve = pFeature.Extent;
                IPoint pPoint = new PointClass();
                pPoint.PutCoords(pEnve.XMin + pEnve.Width / 2, pEnve.YMin + pEnve.Height / 2);
                //新建字体对象
                stdole.IFontDisp pFont;
                pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = "arial";
                //新建rgb对象
                IRgbColor pRGB = new RgbColorClass();
                pRGB.Red = 110;
                pRGB.Green = 60; 
                pRGB.Blue = 200;
                //产生一个文本符号
                ITextSymbol pTextSymbol = new TextSymbolClass();
                //设置文本符号的大小
                pTextSymbol.Size = 3;
                pTextSymbol.Font = pFont;
                pTextSymbol.Color = pRGB;
                //产生一个文本对象
                ITextElement pTextEle = new TextElementClass();
  相关解决方案