I've been trying for some time to get an IconValueRenderer working, without success. I can see no obvious mistakes in my code, and yet nothing gets displayed on the map.
My code is as follows:
Layer layer2 = new Layer("c:/path/to/shape/file", true);
layer2.ThresholdUnit = ThresholdUnits.kilometres;
Threshold threshold = new Threshold();
threshold.UpperExtent = 50000;
threshold.LowerExtent = 0;
IconValueCollection IconValueCollection = new IconValueCollection();
TextSymbolCollection TextSymbols = new TextSymbolCollection();
TextSymbols.Add(new TextSymbol(new Font("Arial", 8, FontStyle.Bold), new SolidBrush(Color.Black), 1, -5));
// "POLICE" is the value I want to match this icon to
IconValueRenderer.IconValue IconValue1 = new IconValueRenderer.IconValue("POLICE", new Bitmap(this.Server.MapPath("") + @"\images\police.png"), TextSymbols);
IconValueCollection.Add(IconValue1);
// "TYPE" is the column that I want to match the value to, and "CITYNAME" is the column with the text to show as a label
IconValueRenderer IconValueRenderer = new IconValueRenderer("TYPE", "CITYNAME", IconValueCollection);
threshold.LabelRenderers.Add(IconValueRenderer);
if (!layer2.HasIndex)
layer2.BuildIndex();
Map1.Layers.Add(layer2);