Geocode addresses to locations and reverse geocode locations to addresses offline.
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
- Use the path of a .loc file to create a
LocatorTask
object. - Set up
GeocodeParameters
and callGeocodeAsync
to get geocode results.
Relevant API
- GeocodeParameters
- GeocodeResult
- LocatorTask
- ReverseGeocodeParameters
Offline data
This sample downloads the following items from ArcGIS Online automatically:
- San Diego Streets Tile Package - Streets Tile Package (tpkx) for the City of San Diego.
- San Diego Offline Locator - Includes San Diego Locator Offline Dataset.
Tags
geocode, geocoder, locator, offline, package, query, search
Sample Code
<UserControl x:Class="ArcGISRuntime.WinUI.Samples.OfflineGeocode.OfflineGeocode"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<TextBlock FontWeight="SemiBold"
IsColorFontEnabled="False"
Text="Enter an address and tap 🔎 to search. Start typing for suggestions."
TextAlignment="Center"
TextWrapping="Wrap" />
<AutoSuggestBox x:Name="AutoSuggestBox"
Margin="0,5,0,0"
HorizontalAlignment="Stretch"
IsEnabled="False"
ItemsSource="{x:Bind _addresses}"
QueryIcon="Find"
QuerySubmitted="AutoSuggestBox_OnQuerySubmitted" />
</StackPanel>
</Border>
</Grid>
</UserControl>