Select to view content in your preferred language

GraphicsLayer Symbol by GeometryType

2350
5
03-11-2010 07:35 AM
JoseSousa
Esri Contributor
Dear ArcGIS API Flex Team,

I've noticed that GraphicsLayer.SymbolFunction has been deprecated. Now I believe that I must use Renderer instead.

Is there a way of specifying the symbols for the GraphicsLayer for each type of geometry (Point, Polyline and Polygon)?

I've searched in the samples but I was unable to find it.

Thanks advanced,

José Sousa
Tags (2)
0 Kudos
5 Replies
DasaPaddock
Esri Regular Contributor
The logic that was in the symbolFunction, can now be placed in a custom renderer's getSymbol function. For example:

package test
{

import com.esri.ags.Graphic;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.geometry.Polygon;
import com.esri.ags.geometry.Polyline;
import com.esri.ags.renderers.Renderer;
import com.esri.ags.symbols.Symbol;

public class MyRenderer extends Renderer
{
    public var pointSymbol:Symbol;
    public var polylineSymbol:Symbol;
    public var polygonSymbol:Symbol;
    
    override public function getSymbol(graphic:Graphic):Symbol
    {
        if (graphic.geometry is MapPoint)
        {
            return pointSymbol;
        }
        if (graphic.geometry is Polyline)
        {
            return polylineSymbol;
        }
        if (graphic.geometry is Polygon)
        {
            return polygonSymbol;
        }
        return null;
    }
}

}
0 Kudos
JoseSousa
Esri Contributor
That will probably work 🙂
Thanks a lot.

José Sousa
0 Kudos
JanicePeal
Deactivated User
I need to accomplish the same task.  I created the renderer class in an external flex library project(MyRenderer), but how do I implement the renderer in the GraphicsLayer (mxml)?

When I tried to point the renderer to the class:

<esri:GraphicsLayer id="debugGL2" symbol="{sfs}" renderer="{test.MyRenderer}"/>

I get 1067: Implicit coercion of a value of type Class to an unrelated type com.esri.ags.renderers:Renderer. 

I am fairly new at this, so apologies in advance for my naivete.  Many thanks in advance for your assistance.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Janice,

    What does your MyRenderer code look like?
0 Kudos
DasaPaddock
Esri Regular Contributor
You need to pass an instance. e.g.

<esri:GraphicsLayer id="debugGL2" symbol="{sfs}" renderer="{new MyRenderer()}"/>
0 Kudos