Web AppBuilder for ArcGIS (Developer Edition)

Query

The Query widget enables you to query information from a map service, a feature service, or an image service by executing a predefined query. It is performed on a single layer.

The following table lists the configurable attributes of the Query widget:

AttributeDescription

queries

Array of query task. Each element has the following child attributes:

  • name—String. There is no default. The name of the query task.
  • url—String. There is no default. A feature layer or an image service URL for the layer you want to query.
  • icon—String. The icon of the query task. It is a Base64 string. If empty, the default icon is applied.
  • filter—Object. There is no default. The expr attribute of filter takes the form of a basic SQL statement and uses it to filter features.
  • showSQL—Boolean. There is no default. If true, the Query widget will display a SQL expression for end users.
  • spatialFilter—Object. There is no default. This object has the following four attributes:
    • currentMapExtent—Returns features within current map extent.
    • drawing—Returns features that intersect the shape drawn on the map.
    • useFeatures—Returns features that have a spatial relationship with features in another layer.
    • fullLayerExtent—Returns features within the full extent of the map.
  • popupInfo—Object. There is no default. This object is used for PopupTemplate. If the subattribute readFromWebMap is true, the Query widget will use the pop-up defined in the web map. See Format Popup Content for more information.
  • useLayerSymbol—Boolean. There is no default. If true, resultsSymbol is ignored and the renderer defined by the REST service is used as the symbol of query results.
  • resultsSymbol—Object. There is no default. This is the symbol of query results.
  • enableExport—Boolean. There is no default. If true, query results can be exported as CSV, FeatureCollection, and GeoJSON files.
  • singleResultLayer—Boolean. There is no default. If true, only one result layer is created regardless of the number of times the query task executes. If false, the Query widget creates a new result layer each time the query task executes.
  • webMapLayerId—String. There is no default. If the query layer exists in the web map, webMapLayerId is the layer ID. If the query layer doesn’t exist in the web map, webMapLayerId is empty.
  • orderByFields—String array. There is no default. Use one or more field names to order the query results.

Example:

{
    Example:
{
  "queries": [
    {
      "url": "http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer/0",
      "name": "SampleWorldCities - Cities",
      "icon": "",
      "filter": {
        "logicalOperator": "AND",
        "parts": [
          {
            "fieldObj": {
              "name": "POP_CLASS",
              "label": "POP_CLASS",
              "shortType": "string",
              "type": "esriFieldTypeString"
            },
            "operator": "stringOperatorIs",
            "valueObj": {
              "isValid": true,
              "type": "unique",
              "value": "250,000 to 499,999"
            },
            "interactiveObj": "",
            "caseSensitive": false,
            "expr": "POP_CLASS = '250,000 to 499,999'"
          }
        ],
        "expr": "POP_CLASS = '250,000 to 499,999'"
      },
      "showSQL": true,
      "spatialFilter": {
        "currentMapExtent": {
          "default": true
        },
        "drawing": {
          "default": false,
          "geometryTypes": [
            "POINT",
            "POLYLINE",
            "EXTENT"
          ],
          "buffer": {
            "defaultDistance": 100,
            "defaultUnit": "MILES"
          }
        },
        "useFeatures": {
          "default": false,
          "relationships": [
            {
              "relationship": "SPATIAL_REL_INTERSECTS",
              "label": "intersect"
            },
            {
              "relationship": "SPATIAL_REL_WITHIN",
              "label": "contain"
            },
            {
              "relationship": "SPATIAL_REL_CONTAINS",
              "label": "within"
            }
          ],
          "buffer": {
            "defaultDistance": 100,
            "defaultUnit": "MILES"
          }
        },
        "fullLayerExtent": {
          "default": false
        }
      },
      "popupInfo": {
        "readFromWebMap": true
      },
      "orderByFields": [],
      "useLayerSymbol": false,
      "resultsSymbol": {
        "color": [
          0,
          0,
          128,
          128
        ],
        "size": 18,
        "angle": 0,
        "xoffset": 0,
        "yoffset": 0,
        "type": "esriSMS",
        "style": "esriSMSCircle",
        "outline": {
          "color": [
            0,
            0,
            128,
            255
          ],
          "width": 0.75,
          "type": "esriSLS",
          "style": "esriSLSSolid"
        }
      },
      "keepResultsOnMapAfterCloseWidget": false,
      "enableExport": true,
      "singleResultLayer": true,
      "webMapLayerId": "SampleWorldCities_3008"
    }
  ]
}