zoukankan      html  css  js  c++  java
  • 使用IUniqueValueRenderer在同一层中根据字段渲染出不同颜色收藏

    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/

  • 相关阅读:
    HDOJ 2577 How To Type
    HDOJ 1171 Big Event in HDU
    HDOJ 2159 FATE
    HDOJ 1176 免费馅饼
    POJ 1014 Dividing
    HDOJ 2844 Coins
    可以设置DefaultButton的TextBox控件
    setTimeout和setInterval的使用
    C# 调用ExchangeWebservice的相关代码
    实现IConfigurationSectionHandler接口来编写自定义配置
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1386955.html
Copyright © 2011-2022 走看看