View in MAUI WPF WinUI UWP 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.xaml SearchPortalMaps.xaml SearchPortalMaps.xaml.cs
<UserControl x:Class="ArcGIS.WPF.Samples.SearchPortalMaps.SearchPortalMaps"
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.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition Height="100" />
<RowDefinition />
</Grid.RowDefinitions>
<RadioButton x:Name="SearchPublicMaps"
Grid.Row="0"
Grid.Column="0"
HorizontalAlignment="Left"
Content="Search public maps:"
IsChecked="True" />
<TextBox x:Name="SearchText"
Grid.Row="0"
Grid.Column="1"
IsEnabled="{Binding ElementName=SearchPublicMaps, Path=IsChecked}" />
<RadioButton x:Name="BrowseMyMaps"
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Left"
Content="Browse my maps" />
<Button x:Name="SearchButton"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="0,5,0,0"
Click="SearchButton_Click"
Content="Get maps" />
<ListBox x:Name="MapListBox"
Grid.Row="3"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="0,5,0,0"
DisplayMemberPath="Title"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectionMode="Single" />
<Button x:Name="LoadMapButton"
Grid.Row="4"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="0,5,0,0"
Click="LoadMapButtonClick"
Content="Load selected map" />
</Grid>
</Border>
</Grid>
</UserControl>