Search for webmap

View inWPFUWPFormsiOSAndroid
View on GitHub

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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="ArcGISRuntime.Samples.SearchPortalMaps.SearchPortalMaps"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:d="http://xamarin.com/schemas/2014/forms/design"
    xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="70" />
        </Grid.RowDefinitions>

        <esriUI:MapView x:Name="MyMapView" Grid.Row="0" />
        <TableView
            x:Name="SearchMapsUI"
            Grid.Row="0"
            BackgroundColor="WhiteSmoke"
            Intent="Form"
            IsVisible="False">
            <TableRoot>
                <TableSection Title="Search public maps">
                    <ViewCell>
                        <StackLayout Orientation="Horizontal">
                            <Label Text="Search text:">
                                <Label.TextColor>
                                    <OnPlatform x:TypeArguments="Color">
                                        <On Platform="Android" Value="DarkGray" />
                                    </OnPlatform>
                                </Label.TextColor>
                            </Label>
                            <Entry
                                x:Name="SearchTextEntry"
                                HorizontalOptions="Start"
                                Placeholder=""
                                VerticalOptions="Center"
                                WidthRequest="240">
                                <Entry.TextColor>
                                    <OnPlatform x:TypeArguments="Color">
                                        <On Platform="Android" Value="DarkGray" />
                                    </OnPlatform>
                                </Entry.TextColor>
                            </Entry>
                        </StackLayout>
                    </ViewCell>
                    <ViewCell>
                        <StackLayout HorizontalOptions="FillAndExpand" Orientation="Horizontal">
                            <Button
                                Margin="20,0"
                                Clicked="CancelSearchClicked"
                                HorizontalOptions="FillAndExpand"
                                Text="Cancel" />
                            <Button
                                Clicked="SearchMapsClicked"
                                HorizontalOptions="FillAndExpand"
                                Text="Search" />
                        </StackLayout>
                    </ViewCell>
                </TableSection>
            </TableRoot>
        </TableView>
        <ListView
            x:Name="MapsListView"
            BackgroundColor="WhiteSmoke"
            IsVisible="False"
            ItemSelected="MapItemSelected"
            SelectionMode="Single">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <TextCell Text="{Binding Title}">
                        <TextCell.TextColor>
                            <OnPlatform x:TypeArguments="Color">
                                <On Platform="Android" Value="DarkGray" />
                            </OnPlatform>
                        </TextCell.TextColor>
                    </TextCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <Grid
            x:Name="OAuthSettingsGrid"
            Grid.Row="0"
            BackgroundColor="WhiteSmoke"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            WidthRequest="300">
            <Grid.RowDefinitions>
                <RowDefinition Height="60" />
                <RowDefinition Height="40" />
                <RowDefinition Height="40" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Label
                Grid.Row="0"
                Grid.ColumnSpan="2"
                HorizontalOptions="Center"
                Text="OAuth Settings"
                VerticalOptions="Start">
                <Label.TextColor>
                    <OnPlatform x:TypeArguments="Color">
                        <On Platform="Android" Value="DarkGray" />
                    </OnPlatform>
                </Label.TextColor>
            </Label>
            <Label
                Grid.Row="1"
                HorizontalOptions="End"
                Text="Client ID:"
                VerticalOptions="Center">
                <Label.TextColor>
                    <OnPlatform x:TypeArguments="Color">
                        <On Platform="Android" Value="DarkGray" />
                    </OnPlatform>
                </Label.TextColor>
            </Label>
            <Entry
                x:Name="ClientIDEntry"
                Grid.Row="1"
                Grid.Column="1"
                HorizontalOptions="Start"
                Placeholder="mYCl1enTiD"
                VerticalOptions="Center"
                WidthRequest="240">
                <Entry.TextColor>
                    <OnPlatform x:TypeArguments="Color">
                        <On Platform="Android" Value="DarkGray" />
                    </OnPlatform>
                </Entry.TextColor>
            </Entry>
            <Label
                Grid.Row="2"
                HorizontalOptions="End"
                Text="Redirect URL:"
                VerticalOptions="Center">
                <Label.TextColor>
                    <OnPlatform x:TypeArguments="Color">
                        <On Platform="Android" Value="DarkGray" />
                    </OnPlatform>
                </Label.TextColor>
            </Label>
            <Entry
                x:Name="RedirectUrlEntry"
                Grid.Row="2"
                Grid.Column="1"
                HorizontalOptions="Start"
                Placeholder="http://my.redirect/url"
                VerticalOptions="Center"
                WidthRequest="240">
                <Entry.TextColor>
                    <OnPlatform x:TypeArguments="Color">
                        <On Platform="Android" Value="DarkGray" />
                    </OnPlatform>
                </Entry.TextColor>
            </Entry>
            <Button
                Grid.Row="3"
                Grid.Column="0"
                Clicked="OAuthSettingsCancel"
                HorizontalOptions="FillAndExpand"
                Text="Cancel"
                VerticalOptions="End" />
            <Button
                Grid.Row="3"
                Grid.Column="1"
                Clicked="SaveOAuthSettings"
                HorizontalOptions="FillAndExpand"
                Text="Use Settings"
                VerticalOptions="End" />
        </Grid>
        <StackLayout
            Grid.Row="1"
            HorizontalOptions="FillAndExpand"
            Orientation="Horizontal">
            <Button
                Clicked="ShowSearchUI"
                HorizontalOptions="FillAndExpand"
                Text="Search Maps" />
            <Button
                Clicked="GetMyMaps"
                HorizontalOptions="FillAndExpand"
                Text="My Maps" />
        </StackLayout>
    </Grid>
</ContentPage>

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