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/

  • 相关阅读:
    可搜索的下拉框
    Vue 父组件调用子组件的方法
    vue中异步函数async和await的用法
    用配置文件的方法发送axios请求
    vue中 localStorage的使用方法(详解)
    下拉框 组件的使用
    遇到不懂的记录
    做测试平台可能会用到的东西
    下拉框 v-for循环拿值的方法
    ant 自定义遮罩
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1386955.html
Copyright © 2011-2022 走看看