Skip To Content

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.

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

Caution:

Attempting to run a spatial query for a feature that is highly complex (such as a polygon feature with a high number of vertices) may overload the widget and not return results. If this happens, you can try generalizing the feature. Make sure you are in compliance with your server's maximum resource limits.

Note:

The widget supports setting individual subtype sublayers from subtype group layers as query layers.

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 an icon from a file. Click the Delete button to remove unused uploaded icons.
      Note:

      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 includes 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 an 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—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 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—Return features that are within the current map extent or that intersect 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 an information icon.
    • Results—Define how the widget displays query results.
      • Label—Customize the label for the results list.
      • Select mode—Choose how many records users can select from the results list.
        • Single—Users can select one record at a time.
        • Multiple—Users can select multiple records.
      • Configure each record—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. If you choose Customize, only the fields you specify as display fields or include in the heading are exported when the user exports to JSON, CSV, GeoJSON, or ArcGIS item.
      • 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 Vertical, Horizontal, or Icon to customize the style for queries in the widget.
  • Result style—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 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 define.

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 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 the action data. You can also add the Zoom to action to zoom the map to the selected feature.