Select to view content in your preferred language

classbreakrenderer using two field

845
3
07-24-2013 12:52 PM
abukhan
Occasional Contributor
Is there a way to use two fields or attributes for classbreakrenderer for a featurelayer? It does not look like current api supports it. if not, can this be a suggestion for future api release.. Also is there a alternate way to use two fields using current api (of course not using two layers of the same feature layer).

Thanks
Tags (2)
0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus
abu khan,

   The flex API is not going to have all the features that are available in ArcMap. The best way is to do this type of symbolization is in ArcMap before you publish your service.
0 Kudos
YannCabon
Esri Contributor
You can achieve what you want by creating a custom IRenderer implementation.

Here's an example.


package sample
{

import com.esri.ags.Graphic;
import com.esri.ags.renderers.IRenderer;
import com.esri.ags.symbols.Symbol;

public class CustomRenderer implements IRenderer
{

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  teamA
    //----------------------------------

    public var teamA:IRenderer;

    //----------------------------------
    //  teamB
    //----------------------------------

    public var teamB:IRenderer;

    //--------------------------------------------------------------------------
    //
    //  Public Methods
    //
    //--------------------------------------------------------------------------


    public function getSymbol(graphic:Graphic):Symbol
    {
        var symbol:Symbol;
        if (graphic)
        {
            var attributes:Object = graphic.attributes;
            if (attributes && attributes.hasOwnProperty("team"))
            {
                if (attributes["team"] == "A")
                {
                    symbol = teamA.getSymbol(graphic);
                }
                else if (attributes["team"] == "B")
                {
                    symbol = teamB.getSymbol(graphic);
                }
            }
        }

        return symbol;
    }

}
}



To use it:


<sample:CustomRenderer>
    <sample:teamA>
        <esri:ClassBreaksRenderer>
            ...
        </esri:ClassBreaksRenderer>
    </sample:teamA>
    <sample:teamB>
        <esri:ClassBreaksRenderer>
            ...
        </esri:ClassBreaksRenderer>
    </sample:teamB>
</sample:CustomRenderer>



Basically the renderer role is to return the right symbol for the graphic.
You can either create one or do like above, delegate to another renderer based on a first attribute (eg: team)
0 Kudos
BjornSvensson
Esri Regular Contributor
Is there a way to use two fields or attributes for classbreakrenderer for a featurelayer?  ... Also is there a alternate way to use two fields using current api

Use a UniqueValueRenderer - which supports up to three fields (just like ArcMap). 

Depending on your data, you might have to adjust it to make it more "uniquevalue" friendly.
0 Kudos