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

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             x:Class="ArcGISRuntimeXamarin.Samples.SearchPortalMaps.SearchPortalMaps">
  <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"
                   IsVisible="False"
                   Intent="Form">
            <TableRoot>
                <TableSection Title="Search Public Maps">
                    <EntryCell x:Name="SearchTextEntry"
                               Label="Search Text:"
                               Text=""/>
                    <ViewCell>
                        <StackLayout Orientation="Horizontal"
                                     HorizontalOptions="CenterAndExpand">
                            <Button Text="Cancel"
                                    Clicked="CancelSearchClicked"
                                    Margin="20,0"/>
                            <Button Text="Search"
                                    Clicked="SearchMapsClicked"/>
                        </StackLayout>
                    </ViewCell>
                </TableSection>
            </TableRoot>
        </TableView>
        <ListView x:Name="MapsListView" 
                  IsVisible="False"
                  ItemSelected="MapItemSelected">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <StackLayout>
                                <Label Text="{Binding Title}"/>
                            </StackLayout>
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <Grid x:Name="OAuthSettingsGrid" 
          Grid.Row="0"
          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" VerticalOptions="Start"
             Text="OAuth Settings"/>
            <Label Grid.Row="1"
             HorizontalOptions="End" VerticalOptions="Center"
             Text="Client ID:"/>
            <Entry x:Name="ClientIDEntry" 
             Grid.Row="1" Grid.Column="1" 
             Placeholder="mYCl1enTiD"
             HorizontalOptions="Start" VerticalOptions="Center"
             WidthRequest="240"/>
            <Label Grid.Row="2"
             HorizontalOptions="End" VerticalOptions="Center"
             Text="Redirect URL:"/>
            <Entry x:Name="RedirectUrlEntry" 
             Grid.Row="2" Grid.Column="1" 
             Placeholder="http://my.redirect/url"
             HorizontalOptions="Start" VerticalOptions="Center"
             WidthRequest="240"/>
            <Button Grid.Row="3" Grid.Column="0"
              HorizontalOptions="End" VerticalOptions="End"
              Text="Cancel"
              Clicked="OAuthSettingsCancel"/>
            <Button Grid.Row="3" Grid.Column="1"
              HorizontalOptions="CenterAndExpand" VerticalOptions="End"
              Text="Use Settings"
              Clicked="SaveOAuthSettings"/>
        </Grid>
        <StackLayout Grid.Row="1"
                     Orientation="Horizontal"
                     HorizontalOptions="Center">
            <Button Text="Search Maps"
              Clicked="ShowSearchUI"/>
            <Button Text="My Maps"
              Clicked="GetMyMaps"/>
        </StackLayout>
  </Grid>
</ContentPage>


In this topic
  1. Instructions
  2. Code