Find address

View inWPFUWPFormsiOSAndroid
View on GitHub
Sample viewer app

Find the location for an address.

Image of find address

Use case

A user can input a raw address into your app's search bar and zoom to the address location.

How to use the sample

For simplicity, the sample comes loaded with a set of suggested addresses. Choose an address from the suggestions or submit your own address to show its location on the map in a callout.

How it works

  1. Create a LocatorTask using the URL to a locator service.
  2. Set the GeocodeParameters for the locator task and specify the geocode's attributes.
  3. Get the matching results from the GeocodeResult using locatorTask.GeocodeAsync(addressString, geocodeParameters).
  4. Create a Graphic with the geocode result's location and store the geocode result's attributes in the graphic's attributes.
  5. Show the graphic in a GraphicsOverlay.

Additional information

This sample uses the World Geocoding Service. For more information, see the Geocoding service help topic on the ArcGIS Developer website.

Relevant API

  • GeocodeParameters
  • GeocodeResult
  • LocatorTask

Tags

address, geocode, locator, search

Sample Code

FindAddress.xamlFindAddress.xaml.cs
                                  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<UserControl x:Class="ArcGISRuntime.WPF.Samples.FindAddress.FindAddress"
             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/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <TextBlock Text="Enter an address to search or select from a preset option."
                           Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
                           TextAlignment="Center"
                           FontWeight="SemiBold" />
                <ComboBox x:Name="SearchBox"
                          Grid.Row="1" Grid.Column="0"
                          Margin="0,5,5,0"
                          IsEnabled="False" IsEditable="True"
                          SelectionChanged="OnSuggestionChosen" />
                <Button x:Name="SearchButton"
                        Grid.Row="1" Grid.Column="1"
                        Margin="0,5,0,0"
                        Content="Search" IsEnabled="False"
                        Click="Button_Click" />
            </Grid>
        </Border>
    </Grid>
</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.