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.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
                Background="White" BorderBrush="Black" BorderThickness="1"
                HorizontalAlignment="Right" VerticalAlignment="Top"
                Margin="30" Padding="20" Width="375">
            <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 Grid.Row="0" Grid.ColumnSpan="2"
                               FontSize="18"
                       VerticalAlignment="Bottom" HorizontalAlignment="Center"
                       Text="OAuth Settings"/>
                    <TextBlock Grid.Row="1" 
                       VerticalAlignment="Bottom" HorizontalAlignment="Right"
                       Text="Client ID:"/>
                    <TextBox x:Name="ClientIdTextBox" 
                     Grid.Row="1" Grid.Column="1"
                     VerticalAlignment="Bottom" HorizontalAlignment="Left"
                     Width="150"
                     Margin="10,0"/>
                    <TextBlock Grid.Row="2"
                       VerticalAlignment="Top" HorizontalAlignment="Right"
                       Margin="0,10"
                       Text="Redirect Url:"/>
                    <TextBox x:Name="RedirectUrlTextBox" 
                     Grid.Row="2" Grid.Column="1"
                     VerticalAlignment="Top" HorizontalAlignment="Left"
                     Width="150"
                     Margin="10"/>
                    <Button Grid.Row="3" Grid.Column="0"
                    Content="Cancel"
                    Width="70" Height="25"
                    Margin="10,0"
                    VerticalAlignment="Center" HorizontalAlignment="Center"
                    Click="CancelOAuthSettingsClicked"/>
                    <Button Grid.Row="3" Grid.Column="1"
                    Content="Save OAuth Settings"
                    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"
                             Unchecked="RadioButtonUnchecked"
                             Grid.Column="0" Grid.Row="0"
                             HorizontalAlignment="Left"
                             IsChecked="True"
                             Content="Search public maps:"/>
                    <TextBox x:Name="SearchText" IsEnabled="{Binding ElementName=SearchPublicMaps, Path=IsChecked}"
                         Grid.Column="1" Grid.Row="0"/>
                    <RadioButton x:Name="BrowseMyMaps"
                             Unchecked="RadioButtonUnchecked"
                             Grid.Column="0" Grid.Row="1"
                             HorizontalAlignment="Left"
                             Content="Browse my maps"/>
                    <Button x:Name="SearchButton"
                        Margin="40,10"
                        Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"
                        Content="Get maps"
                        Click="SearchButton_Click"/>
                    <ListBox x:Name="MapListBox"
                         Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"
                         Margin="10"
                         SelectionMode="Single"
                         DisplayMemberPath="Title"/>
                    <Button x:Name="LoadMapButton"
                        Margin="40,10"
                        Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="2"
                        Content="Load selected map"
                        Click="LoadMapButtonClick"/>
                </Grid>
            </Grid>
        </Border>
    </Grid>
</UserControl>


In this topic
  1. Instructions
  2. Code