Portal Spatial Search Online

This sample shows how to use the Portal API to search public webmaps matching the search criterion on ArcGIS Online. To use the sample, click on Initialize button to initialize the portal. Once the portal is initialized it is available to perform searches and queries. Enter the search parameters and click Find WebMaps. Webmaps matching the search parameters are listed and are marked on the Map using a GraphicsLayer.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.PortalSpatialSearch"
    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/client/2009">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <!-- Webmap Symbol-->
            <esri:PictureMarkerSymbol x:Key="MyWebMapMarkerSymbol" Source="/Assets/Images/webmap.png"/>
            <esri:SimpleRenderer x:Key="MyGraphicsLayerRenderer" Symbol="{StaticResource MyWebMapMarkerSymbol}"/>
        </Grid.Resources>

        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="285"/>
        </Grid.ColumnDefinitions>

        <!-- Left column, map with search results as graphics -->
        <esri:Map x:Name="MyMap" UseAcceleratedDisplay="True" WrapAround="True" Extent="-10827200,3228880,-10292800,3604400" Grid.Column="0" >
            <esri:ArcGISTiledMapServiceLayer
                Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
            <esri:GraphicsLayer ID="MyGraphicsLayer" Renderer="{StaticResource MyGraphicsLayerRenderer}" 
                                MouseLeftButtonUp="GraphicsLayer_MouseLeftButtonUp"
                                PropertyChanged="GraphicsLayer_PropertyChanged"/>
        </esri:Map>

        <!-- Right column, search inputs and result items -->
        <Border Grid.Column="1"  BorderBrush="Black" BorderThickness="1" >
            <Grid Background="White">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MaxWidth="110"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition MaxHeight="25"/>
                    <RowDefinition MaxHeight="30"/>
                    <RowDefinition MaxHeight="30"/>
                    <RowDefinition MaxHeight="35"/>
                    <RowDefinition MaxHeight="2"/>
                    <RowDefinition MaxHeight="30"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Grid.ColumnSpan="2" Margin="5"
                           Text="Search for web maps within the current map extent" 
                           VerticalAlignment="Center"  />
                <TextBlock Text="Query string:" VerticalAlignment="Center" Margin="5" Grid.Row="1" Grid.Column="0" />
                <TextBox x:Name="searchText" Text="Gulf" HorizontalAlignment="Left" Width="150" 
                         Grid.Row="1" Grid.Column="1" Margin="5"/>

                <TextBlock Text="Result limit:" VerticalAlignment="Center" Margin="5" Grid.Row="2" Grid.Column="0"/>
                <TextBox x:Name="resultLimit" Text="15" HorizontalAlignment="Left" Width="150" 
                         Grid.Row="2" Grid.Column="1" Margin="5"/>

                <Button Margin="5" Grid.Row="3" Grid.ColumnSpan="2" Content="Find WebMaps" 
                             Width="100" VerticalAlignment="Center" HorizontalAlignment="Left"
                             Click="FindWebMapsButton_Click"/>
                <Border BorderBrush="Black" BorderThickness="1" Grid.Row="4" Grid.ColumnSpan="2" />
                <TextBlock Grid.Row="5" Grid.ColumnSpan="2" HorizontalAlignment="Left" Text="Search Results" 
                       Margin="5" FontSize="12" VerticalAlignment="Center" FontWeight="Bold" />
                <ListBox x:Name="WebMapsListBox" Grid.Row="6" Grid.ColumnSpan="2">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical" Margin="2" Width="210">
                                <Image Source="{Binding ThumbnailUri}" Margin="5" Stretch="UniformToFill" 
                                   MouseLeftButtonUp="Image_MouseLeftButtonUp" />
                                <TextBlock TextWrapping="Wrap" Text="{Binding Title, StringFormat='Title: {0}'}" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </Border>
    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014