private UniqueValueInfo UniqueValues(string value, string label, string description, PolygonSymbol sym) { UniqueValueInfo uniqueValueInfo = new UniqueValueInfo() { value = value, label = label, description = description, symbol = sym }; return uniqueValueInfo; }
/// <summary> /// Code demonstrates how you would create a unique value renderer with 5 polygon unique symbol values /// </summary> /// <returns></returns> private UniqueValueInfos UniqueValues() { UniqueValueInfos infos = new UniqueValueInfos(); infos.uniqueValueInfos = new UniqueValueInfo[5]; PolygonSymbol symbol1 = new PolygonSymbol() { type = "esriSFS", style = "esriSLSSolid", color = new object[] { 0, 255, 255, 255 }, outline = new Outline() { type = "esriSLS", style = "esriSLSSolid", color = new object[] { 110, 110, 110, 255 }, width = 1 } }; infos.uniqueValueInfos[0] = UniqueValues("1", "1", "", symbol1); PolygonSymbol symbol2 = new PolygonSymbol() { type = "esriSFS", style = "esriSFSSolid", color = new object[] { 0, 191, 255, 255 }, outline = new Outline() { type = "esriSLS", style = "esriSLSSolid", color = new object[] { 110, 110, 110, 255 }, width = 1 } }; infos.uniqueValueInfos[1] = UniqueValues("2", "2", "", symbol2); PolygonSymbol symbol3 = new PolygonSymbol() { type = "esriSFS", style = "esriSFSSolid", color = new object[] { 0, 128, 255, 255 }, outline = new Outline() { type = "esriSLS", style = "esriSLSSolid", color = new object[] { 110, 110, 110, 255 }, width = 1 } }; infos.uniqueValueInfos[2] = UniqueValues("3", "3", "", symbol3); PolygonSymbol symbol4 = new PolygonSymbol() { type = "esriSFS", style = "esriSFSSolid", color = new object[] { 0, 64, 255, 255 }, outline = new Outline() { type = "esriSLS", style = "esriSLSSolid", color = new object[] { 110, 110, 110, 255 }, width = 1 } }; infos.uniqueValueInfos[3] = UniqueValues("4", "4", "", symbol2); PolygonSymbol symbol5 = new PolygonSymbol() { type = "esriSFS", style = "esriSFSSolid", color = new object[] { 0, 0, 255, 255 }, outline = new Outline() { type = "esriSLS", style = "esriSLSSolid", color = new object[] { 110, 110, 110, 255 }, width = 1 } }; infos.uniqueValueInfos[4] = UniqueValues("5", "5", "", symbol2); return infos; }
/// <summary> /// Code to demonstrate creation of a polygon unique value renderer. /// We need to create a default symbol, then create the other values that will be part of the /// collection of unique symbols used. /// The symbol used to display is based on a field value within the feature service that we /// are required to state the field name within the renderer. /// </summary> /// <returns></returns> private PolygonRenderer UniqueValueRender() { PolygonSymbol defaultSym = new PolygonSymbol() { type = "esriSFS", style = "esriSFSSolid", color = new object[] { 198, 245, 215, 255 }, outline = new Outline() { type = "esriSLS", style = "esriSLSSolid", color = new object[] { 110, 110, 110, 255 }, width = 1 } }; UniqueValueInfos infos = UniqueValues(); PolygonRenderer renderer = new PolygonRenderer() { type = "uniqueValue", field1 = cboFields.Text, field2 = "", field3 = "", fieldDelimiter = "", defaultSymbol = defaultSym, defaultLabel = "<all other values>", uniqueValueInfos = infos.uniqueValueInfos }; return renderer; }