Skip To Content

Query widget

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

Examples

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 use the results from the query to create new 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.

Settings

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.
      Note:

      You can upload the following image formats: PNG, GIF, JPG, JPEG, and BMP.

    • 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.
    • Spatial filter—Select which spatial filters will be available and optionally choose a map widget.
      • Label—Customize the label for the spatial filter section.
      • Current map extent—Return all features in the current map extent.
      • Interactive draw mode—Return features that intersect with the shape drawn on the map. You can turn the draw tools on and off to control which tools are available in the widget.
      • Return all features—Return all features from the data source.
    • Results
      • Label—Customize the label for the results list.
      • List direction—Display the query results returned in a vertical or horizontal list.
      • Fields—Determine which fields to display from the layer.
      • Sort—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 one widget.

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.