Query widget

The Query widget allows you to retrieve information from a data source by running an attribute or spatial filter query. The results of a query generate an output data source that other widgets can use.


Use this widget to support app design requirements such as the following:

  • You want to allow users to find features based on a query expression.
  • You want to allow users to draw a shape on a map and return features that intersect with the shape drawn.
  • You want to allow users to find features that have a specific spatial relationship (such as intersect or overlap) with the shapes of selected features from other widgets.
  • You want to use the results from the query to create features for other widgets.

Usage notes

The Query widget requires that a data source be set for each query that you add. Each query works with a single layer, and you can define multiple attribute and spatial filters. You can also create multiple queries and use layers from several data sources. A query can be configured with or without a map. To display the features returned from a query in a Map widget, you can either set an action to have them automatically show or use a data action that allows the user to click a button. Currently, using a scene layer requires adding a Record selection changes trigger instead, so users can click a query result to highlight it on the map.


The Query widget includes the following settings:

  • New query—Create a query and specify the following settings in the Set query panel:
    • Data—Select the data you want to query. You can only select one data source per query. Feature layers, feature layers in selected web maps and web scenes, data views, output data source, and feature service URLs are supported.
    • Label—Customize the name of each query. If there is a single query in a widget, you can turn off the display label for vertical and icon arrangement style.
    • Icon—Choose an icon for each query displayed in the widget and the list of queries in the content panel. You can choose icons from the General and Arrows galleries or add your icon from a file. Click the Delete button to remove unused uploaded icons.

      You can upload the following image formats: PNG, GIF, JPG, JPEG, and BMP. To preserve optimal performance, there is a 10MB size limit for each upload.

    • Attribute filter—Build SQL expressions to specify the attribute filter criteria. The SQL Expression Builder that opens provides several options for creating complex and interactive queries.
      • Label—Customize the label for the attribute filter section.
      • Description—Provide instructions for a specific audience, such as new users, that appears as hover text on a more information icon.
    • Spatial filter—Select which spatial filters will be available and, optionally, choose a map widget.
      • Label—Customize the label for the spatial filter section.
      • Selected features from data source—Choose to return features that have a spatial relationship with features in another layer. Optionally, a search distance can be applied to the geometries of the features in the related layer.
        • Spatial relationship rules—Choose which of the following spatial relationships to provide to users:
          • Intersect—Part of a feature from the source layer is contained in a feature from the filter layer.
          • Contain—The feature from the source layer is completely enclosed by the feature from the filter layer.
          • Cross—The feature from the source layer crosses a feature from the filter layer.
          • Envelope Intersect—The envelope of the source layer intersects with the envelope of the filter layer.
          • Index Intersect—The envelope of the source layer intersects the index entry of the filter layer.
          • Overlap—Features from the source layer overlap features from the filter layer.
          • Touch—The feature from the source layer touches the border of a feature from the filter layer.
          • Within—The feature from the filter layer is completely enclosed by the feature from the source layer.
        • Enable buffer—Add a search distance. You can define the default distance and unit.
      • Geometries from a map—Choose to return features that are within the current map extent or that intersect with a shape drawn on the map. You can turn the draw tools on and off to control which tools are available in the widget.
      • Description—Provide instructions for a specific audience, such as new users, that appear as hover text on a more information icon.
    • Results—Define how to display the query results.
      • Label—Customize the label for the results list.
      • Configure each record—Choose to honor the settings from the source data or customize the results by specifying which fields to display from the layer and providing a meaningful heading.
      • Expand by default—Check this box to expand all result nodes by default.
      • Sort records—Configure which fields to sort by for the results list.
  • Arrangement style—Choose from Vertical, Horizontal, or Icon to customize the style for queries in the widget.
  • Result style—Choose to organize query results horizontally or vertically and on a single page or multiple pages.
    • Number of records per page (Available when you choose Multipage for the Paging style)—Define the number of records that display per page. This number can be no less than 10 and no greater than 1,000. At run time, users can choose how many results to display per page using a drop-down menu or by typing a number. The drop-down menu is populated with values equal to 100 percent, 50 percent, and 33 percent of the number you provide here.

      The Query widget does not honor any maximum record count limitations you set for data views.

Interaction options

The Query widget generates an output data source that can be used in other widgets. The interaction with additional widgets using the same output data source is achieved through adding actions. For example, the map can automatically display the query results and zoom to the features. In the Query widget settings, on the Action tab, add the Records created trigger, select the target map, and add actions for Show on map and Zoom to.

The query results are shown in a list. To select the item in the list and select the corresponding feature on the map, add the Record selection changes trigger for the Query widget. Select the target framework, add the Select data records action, and configure it with the feature layer for the map and the fields that bind the connection between the trigger and action data. Additionally, you can add the Zoom to action to zoom the map to the selected feature.