Geocode

This sample demonstrates using the ArcGIS Runtime SDK for WPF to geocode addresses by using a LocalGeocodeService and a Locator. To use the sample, specify an address in the dialog in the upper right of the application and click the Find button.

In the code-behind, a LocalGeocodeService is started and the Url is used to create a Locator to geocode the specified address. The results are then used to create Graphics and added to the map.

The supported source for a LocalGeocodeService is an ArcGIS Locator Package (. gcpk ), which can be authored in ArcGIS for Desktop.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LocalGeocode"
  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" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            <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>
            <esri:MarkerSymbol x:Key="StrobeMarkerSymbol">
                <esri:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Canvas>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal">
                                        <Storyboard RepeatBehavior="Forever">
                                            <DoubleAnimation BeginTime="0"
                                                Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"
                                                From="1" To="10" Duration="00:00:02" />
                                            <DoubleAnimation BeginTime="0"
                                                Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)"
                                                From="1" To="10" Duration="00:00:02" />
                                            <DoubleAnimation BeginTime="0"
                                                Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)"
                                                From="1" To="0" Duration="00:00:01" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5" 
                                RenderTransformOrigin="0.5,0.5" x:Name="ellipse"
                                IsHitTestVisible="False">
                                <Ellipse.RenderTransform>
                                    <ScaleTransform />
                                </Ellipse.RenderTransform>
                                <Ellipse.Fill>
                                    <RadialGradientBrush>
                                        <GradientStop Color="#00FF0000" />
                                        <GradientStop Color="#FFFF0000" Offset="0.25"/>
                                        <GradientStop Color="#00FF0000" Offset="0.5"/>
                                        <GradientStop Color="#FFFF0000" Offset="0.75"/>
                                        <GradientStop Color="#00FF0000" Offset="1"/>
                                    </RadialGradientBrush>
                                </Ellipse.Fill>
                            </Ellipse>
                            <Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5" 
                                Fill="#FFFF0000" x:Name="ellipse1"/>
                        </Canvas>
                    </ControlTemplate>
                </esri:MarkerSymbol.ControlTemplate>
            </esri:MarkerSymbol>
        </Grid.Resources>
        <esri:Map x:Name="MyMap" Background="#FFE3E3E3" Extent="-122.519985221, 37.836494682 ,-122.302264539 , 37.698485944">
            <esri:ArcGISLocalTiledLayer Path="..\Data\TPKS\SanFrancisco.tpk"/>
            <esri:GraphicsLayer ID="MyGraphicsLayer"/>
        </esri:Map>
        <StackPanel Orientation="Vertical" Margin="10" HorizontalAlignment="Right" VerticalAlignment="Top" >
            <Grid x:Name="GeocodeGrid" HorizontalAlignment="Right" VerticalAlignment="Top" >
                <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray" RadiusX="10" RadiusY="10" Margin="-5,-5,-5,0">
                    <Rectangle.Effect>
                        <DropShadowEffect/>
                    </Rectangle.Effect>
                </Rectangle>
                <Grid MinWidth="500">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="115*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Search for Address:" Foreground="White" Grid.Column="0"
                    HorizontalAlignment="Center" Height="24" VerticalAlignment="Center" 
                    FontWeight="Bold" FontSize="12" Margin="10,10,5,0"/>
                    <ComboBox x:Name="FindText" IsEditable="True" Background="White" Width="300" HorizontalContentAlignment="Left" Grid.Column="1" Margin="0,4,0,8" />
                    <Button x:Name="ExecuteButton" Content="Find" Width="75" Click="ExecuteButton_Click" IsEnabled="False" 
                    Margin="8,4,2,6.622" Cursor="Hand"  Grid.Column="3" />
                </Grid>
            </Grid>
        </StackPanel>
        <ProgressBar x:Name="MyProgressBar" IsIndeterminate="True" VerticalAlignment="Bottom" Width="200" Height="20" Margin="10" Visibility="{Binding Path=IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>
    </Grid>
</UserControl>
Sample code usage restrictions
5/16/2014