Use of FeatureSymbol on FeatureLayer

728
6
08-13-2010 05:49 AM
TobiasJohansson
New Contributor
After upgrading, from ArcGIS 10 Pre-Release and Silverlight/WPF 2.0 Beta to ArcGIS 10 and Silverlight/WPF 2.0, I seem to have problems databinding a Symbol to my FeatureLayer.

If I set the FeatureSymbol, as on SignTestFeatureLayer2, the MyMarkerSymbol won't show. But if I put the symbol in a UniqueValueRenderer instead, as on SignTestFeatureLayer1, the symbol appears.
<Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <esri:SimpleMarkerSymbol x:Name="MyMarkerSymbol" Color="Red" Size="12" Style="Circle" />
            <esri:UniqueValueRenderer x:Name="MyValueRenderer" DefaultSymbol="{StaticResource MyMarkerSymbol}" Attribute="TYPE">
                <esri:UniqueValueRenderer.Infos>
                </esri:UniqueValueRenderer.Infos>
            </esri:UniqueValueRenderer>
        </Grid.Resources>
        <esri:Map x:Name="Map">
            <esri:ArcGISTiledMapServiceLayer ID="PhysicalTiledLayer" Url="http://server.arcgisonline.com/ArcGIS/rest/services/NPS_Physical_World_2D/MapServer"/>
            <!-- <esri:FeatureLayer x:Name="SignTestFeatureLayer1" Url="http://vpc1778politi/ArcGIS/rest/services/PolitiSkilt/MapServer/1" 
                               Renderer="{StaticResource MyValueRenderer}"  />-->
            <esri:FeatureLayer x:Name="SignTestFeatureLayer2" Url="http://vpc1778politi/ArcGIS/rest/services/PolitiSkilt/MapServer/1" 
                               FeatureSymbol="{StaticResource MyMarkerSymbol}"  />
        </esri:Map>
    </Grid>

The map service used contains one point feature.
Does anyone have any idea why this should not work anymore?

Thanks,
Tobias
0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor
New to ArcGIS 10 is the "DrawingInfo" which defines the Renderer. When you visit your FeatureLayer URL in the browser, do you see this property and symbols defined? Is this the symbol you see in your map when you run your application? If yes, the Renderer trumps the FeatureSymbol and if you don't want the Renderer to be used you should set it to null. What you can do is either set the FeatureSymbol or overwrite your layer's renderer by setting it to a SimpleRenderer with your marker symbol. I suggest to use SimpleRenderer over UniqueValueRenderer if you don't have to distinguish between types or attributes. If you want a single feature symbol used for your graphics.
0 Kudos
TobiasJohansson
New Contributor
I didn't realize the MapService renderer overrides my FeatureSymbol.
Setting the Renderer of the FeatureLayer to null solved my problem.

Thank you for pointing this out to me.

/Tobias
0 Kudos
JakubGutkowski
New Contributor
New to ArcGIS 10 is the "DrawingInfo" which defines the Renderer. When you visit your FeatureLayer URL in the browser, do you see this property and symbols defined? Is this the symbol you see in your map when you run your application? If yes, the Renderer trumps the FeatureSymbol and if you don't want the Renderer to be used you should set it to null. What you can do is either set the FeatureSymbol or overwrite your layer's renderer by setting it to a SimpleRenderer with your marker symbol. I suggest to use SimpleRenderer over UniqueValueRenderer if you don't have to distinguish between types or attributes. If you want a single feature symbol used for your graphics.


this should be in SDK documentation.

Cheers
0 Kudos
JenniferNery
Esri Regular Contributor
Sure, we are continuing to try to improve our documentation. We will try to include this. Thank you.
0 Kudos
AndrewHargreaves
Occasional Contributor II
How do you set the render value to NULL? my code below doesn't work:

<esri:FeatureLayer  ID="GISClients"
                                Url="http://ags2.cdm.com/ArcGIS/rest/services/GISClients/MapServer/0"
                                Renderer=""
                                FeatureSymbol="{StaticResource MyMarkerSymbol}"
                                OutFields="First_Name,Last_Name">
                <esri:FeatureLayer.Clusterer>
                    <esri:FlareClusterer FlareBackground="Blue" 
                                         FlareForeground="Black" 
                                         MaximumFlareCount="10"
                                         Gradient="{StaticResource BlueGradient}" />
                </esri:FeatureLayer.Clusterer>
0 Kudos
JenniferNery
Esri Regular Contributor
Renderer="{x:Null}" in XAML is equivalent to Renderer = null in code-behind.

However during the layer's initialization process, if your feature service has defined its own renderer, and your renderer is null - which is true in this case because of Renderer="{x:Null}" in XAML - the default renderer defined by your feature service will overwrite your renderer.  This means, if you want FeatureSymbol to be used, you will need to set its renderer to null after the layer has initialized. 

I suggest you do this
Renderer = null
after the layer has initialized.
0 Kudos