3

I am currently using IUnique value renderer like this:

 foreach (string nodeType in nodes)
      yield return new KeyValuePair<string, ISymbol>(nodeType, CreateNewSymbol() );


public static ISimpleLineSymbol CreateSimpleLineSymbol(IRgbColor rgbColor, Double width, esriSimpleLineStyle style)
{
    SimpleLineSymbolClass simpleLineSymbol = new SimpleLineSymbolClass();

    simpleLineSymbol.Color = rgbColor;
    simpleLineSymbol.Style = style;
    simpleLineSymbol.Width = width;

    return simpleLineSymbol;
}

finally this is called during creation of the layer:

  /// <summary>
        /// Set's the unique symbol types on the feature layer
        /// </summary>
        /// <param name="featureLayer"></param>
        /// <param name="layerType"></param>
        public static void SetFeatureLayerSymbols(IFeatureLayer featureLayer, IEnumerable<KeyValuePair<string, ISymbol>> layerSymbols)
        {
            IFields fields = featureLayer.FeatureClass.Fields;

            //Get indexes of certain fields
            int id = fields.FindField("TYPE");

            IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer();

            //The fields which are used to map to the symbol
            uniqueValueRenderer.FieldCount = 1;
            uniqueValueRenderer.set_Field(0, "TYPE");

            foreach (KeyValuePair<string, ISymbol> values in layerSymbols)
                uniqueValueRenderer.AddValue(values.Key, null, values.Value);

            if (uniqueValueRenderer.ValueCount > 0)
                (featureLayer as IGeoFeatureLayer).Renderer = uniqueValueRenderer as IFeatureRenderer;
        }

I can see the index in the TOC showing the proper unique values and the colors, but on the map it is invisible, I CAN HOWEVER HIGHLIGHT IT.

Thanks and Regards,

2
  • I've seen the same thing using the ArcMap product. I wonder if this is a bug? (I'm on 10 service pack 2.)
    – Chaz
    Commented Nov 4, 2011 at 18:46
  • yea i am also using 10 sp2, it doesn't make sense as the same thing works for polygons but not points nor polylines.
    – Kev84
    Commented Nov 4, 2011 at 20:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.