Offline geocode

View inWPFUWPFormsiOSAndroid
View on GitHub
Sample viewer app

Geocode addresses to locations and reverse geocode locations to addresses offline.

Image of offline geocode

Use case

You can use an address locator file to geocode addresses and locations. For example, you could provide offline geocoding capabilities to field workers repairing critical infrastructure in a disaster when network availability is limited.

How to use the sample

Type the address in the Search menu option or select from the list to Geocode the address and view the result on the map. Tap the location you want to reverse geocode. Tap the pin to see the full address.

How it works

  1. Use the path of a .loc file to create a LocatorTask object.
  2. Set up GeocodeParameters and call GeocodeAsync to get geocode results.

Relevant API

  • GeocodeParameters
  • GeocodeResult
  • LocatorTask
  • ReverseGeocodeParameters

Offline data

This sample downloads the following items from ArcGIS Online automatically:

Tags

geocode, geocoder, locator, offline, package, query, search

Sample Code

OfflineGeocode.xamlOfflineGeocode.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
35
<UserControl x:Class="ArcGISRuntime.WPF.Samples.OfflineGeocode.OfflineGeocode"
             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"
                          ItemsSource="{Binding Suggestions}"
                          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="Search_Clicked" />
            </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.