FeatureSet JSON

This sample demonstrates how to create a graphics layer from ArcGIS JSON using the FeatureSet.FromJson() static method. The ArcGIS JSON string included in the code-behind contains two features which are converted into graphics and displayed in the map using a green marker symbol. Existing graphics collections within graphics layers or feature layers can be converted into ArcGIS JSON using the FeatureSet.ToJson() method. A feature layer in the map contains a set of cities symbolized using a red marker symbol. The graphics collection of the feature layer is serialized to ArcGIS JSON and displayed in the textbox below the map.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.FeatureSetJson"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              
    xmlns:basics="clr-namespace:System;assembly=mscorlib"
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <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 Width="420"/>
        </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:Map>

        <TabControl Margin="5" Grid.Column="1" Background="White" VerticalAlignment="Stretch">
            <TabItem Header="From JSON" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" Grid.Row="0" >
                        <Button Content="Clear Map" Width="172" Click="Button_ClearMap" Margin="10" />
                        <Button Content="Create FeatureSet from JSON" Width="172" Click="Button_Load" Margin="10" />
                    </StackPanel>
                    <ScrollViewer Grid.Row="1">
                        <TextBox x:Name="JsonTextBox" FontSize="12" />
                    </ScrollViewer>
                </Grid>
            </TabItem>
            <TabItem Header="To JSON">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50" />
                        <RowDefinition Height="40" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" Grid.Row="0" >
                        <Button Content="Clear Map" Width="172" Click="Button_ClearMap" Margin="10" />
                        <Button Content="Show FeatureSet JSON from Layer" Width="190" Click="Button_Show" Margin="10" />
                    </StackPanel>
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="Url: " HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Margin="10,0,0,0"/>
                        <TextBox x:Name="FeatureLayerUrlTextBox" Margin="2,5,5,10" Grid.Column="1" VerticalContentAlignment="Center" 
                                 FontSize="12" Text="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0"/>
                    </Grid>
                    <ScrollViewer Grid.Row="2">
                        <TextBox x:Name="OutTextBox" TextWrapping="Wrap" IsReadOnly="True" />
                    </ScrollViewer>
                </Grid>
            </TabItem>
        </TabControl>


    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014