USGS Home Logo and link to The National Map
Advanced Viewer Help - Query

The Query widget allows you to retrieve information from source data by executing a predefined query. Data sources can be one of the following:

  • Feature layer in the current map
  • Feature layer as an item in the portal
  • Feature layer from an ArcGIS Server REST service Tip: A feature layer can be from a map service or a feature service
  • Imagery layer from an image service
  • Table

The Query tool serves as a query builder during configuration, allowing you to define the query by specifying source data, filters, and displaying fields in query results. Each query works with a single layer. However, you can define multiple queries for a single app and data layers can be from multiple sources.

  1. Click the Query tool to open it. A list of queries are shown under the Tasks tab if you have configured more than one query.
    Query list
  2. If the tool has only one query and does not ask for input, clicking the tool will run the query and immediately display the results. If the tool has only one query and asks for input, clicking the tool will display the query with user inputs. Note: Input may include an attribute criteria, one or many spatial filters, or a combination of both.
  3. Click one of the queries. The query may execute differently depending on your configuration.
    1. If the query does not ask for input, the result shows under the Results tab and the resulting features display on the map with the symbol specified during configuration.
    2. If Ask for values is checked in the configuration, a text box displays prompting you for a new value for the parameter. The default value initially shows in the box. If unique values are set, the text box will list all of them.
    3. Using one or more spatial filters.
      • Only return features within current map extent—Return features within current map extent.
      • Only return features that intersect with the shape drawn on the map—A set of drawing tools can be used to draw shapes on the map to define the area. Optionally, a search distance can be applied to the shapes.
        Query spatial fetatures
      • Only return features that have a spatial relationship with features in another layer—The results are based on the spatial relationship between features in the query layer and the related layer. Optionally, a search distance can be applied to the geometries of the features in the related layer.
        Query spatial relationship
      • Return features within full extent of the map—Return features within full extent of the map.
    4. Click Execute to run the query. If the layer has related data, the related records are also included in the results. Features resulting from the query are highlighted on the map with the symbol specified during configuration.
  4. Taking action on the results set, such as doing statistics and exporting results.
    Query results
    Tip: The maximum features a query can return depends on the maxRecordCount property set in the service. By default, it is 1,000. For example, if the default value is used and 1,300 features are expected to be returned from a query, 1,000 features in the query result panel. Scrolling down the panel will reveal the remaining 300 features.

    Alternatively, if the query is performed on a related table, the related features will display in the result.