Renderers JSON

This sample demonstrates techniques for converting renderers, such as SimpleRenderer, UniqueValueRenderer, and ClassBreaksRenderer to and from ArcGIS JSON. ArcGIS JSON renderers are defined as part of the ArcGIS Server REST API specification: http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/renderer.html.

Different predefined renderers in the ArcGIS JSON format are provided. Feel free to modify the JSON content appropriately and apply to the features in the US States feature layer in the map. The current tab will always show the current JSON renderer applied to the feature layer. Use the Reset to Service button to retrieve the renderer defined for the feature layer by the map or feature service. Note, the maxAllowableOffset property is used to generalize features in the map to improve display performance by reducing the complexity of the geometry.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.RendererJson"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009" Margin="5,0,0,0">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                <LinearGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </LinearGradientBrush.RelativeTransform>
                <GradientStop Color="#FF145787" Offset="0.16"/>
                <GradientStop Color="#FF3D7FAC" Offset="0.502"/>
                <GradientStop Color="#FF88C5EF" Offset="0.984"/>
            </LinearGradientBrush>
        </Grid.Resources>

        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <esri:Map x:Name="MyMap" WrapAround="True" Extent="-15000000,2000000,-7000000,8000000" Grid.Column="0">
            <esri:ArcGISTiledMapServiceLayer ID="TiledLayer" 
                Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
            <esri:FeatureLayer ID="MyFeatureLayerStates" 
                Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/2"               
                OutFields="*"
                Initialized="FeatureLayer_Initialized"
                PropertyChanged="FeatureLayer_PropertyChanged" />
        </esri:Map>

        <TabControl Margin="5" Grid.Column="1" Background="White" VerticalAlignment="Stretch">
            <TabItem Header="Current">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" Grid.Row="0" >
                        <Button Content="Reset to service" Width="200" Click="Button_ResetMap" Margin="5" />
                    </StackPanel>
                    <ScrollViewer Grid.Row="1">
                        <TextBox x:Name="JsonTextBoxCurrent" TextWrapping="Wrap" IsReadOnly="True" />
                    </ScrollViewer>
                </Grid>
            </TabItem>
            <TabItem Header="Simple" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" Grid.Row="0" >
                        <Button Content="Apply" Width="200" Click="Button_Load" Margin="5" Tag="JsonTextBoxSimple"/>
                    </StackPanel>
                    <ScrollViewer Grid.Row="1">
                        <TextBox x:Name="JsonTextBoxSimple" FontSize="12" TextWrapping="Wrap" AcceptsReturn="True" />
                    </ScrollViewer>
                </Grid>
            </TabItem>
            <TabItem Header="Class Breaks" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" Grid.Row="0" >
                        <Button Content="Apply" Width="200" Click="Button_Load" Margin="5" Tag="JsonTextBoxClassBreaks" />
                    </StackPanel>
                    <ScrollViewer Grid.Row="1">
                        <TextBox x:Name="JsonTextBoxClassBreaks" FontSize="12" TextWrapping="Wrap" AcceptsReturn="True" />
                    </ScrollViewer>
                </Grid>
            </TabItem>
            <TabItem Header="Unique Value" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" Grid.Row="0" >
                        <Button Content="Apply" Width="200" Click="Button_Load" Margin="5" Tag="JsonTextBoxUniqueValue"/>
                    </StackPanel>
                    <ScrollViewer Grid.Row="1">
                        <TextBox x:Name="JsonTextBoxUniqueValue" FontSize="12" TextWrapping="Wrap" AcceptsReturn="True" />
                    </ScrollViewer>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014