View in MAUI UWP WPF WinUI View on GitHub
import InlineCode from "@esri-dx/starship-doc-components/components/InlineCode.astro";

Find features in a sublayer based on attributes and location.

Image of query map image sublayer

Use case

Sublayers of an

may expose a
through a
property. This allows you to perform the same queries available when working with a table from a
: attribute query, spatial query, statistics query, query for related features, etc. An image layer with a sublayer of counties can be queried by population to only show those above a minimum population.

How to use the sample

Specify a minimum population in the input field (values under 1810000 will produce a selection in all layers) and click the query button to query the sublayers in the current view extent. After a short time, the results for each sublayer will appear as graphics.

How it works

  1. Create an
    object using the URL of an image service.
  2. After loading the layer, get the sublayer you want to query with
    .
  3. Load the sublayer, and then get its
    with
    .
  4. Create
    . You can set
    to query against a table attribute and/or set
    to limit the results to an area of the map.
  5. Call
    to get a
    with features matching the query. The result is an iterable of features.

Relevant API

  • ArcGISMapImageLayer
  • ArcGISMapImageSublayer
  • QueryParameters
  • ServiceFeatureTable

About the data

The

in the map uses the “USA” map service as its data source. This service is hosted by ArcGIS Online, and is composed of four sublayers: “states”, “counties”, “cities”, and “highways”. Since the
,
, and
tables all have a
field, they can all execute a query against that attribute and a map extent.

Tags

search and query

Sample Code

MapImageSublayerQuery.xaml MapImageSublayerQuery.xaml MapImageSublayerQuery.xaml.cs
<UserControl x:Class="ArcGIS.WinUI.Samples.MapImageSublayerQuery.MapImageSublayerQuery"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Margin="0,0,0,5"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontWeight="SemiBold"
Text="[POP2000] &gt; " />
<TextBox x:Name="PopulationTextBox"
Grid.Row="0"
Grid.Column="1"
Margin="5,0,0,5"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
HorizontalContentAlignment="Right"
Text="1810000" />
<Button x:Name="QuerySublayers"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
Click="QuerySublayers_Click"
Content="Query in extent" />
</Grid>
</Border>
</Grid>
</UserControl>