码迷,mamicode.com
首页 > 其他好文 > 详细

取出一个图层的symbol 在其基础上对其进行修改

时间:2017-11-27 17:28:13      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:pre   relay   apc   private   button   bsp   eof   行修改   imp   

取出一个图层的symbol 在其基础上对其进行修改

   private void button1_Click(object sender, EventArgs e)
        {
  mp;nbsp;          //设定要改变symbol的图层
            ILayer pLayer=m_mapControl.get_Layer(0);
            IGeoFeatureLayer pGeoFeatLayer = pLayer as IGeoFeatureLayer;

            //得到此图层的symbol
            ISimpleMarkerSymbol pMarkerSymbol=new SimpleMarkerSymbolClass();
            pMarkerSymbol=GetFeatureLayerSymbol(pLayer) as ISimpleMarkerSymbol;

            //对symbol进行改变操作
            pMarkerSymbol.Size=20;    

            //把改变后的symbol赋给此图层
            ISimpleRenderer pRenderer=new SimpleRendererClass();
            pRenderer.Symbol=pMarkerSymbol as ISymbol;
            pGeoFeatLayer.Renderer = pRenderer as IFeatureRenderer;

          
        }

        /// <summary> 得到指定图层的symbol</summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        public ISymbol GetFeatureLayerSymbol(ILayer layer)
        {
            ISymbol pSymbol = null;

            IGeoFeatureLayer pGeoFeatLayer = (IGeoFeatureLayer)layer;
            IFeatureClass pFeatClass = pGeoFeatLayer.FeatureClass;
            IFeatureCursor pFeatCursor = pFeatClass.Search(null, true);
            IFeature pFeature = pFeatCursor.NextFeature();

            if (pFeature == null)
            {
                pFeature = pFeatCursor.NextFeature();
            }
            else
            {
                IFeatureRenderer pFeatRen;
                pFeatRen = pGeoFeatLayer.Renderer;
                pSymbol = pFeatRen.get_SymbolByFeature(pFeature);
            }
            return pSymbol;
        }

取出一个图层的symbol 在其基础上对其进行修改

标签:pre   relay   apc   private   button   bsp   eof   行修改   imp   

原文地址:http://www.cnblogs.com/sunzhiyang/p/7905067.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!