Search a portal for maps

This sample demonstrates searching a portal for web maps and loading them in the map view. You can search ArcGIS Online public web maps using tag values or browse the web maps in your account.

Search portal maps sample

Instructions

  1. When the sample starts, you will be presented with a dialog for entering OAuth settings. If you need to create your own settings, sign in with your developer account and use the ArcGIS for Developers dashboard to create an Application to store these settings.
  2. Enter values for the following OAuth settings.
    • Client ID: a unique alphanumeric string identifier for your application
    • Redirect URL: a URL to which a successful OAuth login response will be sent
  3. If you do not enter OAuth settings, you will be able to search public web maps on ArcGIS Online. Browsing the web map items in your ArcGIS Online account will be disabled, however.

Code

<UserControl 
    x:Class="ArcGISRuntime.UWP.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="using:Esri.ArcGISRuntime"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls" 
    mc:Ignorable="d" 
    d:DesignHeight="500" d:DesignWidth="600">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <CommandBar>
            <AppBarButton Width="100" AllowFocusOnInteraction="True"
                Content="Search Maps">
                <AppBarButton.Flyout>
                    <Flyout x:Name="SearchMapsFlyout">
                        <Grid Width="300">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="2*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Row="0" Grid.Column="0"
                                       VerticalAlignment="Center" HorizontalAlignment="Right"
                                       Text="Keyword:"/>
                            <TextBox x:Name="SearchText"
                                     Grid.Row="0" Grid.Column="1"
                                     Margin="5"
                                     HorizontalAlignment="Stretch"/>
                            <Button x:Name="SearchMapsButton"
                                    Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
                                    HorizontalAlignment="Stretch"
                                    Margin="10"
                                    Content="Search"
                                    Click="SearchMapsClicked"/>
                            <ListView x:Name="SearchMapsList"
                                     Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
                                     DisplayMemberPath="Title"
                                     HorizontalAlignment="Stretch"
                                     Height="100"
                                     SelectionChanged="OnMapSelectionChanged"/>
                        </Grid>
                    </Flyout>
                </AppBarButton.Flyout>
            </AppBarButton>
            <AppBarButton Width="80"
                Content="My Maps" 
                Click="MyMapsClicked">
                <AppBarButton.Flyout>
                    <Flyout x:Name="MyMapsFlyout">
                        <ListView x:Name="MyMapsList" 
                                  DisplayMemberPath="Title" 
                                  SelectionChanged="OnMapSelectionChanged"/>
                    </Flyout>
                </AppBarButton.Flyout>
            </AppBarButton>
        </CommandBar>
        <esriUI:MapView x:Name="MyMapView" 
                        Grid.Row="1"/>
        <ContentDialog x:Name="OAuthSettingsDialog" 
                       Grid.Row="1"
                       PrimaryButtonText="Save" SecondaryButtonText="Cancel"
                       Title="OAuth Configuration Settings">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock Text="Client ID:"
                           Grid.Row="0"
                           HorizontalAlignment="Right" VerticalAlignment="Center"
                           Margin="5,0"/>
                <TextBox x:Name="ClientIdTextBox"
                         Grid.Row="0" Grid.Column="1"
                         HorizontalAlignment="Left" VerticalAlignment="Center"
                         Width="220"
                         IsReadOnly="True"
                         Margin="0,3"/>
                <TextBlock Text="Redirect URL:"
                           Grid.Row="1"
                           HorizontalAlignment="Right" VerticalAlignment="Center"
                           Margin="5,0"/>
                <TextBox x:Name="RedirectUrlTextBox" 
                         Grid.Row="1" Grid.Column="1"
                         HorizontalAlignment="Left" VerticalAlignment="Center"
                         Width="220"
                         IsReadOnly="True"
                         Margin="0,3"/>
            </Grid>
        </ContentDialog>
    </Grid>
</UserControl>


In this topic
  1. Instructions
  2. Code