Calculate Viewshed Online

This sample demonstrates use of the Geoprocessor to call a ViewShed geoprocessing service. To use the sample, specify a distance and click a point on the map. Once the viewshed is calculated, it will be shown on the map.

In the code-behind, a Geoprocessor is used to pass the distance and click point to the ViewShed service. When the results are returned, they are added to a GraphicsLayer and shown in the map.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.ViewShed"
    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">
    <Grid x:Name="LayoutRoot" Background="White">

        <Grid.Resources>
            <esri:PictureMarkerSymbol x:Key="StartMarkerSymbol" OffsetX="8" OffsetY="8" 
                 Source="/Assets/Images/i_about.png" />
            <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#99FF9999" BorderBrush="#FFFF9999" BorderThickness="2"  />
            <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>

        <esri:Map x:Name="MyMap" MouseClick="MyMap_MouseClick" Cursor="Hand" Extent="76.35,35.65,76.65,35.95" >
            <esri:ArcGISTiledMapServiceLayer ID="TopoMapLayer" 
                      Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
            <esri:GraphicsLayer ID="MyGraphicsLayer" />
        </esri:Map>

        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" >
            <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5">
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
            <StackPanel Orientation="Vertical" Margin="20,20,20,20" HorizontalAlignment="Left" >
                <TextBlock Text="Calculate Viewshed" HorizontalAlignment="Center" FontWeight="Bold" Foreground="Black"/>
                <TextBlock x:Name="InformationTextBlock" Text="Click on map to see the calculated viewshed. Set distance below." 
                            Width="220" TextAlignment="Left" TextWrapping="Wrap" Foreground="Black" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5,5,5,10">
                    <TextBlock Text="Miles: " VerticalAlignment="Center" Foreground="Black"/>
                    <TextBox x:Name="MilesTextBox" Text="10" Width="35" TextAlignment="Right" Margin="0,0,5,0" />
                </StackPanel>
            </StackPanel>
        </Grid>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014