layerDefinition

The layerDefinition object defines the attribute schema and drawing information for a layer drawn using client-side graphics. This could include a feature collection, a CSV file referenced through the web, or a single layer in an ArcGIS map service.

Properties

Property

Details

definitionExpression

An optional SQL-based definition expression string that narrows down the data to be displayed in the layer. Used with ArcGIS Server map services.

Example: "STATE_NAME='Kansas' and POP2007>25000"

displayField

A string containing the name of the field that best summarizes the feature. Values from this field are used by default as the titles for pop-up windows.

drawingInfo

A drawingInfo object containing drawing, labeling, and transparency information for the layer.

fields

An array of field objects containing information about the attribute fields for the feature collection or layer.

geometryType

A string defining the type of geometry used in the layer definition. Available values are: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope.

This property is used with feature collections and CSV files. The only supported geometry for CSV files is esriGeometryPoint.

hasAttachments

A Boolean indicating whether attachments should be loaded for the layer.

maxScale

A number representing the maximum scale at which the layer definition will be applied. The number is the scale's denominator; thus, a value of 2400 represents a scale of 1/2,400. A value of 0 indicates that the layer definition will be applied no matter how far you zoom in.

minScale

A number representing the minimum scale at which the layer definition will be applied. The number is the scale's denominator; thus, a value of 2400 represents a scale of 1/2,400.

name

A string containing a unique name for the layer that could be displayed in a legend.

objectIdField

A string indicating the name of the object ID field in the dataset.

templates

An array of template objects describing features that can be created in this layer. Templates are used with map notes, other feature collections, and editable web-based CSV layers. They are not used with ArcGIS feature services, which already have feature templates defined in the service.

Templates are defined as a property of the layer definition when there are no types defined; otherwise, templates are defined as properties of the types.

type

A string indicating whether the layerDefinition applies to a Feature Layer or a Table.

typeIdField

A string containing the name of the field holding the type ID for the features, if types exist for the dataset. Each available type has an ID, and each feature's typeIdField can be read to determine the type for each feature.

types

An array of type objects available for the dataset. This is used when the typeIdField is populated.

Types contain information about the combinations of attributes that are allowed for features in the dataset. Each feature in the dataset can have a type, indicated in its typeIdField.

Examples

Single layer from an ArcGIS map service

This layer definition is applied to a single layer in an ArcGIS map service to override the default styling. For a full example, see Single layer from an ArcGIS map service as an operational layer.

"layerDefinition": {
      "drawingInfo": {"renderer": {
        "type": "simple",
        "symbol": {
          "color": [
            108,
            151,
            203,
            0
          ],
          "outline": {
            "color": [
              108,
              151,
              203,
              255
            ],
            "width": 1.5,
            "type": "esriSLS",
            "style": "esriSLSSolid"
          },
          "type": "esriSFS",
          "style": "esriSFSSolid"
        }
      }},
      "minScale": 500000000,
      "maxScale": 0
    }

CSV file

This example shows how a layer definition might look when a web-based CSV file is referenced by the map and made editable. For a full example, see CSV operational layer.

"layerDefinition": {
      "geometryType": "esriGeometryPoint",
      "objectIdField": "__OBJECTID",
      "type": "Feature Layer",
      "typeIdField": "",
      "drawingInfo": {
        "renderer": {. . .},
        "fixedSymbols": true
      },
      "fields": [
        {
          "name": "__OBJECTID",
          "alias": "__OBJECTID",
          "type": "esriFieldTypeOID",
          "editable": false,
          "nullable": false,
          "domain": null
        },
        {
          "name": "Src",
          "alias": "Src",
          "type": "esriFieldTypeString",
          "length": 255,
          "editable": true,
          "nullable": true,
          "domain": null
        },
        . . .
      ],
      "types": [],
      "capabilities": "Query",
      "name": "eqs7day-M2",
      "templates": [{
        "description": "",
        "name": "New Feature",
        "prototype": {. . .}
      }]
    }

Feature collection of map notes

This example shows a layer definition as applied to a feature collection of map notes. The map notes in this example are comprised of graphical markup that anyone can edit.

"layerDefinition": {
            "objectIdField": "OBJECTID",
            "templates": [],
            "type": "Feature Layer",
            "drawingInfo": {. . .},
            "displayField": "TITLE",
            "visibilityField": "VISIBLE",
            "name": "Trails",
            "hasAttachments": false,
            "typeIdField": "TYPEID",
            "capabilities": "Query,Editing",
            "types": [
              {
                "id": 0,
                "templates": [{. . .
                }],
                "domains": {},
                "name": "Walking"
              },
              {
                "id": 1,
                "templates": [{. . .}],
                "domains": {},
                "name": "Biking"
              },
              . . .
            ],
            "geometryType": "esriGeometryPolyline",
            "fields": [
              {
                "alias": "Type ID",
                "name": "TYPEID",
                "type": "esriFieldTypeInteger",
                "editable": true
              },
			           {
                "alias": "OBJECTID",
                "name": "OBJECTID",
                "type": "esriFieldTypeOID",
                "editable": false
              },
              {
                "alias": "Title",
                "name": "TITLE",
                "length": 50,
                "type": "esriFieldTypeString",
                "editable": true
              },
              . . . 
            ]
          }
12/11/2012