使用IUniqueValueRenderer在同一层中根据字段渲染出不同颜色收藏

小麋鹿666 2017-02-10

源码 index

  
public static void UniqueValueRenderer(ILayer layer)
  {
   IFeatureLayer pFLayer = layer  as IFeatureLayer;
   IGeoFeatureLayer geoLayer = layer as IGeoFeatureLayer;
   IFeatureClass fcls = pFLayer.FeatureClass;
   IQueryFilter pQueryFilter = new  QueryFilterClass();
   IFeatureCursor fCursor = fcls.Search(pQueryFilter,false);
   IRandomColorRamp rx = new RandomColorRampClass();
   rx.MinSaturation = 15;
   rx.MaxSaturation = 30;
   rx.MinValue = 85;
   rx.MaxValue = 100;
   rx.StartHue = 0;
   rx.EndHue = 360;
   rx.Size =100;
   bool ok;;
   rx.CreateRamp(out ok);
   IEnumColors RColors = rx.Colors;
   RColors.Reset();
   IUniqueValueRenderer pRender = new UniqueValueRendererClass();
   pRender.FieldCount=1;
   pRender.set_Field(0,"乡名");
   IFeature pFeat = fCursor.NextFeature();
   int index = pFeat.Fields.FindField("乡名");
   while(pFeat!=null)
   {
    ISimpleFillSymbol symd = new SimpleFillSymbolClass();
    symd.Style=esriSimpleFillStyle.esriSFSSolid;
    symd.Outline.Width=1;
    symd.Color = RColors.Next();
    string valuestr = pFeat.get_Value(index).ToString();
    pRender.AddValue(valuestr,valuestr,symd as ISymbol);
    pFeat = fCursor.NextFeature();
   }
   geoLayer.Renderer = pRender as IFeatureRenderer;
  }
版权说明

  如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。
  作      者:温景良
  文章出处:http://wenjl520.cnblogs.com/  或  http://www.cnblogs.com/

posted @ 2009-02-09 17:20 温景良(Jason) Views(2124) Comments(0) Edit 收藏
 

公告

 
本文转自我的程序人生博客园博客,原文链接:http://www.cnblogs.com/wenjl520/archive/2009/02/09/1386955.html,如需转载请自行联系
 
 
登录 后评论
下一篇
云栖号资讯小编
1132人浏览
2020-03-31
相关推荐
ArcEngine 图层渲染(转)
664人浏览
2017-02-10 00:00:00
ArcEngine 渲染的使用
529人浏览
2017-02-10 00:00:00
GIS基础软件及操作(一)
818人浏览
2016-07-30 09:48:00
MipMap
396人浏览
2015-11-16 21:52:00
MipMap
634人浏览
2017-11-28 18:57:00
动画类型
710人浏览
2012-12-03 15:38:00
ArcEngine图层渲染
355人浏览
2013-06-26 11:44:33
0
0
0
914