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.

Configurable attributes

The following table describes the configurable attributes of the Query widget.

AttributeDescription

queries

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

  • name—String. The name of the query task. There is no default.
  • url—String. A feature layer or an image service URL for the layer you want to query. There is no default.
  • icon—String. The icon of the query task. It is a Base64 string. If empty, the default icon is applied.
  • filter—Object. The expr attribute of filter takes the form of a basic SQL statement and uses it to filter features. There is no default.
  • showSQL—Boolean. If true, the Query widget will display an SQL expression for end users. There is no default.
  • 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. 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. There is no default. See Format Popup Content for more information.
  • useLayerSymbol—Boolean. If true, resultsSymbol is ignored and the renderer defined by the REST service is used as the symbol of query results. There is no default.
  • resultsSymbol—Object. This is the symbol of query results. There is no default.
  • enableExport—Boolean. If true, query results can be exported as CSV, FeatureCollection, and GeoJSON files. There is no default.
  • singleResultLayer—Boolean. 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. There is no default.
  • webMapLayerId—String. 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. There is no default.
  • orderByFields—String array. Use one or more field names to order the query results. There is no default.

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"
    }
  ]
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.