Find place

View inWPFUWPFormsiOSAndroid
View on GitHub
Sample viewer app

Find places of interest near a location or within a specific area.

Image of find place

Use case

When getting directions or looking for nearby places, users may only know what the place has ("food"), the type of place ("gym"), or the generic place name ("Starbucks"), rather than the specific address. You can get suggestions and locations for these places of interest (POIs) using a natural language query. Additionally, you can filter the results to a specific area.

How to use the sample

Choose a type of place in the first field and an area to search within in the second field. Click the Search button to show the results of the query on the map. Click on a result pin to show its name and address. If you pan away from the result area, a "Redo search in this area" button will appear. Click it to query again for the currently viewed area on the map.

How it works

  1. Create a LocatorTask using a URL to a locator service.
  2. Find the location for an address (or city name) to build an envelope to search within:

    • Create GeocodeParameters.
    • Add return fields to the parameters' ResultAttributeNames collection. Only add a single "*" option to return all fields.
    • Call locatorTask.GeocodeAsync(locationQueryString, geocodeParameters) to get a list of GeocodeResults.
    • Use the DisplayLocation from one of the results to build an Envelope to search within.
  3. Get place of interest (POI) suggestions based on a place name query:

    • Create SuggestParameters.
    • Add "POI" to the parameters' categories collection.
    • Call locatorTask.SuggestAsync(placeQueryString, suggestParameters) to get a list of SuggestResults.
    • The SuggestResult will have a label to display in the search suggestions list.
  4. Use one of the suggestions or a user-written query to find the locations of POIs:

    • Create GeocodeParameters.
    • Set the parameters' searchArea to the envelope.
    • Call locatorTask.GeocodeAsync(suggestionLabelOrPlaceQueryString, geocodeParameters) to get a list of GeocodeResults.
    • Display the places of interest using the results' DisplayLocations.

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
  • SuggestParameters
  • SuggestResult

Tags

businesses, geocode, locations, locator, places of interest, POI, point of interest, search, suggestions

Sample Code

FindPlace.xamlFindPlace.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<UserControl x:Class="ArcGISRuntime.WPF.Samples.FindPlace.FindPlace"
             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 />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="2*" />
                </Grid.ColumnDefinitions>
                <TextBlock
                    Text="Enter a search term and a search location. Tap 'Search all' to find all results near that location. Tap 'Search in view' to restrict the search to results within the current visible extent."
                    Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"
                    TextAlignment="Left" TextWrapping="Wrap" FontWeight="SemiBold" />
                <TextBlock Text="Search"
                           Grid.Row="1" Grid.Column="0"
                           Margin="0,5,5,0" />
                <TextBlock Text="Location"
                           Grid.Row="2" Grid.Column="0"
                           Margin="0,5,5,0" />
                <ComboBox x:Name="MySearchBox"
                          Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"
                          Text="Coffee"
                          Margin="0,5,0,0"
                          IsEnabled="False" IsEditable="True"
                          TextBoxBase.TextChanged="MySearchBox_TextChanged" />
                <ComboBox x:Name="MyLocationBox"
                          Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"
                          Text="Current Location"
                          Margin="0,5,0,0"
                          IsEditable="True" IsEnabled="False"
                          TextBoxBase.TextChanged="MyLocationBox_TextChanged" />
                <Button x:Name="MySearchButton"
                        Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
                        Content="Search all"
                        IsEnabled="False"
                        Margin="0,5,5,0"
                        Click="MySearchButton_Click" />
                <Button x:Name="MySearchRestrictedButton"
                        Grid.Row="3" Grid.Column="2"
                        Content="Search in view"
                        IsEnabled="False"
                        Margin="5,5,0,0"
                        Click="MySearchRestrictedButton_Click" />
                <ProgressBar x:Name="MyProgressBar"
                             Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3"
                             Visibility="Collapsed" IsIndeterminate="True"
                             Margin="0,5,0,0" Height="20" />
            </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.