Search for webmap

View inWPFUWPFormsiOSAndroid
View on GitHub
Sample viewer app

Find webmap portal items by using a search term.

Image of search for webmap

Use case

Portals can contain many portal items and at times you may wish to query the portal to find what you're looking for. In this example, we search for webmap portal items using a text search.

How to use the sample

Enter search terms into the search bar. Once the search is complete, a list is populated with the resultant webmaps. Tap on a webmap to set it to the map view. Scrolling to the bottom of the webmap recycler view will get more results.

How it works

  1. Create a new Portal and load it.
  2. Create new PortalItemQueryParameters. Set the type to PortalItem.Type.WebMap and add the text you want to search for.
  3. Use portal.FindItemsAsync(params) to find matching items.

Relevant API

  • Portal
  • PortalItem
  • PortalQueryParameters
  • PortalQueryResultSet

Tags

keyword, query, search, webmap

Sample Code

SearchPortalMaps.xamlSearchPortalMaps.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<UserControl
    x:Class="ArcGISRuntime.WPF.Samples.SearchPortalMaps.SearchPortalMaps"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
    mc:Ignorable="d"
    d:DesignHeight="600" d:DesignWidth="800">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid x:Name="OAuthSettingsGrid"
                      Visibility="Visible">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="60" />
                        <RowDefinition Height="40" />
                        <RowDefinition Height="40" />
                        <RowDefinition Height="40" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="115" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="OAuth Settings"
                               Grid.Row="0" Grid.ColumnSpan="2"
                               FontSize="18"
                               VerticalAlignment="Bottom" HorizontalAlignment="Center" />
                    <TextBlock Text="Client ID:"
                               Grid.Row="1" Grid.Column="0"
                               VerticalAlignment="Bottom" HorizontalAlignment="Right" />
                    <TextBox x:Name="ClientIdTextBox"
                             Grid.Row="1" Grid.Column="1"
                             VerticalAlignment="Bottom" HorizontalAlignment="Left"
                             Width="150" Margin="10,0" />
                    <TextBlock Text="Redirect URL:"
                               Grid.Row="2" Grid.Column="0"
                               VerticalAlignment="Top" HorizontalAlignment="Right"
                               Margin="0,10" />
                    <TextBox x:Name="RedirectUrlTextBox"
                             Grid.Row="2" Grid.Column="1"
                             VerticalAlignment="Top" HorizontalAlignment="Left"
                             Width="150" Margin="10" />
                    <Button Content="Cancel"
                            Grid.Row="3" Grid.Column="0"
                            Width="70" Height="25" Margin="10,0"
                            VerticalAlignment="Center" HorizontalAlignment="Center"
                            Click="CancelOAuthSettingsClicked" />
                    <Button Content="Save OAuth Settings"
                            Grid.Row="3" Grid.Column="1"
                            Width="150" Height="25" Margin="10,0"
                            VerticalAlignment="Center" HorizontalAlignment="Left"
                            Click="SaveOAuthSettingsClicked" />
                </Grid>
                <Grid x:Name="SearchUI" Visibility="Collapsed">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition Height="100" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <RadioButton x:Name="SearchPublicMaps"
                                 Grid.Column="0" Grid.Row="0"
                                 HorizontalAlignment="Left"
                                 IsChecked="True"
                                 Content="Search public maps:"
                                 Unchecked="RadioButtonUnchecked" />
                    <TextBox x:Name="SearchText"
                             Grid.Column="1" Grid.Row="0"
                             IsEnabled="{Binding ElementName=SearchPublicMaps, Path=IsChecked}" />
                    <RadioButton x:Name="BrowseMyMaps"
                                 Grid.Column="0" Grid.Row="1"
                                 Unchecked="RadioButtonUnchecked"
                                 HorizontalAlignment="Left"
                                 Content="Browse my maps" />
                    <Button x:Name="SearchButton"
                            Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"
                            Content="Get maps"
                            Margin="0,5,0,0"
                            Click="SearchButton_Click" />
                    <ListBox x:Name="MapListBox"
                             Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"
                             SelectionMode="Single"
                             Margin="0,5,0,0"
                             DisplayMemberPath="Title"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>
                    <Button x:Name="LoadMapButton"
                            Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="2"
                            Content="Load selected map"
                            Margin="0,5,0,0"
                            Click="LoadMapButtonClick" />
                </Grid>
            </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.