Select to view content in your preferred language

Graphic tool - Draw Polygon Polygon disappears after finish drawing

2922
3
03-23-2011 12:44 PM
YingLin
Emerging Contributor
I am using arcGIS silverlight api 2.1 SDK. Created a button for drawing polygon using ESRI:RedlineAction

<esri:RedlineAction
    Color="Red"
    DrawMode="Polygon"                                   
    GraphicsLayerID="MyGraphicsLayer"
    TargetName="Map" />

when drawing is finished, the polygon disappears. I want it to stay so that it can be used when creating printouts. Drawing with polyline and freehand functions are fine though.  Anyone has the same problem?
Thanks very much
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
If you are using this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#GraphicsActions

                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <esri:RedlineAction 
                                    Color="#FF32FF00"
                                    DrawMode="Polygon"                                    
                              GraphicsLayerID="MyGraphicsLayer"
                                    TargetName="MyMap"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>


Notice that the GraphicsLayer it uses is:
            <esri:GraphicsLayer ID="MyGraphicsLayer" Renderer="{StaticResource GraphicsLayerLineSymbol}" />

This Renderer is for Polyline geometry. The graphic is not removed, it is just not rendered because its geometry type cannot be given line symbol. You need to use a different Renderer with symbols that match the geometry type for graphics drawn by RedlineAction.
0 Kudos
YingLin
Emerging Contributor
Does that mean another graphics Layer have to be created for polygon rendering? The previous api example was able to accommadate both polyline and polygon on same graphic layer.
thanks
0 Kudos
dotMorten_esri
Esri Notable Contributor
If you use one of the built-in renderers, the symbol type much match the geometry type, and thus all geometry types must be the same in the layer.

If you don't use a renderer, you can simply assign a symbol directly to each graphic that matches for the geometry type.
0 Kudos