SubtypeSublayer

AMD: require(["esri/layers/support/SubtypeSublayer"], (SubtypeSublayer) => { /* code goes here */ });
ESM: import SubtypeSublayer from "@arcgis/core/layers/support/SubtypeSublayer.js";
Class: esri/layers/support/SubtypeSublayer
Inheritance: SubtypeSublayer Accessor
Since: ArcGIS Maps SDK for JavaScript 4.20

Represents a sublayer in a SubtypeGroupLayer. Each SubtypeSublayer is not a standalone service, but rather each sublayer corresponds to one subtype in the source feature service. This pattern allows each sublayer to be symbolized independently of one another, without requiring an individual service per sublayer. This relationship differs from the relationship between the MapImageLayer and its sublayers. In the case with the MapImageLayer, its sublayers represent individual map services.

The SubtypeSublayers are identified by their unique subtypeCode. You can configure the properties of each sublayer while initializing the SubtypeGroupLayer

See also
Example
// Only includes one SubtypeSublayer from the SubtypeGroupLayer
let layer = new SuptypeGroupLayer({
  url: "https://sampleserver7.arcgisonline.com/server/rest/services/UtilityNetwork/NapervilleElectric/FeatureServer/0",
  sublayers: [{  // autocasts as a Collection of SubtypeSublayers
    subtypeCode: 14,
    visible: true,
    renderer: {
      type: "simple",  // autocasts as a SimpleRenderer()
      symbol: {
        type: "simple-marker",  // autocasts as a SimpleMarkerSymbol()
        style: "circle",
        color: [120, 120, 120, 255],
        size: 6
      }
    }
  }]
});

Constructors

SubtypeSublayer

Constructor
new SubtypeSublayer(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

Describes the layer's supported capabilities.

SubtypeSublayer

The name of the class.

Accessor

Determines if the layer is editable.

SubtypeSublayer

Indicates whether the layer is editable taking in to consideration privileges of the currently signed-in user and whether the parent subtype group layer is editable or not.

SubtypeSublayer

An array of fields in the layer.

SubtypeSublayer

The template used in an associated layer's FeatureForm.

SubtypeSublayer

The geometry type of features in the layer.

SubtypeSublayer

The unique ID assigned to the layer.

SubtypeSublayer

The label definition for this layer, specified as an array of LabelClass.

SubtypeSublayer

Indicates whether to display labels for this layer.

SubtypeSublayer

Indicates whether the layer will be included in the legend.

SubtypeSublayer

The Error object returned if an error occurred while loading.

SubtypeSublayer

Represents the status of a load operation.

SubtypeSublayer

A list of warnings which occurred while loading.

SubtypeSublayer

The maximum scale (most zoomed in) at which the layer is visible in the view.

SubtypeSublayer

The minimum scale (most zoomed out) at which the layer is visible in the view.

SubtypeSublayer

The name of an oidfield containing a unique value or identifier for each feature in the layer.

SubtypeSublayer

The opacity of the layer.

SubtypeSublayer

The SubtypeGroupLayer to which the sublayer belongs.

SubtypeSublayer

Indicates whether to display popups when features in the layer are clicked.

SubtypeSublayer

The popup template for the layer.

SubtypeSublayer

The renderer assigned to the layer.

SubtypeSublayer

The spatial reference of the layer.

SubtypeSublayer

The unique identifier representing the SubtypeSublayer created from the SubtypeGroupLayer.

SubtypeSublayer

The name of the field which holds the id of the subtypes.

SubtypeSublayer

An array of feature templates defined in the feature layer.

SubtypeSublayer

The title of the layer used to identify it in places such as the Legend widget.

SubtypeSublayer
For SubtypeSublayer the type is always "subtype-sublayer". SubtypeSublayer

The absolute URL of the REST endpoint of the feature service.

SubtypeSublayer

Indicates if the layer is visible in the View.

SubtypeSublayer

Property Details

capabilities

Property
capabilities Capabilitiesreadonly
Since: ArcGIS Maps SDK for JavaScript 4.27 SubtypeSublayer since 4.20, capabilities added at 4.27.

Describes the layer's supported capabilities.

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

editingEnabled

Property
editingEnabled Boolean

Determines if the layer is editable.

Default Value:true
See also

effectiveEditingEnabled

Property
effectiveEditingEnabled Booleanreadonly
Since: ArcGIS Maps SDK for JavaScript 4.26 SubtypeSublayer since 4.20, effectiveEditingEnabled added at 4.26.

Indicates whether the layer is editable taking in to consideration privileges of the currently signed-in user and whether the parent subtype group layer is editable or not.

fields

Property
fields Field[]readonly

An array of fields in the layer. Each field represents an attribute that may contain a value for each feature in the layer. For example, a field named POP_2015, stores information about total population as a numeric value for each feature; this value represents the total number of people living within the geographic bounds of the feature.

Example
// define each field's schema
const fields = [
 new Field({
   name: "ObjectID",
   alias: "ObjectID",
   type: "oid"
 }), new Field({
   name: "description",
   alias: "Description",
   type: "string"
 }), new Field ({
   name: "title",
   alias: "Title",
   type: "string"
 })
];

// See the sample snippet for the source property
const layer = new SubtypeSublayer({
  // Object ID field is inferred from the fields array
  fields: fields
});

formTemplate

Property
formTemplate FormTemplateautocast

The template used in an associated layer's FeatureForm. All of the properties and field configurations set on the layer's FeatureForm are handled via the FormTemplate.

Example
// Create the Field Elements to pass into the template
const fieldElement1 = new FieldElement({
  fieldName: "firstname",
  label: "First name",
  description: "First name of emergency contact"
});

const fieldElement2 = new FieldElement({
  fieldName: "lastname",
  label: "Last name",
  description: "Last name of emergency contact"
});

// Create the form's template
const formTemplate = new FormTemplate({
  title: "Emergency information",
  description: "In case of emergency, update any additional information needed",
  elements: [fieldElement1, fieldElement2] // pass in array of field elements from above
});

// Pass the template to the layer
subtypeSublayer.formTemplate = formTemplate;

// Pass the layer to the FeatureForm
const form = new FeatureForm({
  container: "form", // html div referencing the form
  layer: subtypeSublayer
});

geometryType

Property
geometryType Stringreadonly
Since: ArcGIS Maps SDK for JavaScript 4.27 SubtypeSublayer since 4.20, geometryType added at 4.27.

The geometry type of features in the layer. All features must be of the same type.

Possible Values:"point" |"multipoint" |"polyline" |"polygon" |"multipatch" |"mesh"

id

Property
id Stringreadonly

The unique ID assigned to the layer.

labelingInfo

Property
labelingInfo LabelClass[] |null |undefinedautocast
Autocasts from Object[]

The label definition for this layer, specified as an array of LabelClass. Use this property to specify labeling properties for the layer such as label expression, placement, and size.

Multiple Label classes with different where clauses can be used to define several labels with varying styles on the same feature. Likewise, multiple label classes may be used to label different types of features (for example blue labels for lakes and green labels for parks).

See the Labeling guide page for more information and known limitations.

Known Limitations

3D SceneViews only support displaying one LabelClass per feature.

Example
const statesLabelClass = new LabelClass({
  labelExpressionInfo: { expression: "$feature.NAME" },
  symbol: {
    type: "text",  // autocasts as new TextSymbol()
    color: "black",
    haloSize: 1,
    haloColor: "white"
  }
});

subtypeSubLayer.labelingInfo = [ statesLabelClass ];

labelsVisible

Property
labelsVisible Boolean

Indicates whether to display labels for this layer. If true, labels will appear as defined in the labelingInfo property.

Known Limitations

3D SceneViews only support displaying one LabelClass per feature.

Default Value:true

legendEnabled

Property
legendEnabled Boolean

Indicates whether the layer will be included in the legend.

Default Value:true

loadError

Property
loadError Errorreadonly

The Error object returned if an error occurred while loading.

Default Value:null

loadStatus

Property
loadStatus Stringreadonly

Represents the status of a load operation.

Value Description
not-loaded The object's resources have not loaded.
loading The object's resources are currently loading.
loaded The object's resources have loaded without errors.
failed The object's resources failed to load. See loadError for more details.

Possible Values:"not-loaded" |"loading" |"failed" |"loaded"

Default Value:not-loaded

loadWarnings

Property
loadWarnings Object[]readonly

A list of warnings which occurred while loading.

maxScale

Property
maxScale Number

The maximum scale (most zoomed in) at which the layer is visible in the view. If the map is zoomed in beyond this scale, the layer will not be visible. A value of 0 means the layer does not have a maximum scale. The maxScale value should always be smaller than the minScale value, and greater than or equal to the service specification.

Default Value:0

minScale

Property
minScale Number

The minimum scale (most zoomed out) at which the layer is visible in the view. If the map is zoomed out beyond this scale, the layer will not be visible. A value of 0 means the layer does not have a minimum scale. The minScale value should always be larger than the maxScale value, and lesser than or equal to the service specification.

Default Value:0

objectIdField

Property
objectIdField Stringreadonly

The name of an oid field containing a unique value or identifier for each feature in the layer. This property is required when constructing a FeatureLayer from a collection of client-side features. If not specified, it will be inferred from the fields array.

opacity

Property
opacity Number

The opacity of the layer. This value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.

Default Value:1
Example
// Makes the layer 50% transparent
layer.opacity = 0.5;

parent

Property
parent SubtypeGroupLayer

The SubtypeGroupLayer to which the sublayer belongs.

popupEnabled

Property
popupEnabled Boolean

Indicates whether to display popups when features in the layer are clicked. The layer needs to have a popupTemplate to define what information should be displayed in the popup. Alternatively, a default popup template may be automatically used if Popup.defaultPopupTemplateEnabled is set to true.

Default Value:true
See also

popupTemplate

Property
popupTemplate PopupTemplateautocast

The popup template for the layer. When set on the layer, the popupTemplate allows users to access attributes and display their values in the view's popup when a feature is selected using text and/or charts. See the PopupTemplate sample for an example of how PopupTemplate interacts with a FeatureLayer.

A default popup template is automatically used if no popupTemplate has been defined when Popup.defaultPopupTemplateEnabled is set to true.

renderer

Property
renderer Rendererautocast

The renderer assigned to the layer. The renderer defines how to visualize each feature in the layer. Depending on the renderer type, features may be visualized with the same symbol, or with varying symbols based on the values of provided attribute fields or functions.

However, when creating a FeatureLayer from client-side features, this property must be specified in the layer's constructor along with the source, fields, objectIdField properties.

Example
// all features in the layer will be visualized with
// a 6pt black marker symbol and a thin, white outline
layer.renderer = {
  type: "simple",  // autocasts as new SimpleRenderer()
  symbol: {
    type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
    size: 6,
    color: "black",
    outline: {  // autocasts as new SimpleLineSymbol()
      width: 0.5,
      color: "white"
    }
  }
};

spatialReference

Property
spatialReference SpatialReference

The spatial reference of the layer. When creating the layer from a url, the spatial reference is read from the service.

When creating a FeatureLayer from client-side features, this property is inferred from the geometries of the features provided in the source property.

subtypeCode

Property
subtypeCode Number

The unique identifier representing the SubtypeSublayer created from the SubtypeGroupLayer.

Default Value:null

subtypeField

Property
subtypeField Stringreadonly

The name of the field which holds the id of the subtypes.

templates

Property
templates FeatureTemplate[]

An array of feature templates defined in the feature layer. See ArcGIS Pro subtypes document.

title

Property
title String

The title of the layer used to identify it in places such as the Legend widget. The title is set to the subtype description of layer.

type

Property
type Stringreadonly

For SubtypeSublayer the type is always "subtype-sublayer".

url

Property
url String

The absolute URL of the REST endpoint of the feature service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online. The service url points to the service url of the SubtypeGroupLayer. All SubtypeSublayers that belong to the same SubtypeGroupLayer will share the same value for the url.

visible

Property
visible Boolean

Indicates if the layer is visible in the View. When false, the layer may still be added to a Map instance that is referenced in a view, but its features will not be visible in the view.

Default Value:true
Example
// The layer is no longer visible in the view
layer.visible = false;

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds an attachment to a feature.

SubtypeSublayer

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor

Cancels a load() operation if it is already in progress.

SubtypeSublayer

Creates a popup template for the layer, populated with all the fields of the layer.

SubtypeSublayer

Creates query parameters that can be used to fetch features that satisfy the layer's current filters, and definitions.

SubtypeSublayer

Deletes attachments from a feature.

SubtypeSublayer

Returns the Field instance for a field name (case-insensitive).

SubtypeSublayer

Returns the Domain associated with the given field name.

SubtypeSublayer

Returns true if a named group of handles exist.

Accessor

isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected).

SubtypeSublayer

isRejected() may be used to verify if creating an instance of the class is rejected.

SubtypeSublayer

isResolved() may be used to verify if creating an instance of the class is resolved.

SubtypeSublayer

Loads the resources referenced by this class.

SubtypeSublayer

Query information about attachments associated with features.

SubtypeSublayer

Executes a Query against the feature service and returns a FeatureSet, which can be accessed using the .then() method once the promise resolves.

SubtypeSublayer

Removes a group of handles owned by the object.

Accessor

Updates an existing attachment for a feature.

SubtypeSublayer

when() may be leveraged once an instance of the class is created.

SubtypeSublayer

Method Details

addAttachment

Method
addAttachment(feature, attachment){Promise<FeatureEditResult>}

Adds an attachment to a feature. This operation is available only if the layer's capabilities.data.supportsAttachment is true.

Parameters
feature Graphic

Feature to associate with the added attachment.

HTML form that contains a file upload field specifying the file to be added as an attachment.

Returns
Type Description
Promise<FeatureEditResult> When resolved, a FeatureEditResult object is returned.
Example
view.when(function () {
  view.on("click", function (event) {

    view.hitTest(event).then(function (response) {
      const feature = response.results[0].graphic;

      // The form is defined as below in the html.
      // For enterprise services:
      // 1. File input name must be "attachment"
      // <form id="attachmentForm">
      //   Select a file: <input type="file" name="attachment">
      // </form>
      const attachmentForm = document.getElementById("attachmentForm");
      const formData = new FormData(attachmentForm);

      // For enterprise services - add input with name:f and value:json
      formData.append("f","json");
      const form = new FormData();
      form.set("attachment", file);
      form.append("f","json")
      let form = document.getElementById("myForm");

      // Add an attachment to the clicked feature.
      // The attachment is taken from the form.
      layer.addAttachment(feature, form).then(function (result) {
        console.log("attachment added: ", result);
      })
      .catch(function (err) {
        console.log("attachment adding failed: ", err);
      });
    });
  });
});

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

cancelLoad

Method
cancelLoad()

Cancels a load() operation if it is already in progress.

createPopupTemplate

Method
createPopupTemplate(options){PopupTemplate}

Creates a popup template for the layer, populated with all the fields of the layer.

Starting with version 4.28, date fields are formatted using the short-date-short-time preset dateFormat rather than long-month-day-year in popup templates created with the createPopupTemplate() method. For example, previously a date that may have appeared as "December 30, 1997" will now appear as "12/30/1997 6:00 PM".

Parameter
optional

Options for creating the popup template.

Returns
Type Description
PopupTemplate The popup template, or null if the layer does not have any fields.

createQuery

Method
createQuery(){Query}

Creates query parameters that can be used to fetch features that satisfy the layer's current filters, and definitions.

Returns
Type Description
Query The query object representing the layer's definition expression and other configurations.
Examples
// this snippet shows the query parameter object that is returned
// from SubtypeSublayer.createQuery().
const queryParams = new Query();
queryParams.outFields = ["*"];
queryParams.where = "1=1";
// Get a query object for the layer's current configuration
// queryParams.outFields will be set to ["*"] to get values
// for all available fields.
const queryParams = layer.createQuery();
// set a geometry for filtering features by a region of interest
queryParams.geometry = extentForRegionOfInterest;
// Add to the layer's current definitionExpression
queryParams.where = queryParams.where + " AND TYPE = 'Extreme'";

// query the layer with the modified params object
layer.queryFeatures(queryParams).then(function(results){
  // prints the array of result graphics to the console
  console.log(results.features);
});

deleteAttachments

Method
deleteAttachments(feature, attachmentIds){Promise<FeatureEditResult>}
Since: ArcGIS Maps SDK for JavaScript 4.26 SubtypeSublayer since 4.20, deleteAttachments added at 4.26.

Deletes attachments from a feature. This operation is available only if the layer's capabilities.data.supportsAttachment is set to true.

Parameters
feature Graphic

Feature containing attachments to be deleted.

attachmentIds Number[]

Ids of the attachments to be deleted.

Returns
Type Description
Promise<FeatureEditResult> When resolved, a FeatureEditResult object is returned. FeatureEditResult indicates whether or not the edit was successful. If successful, the objectId of the result is the Id of the new attachment. If unsuccessful, it also includes an error name and error message.

getField

Method
getField(fieldName){Field}

Returns the Field instance for a field name (case-insensitive).

Parameter
fieldName String

Name of the field.

Returns
Type Description
Field the matching field or undefined
See also

getFieldDomain

Method
getFieldDomain(fieldName){Domain}

Returns the Domain associated with the given field name. The domain can be either a CodedValueDomain or RangeDomain.

Parameter
fieldName String

Name of the field.

Returns
Type Description
Domain The Domain object associated with the given field name for the given feature.
Example
// Get a range domain associated with the first feature
// returned from queryFeatures().
subtypeSublayer.queryFeatures(query).then(function(results){
  const domain = subtypeSublayer.getFieldDomain("Height");
  console.log("domain", domain)
});

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

isFulfilled

Method
isFulfilled(){Boolean}

isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected). If it is fulfilled, true will be returned.

Returns
Type Description
Boolean Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).

isRejected

Method
isRejected(){Boolean}

isRejected() may be used to verify if creating an instance of the class is rejected. If it is rejected, true will be returned.

Returns
Type Description
Boolean Indicates whether creating an instance of the class has been rejected.

isResolved

Method
isResolved(){Boolean}

isResolved() may be used to verify if creating an instance of the class is resolved. If it is resolved, true will be returned.

Returns
Type Description
Boolean Indicates whether creating an instance of the class has been resolved.

load

Method
load(signal){Promise}

Loads the resources referenced by this class. This method automatically executes for a View and all of the resources it references in Map if the view is constructed with a map instance.

This method must be called by the developer when accessing a resource that will not be loaded in a View.

The load() method only triggers the loading of the resource the first time it is called. The subsequent calls return the same promise.

It's possible to provide a signal to stop being interested into a Loadable instance load status. When the signal is aborted, the instance does not stop its loading process, only cancelLoad can abort it.

Parameter
signal AbortSignal
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns
Type Description
Promise Resolves when the resources have loaded.

queryAttachments

Method
queryAttachments(attachmentQuery, options){Promise<object>}
Since: ArcGIS Maps SDK for JavaScript 4.26 SubtypeSublayer since 4.20, queryAttachments added at 4.26.

Query information about attachments associated with features. It will return an error if the layer's capabilities.data.supportsAttachment property is false. Attachments for multiple features can be queried if the layer's capabilities.operations.supportsQueryAttachments is true.

Known Limitations

When the layer's capabilities.operations.supportsQueryAttachments property is false, AttachmentQuery.objectIds property only accepts a single objectId.

Parameters
attachmentQuery AttachmentQuery autocast
Autocasts from Object

Specifies the attachment parameters for query.

options Object
optional

An object with the following properties.

Specification
signal AbortSignal
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns
Type Description
Promise<object> When resolved, returns an object containing AttachmentInfos grouped by the source feature objectIds.
Example
subtypeGroupLayer.when(function () {
  // queryObjectIds for all features within the layer
  subtypeGroupLayer.queryObjectIds().then(function (objectIds) {
    // Define parameters for querying attachments,
    // query features where objectIds are less than 735,
    // and only query jpeg attachments for these features.
    let attachmentQuery = {
      objectIds: objectIds,
      definitionExpression: "OBJECTID < 735",
      attachmentTypes: ["image/jpeg"]
    };

    // Only pass in one objectId for attachmentQuery.objectIds
    // if the layer's capabilities.operations.supportsQueryAttachments is false
    subtypeGroupLayer.queryAttachments(attachmentQuery).then(function (attachments) {
      // Print out all returned attachment infos to the console.
      attachmentQuery.objectIds.forEach(function (objectId) {
        if (attachments[objectId]) {
          let attachment = attachments[objectId];
          console.group("attachment for", objectId);
          attachment.forEach(function (item) {
            console.log("attachment id", item.id);
            console.log("content type", item.contentType);
            console.log("name", item.name);
            console.log("size", item.size);
            console.log("url", item.url);
            console.groupEnd();
          });
        }
      });
    })
    .catch(function (error) {
      console.log("attachment query error", error);
    })
  });
});

queryFeatures

Method
queryFeatures(query, options){Promise<FeatureSet>}

Executes a Query against the feature service and returns a FeatureSet, which can be accessed using the .then() method once the promise resolves. A FeatureSet contains an array of Graphic features.

When querying a service with z-values and no vertical coordinate system information, the z-values will automatically be converted to match the outSpatialReference units. Example: The service has a horizontal spatial reference using feet units and the query is made with outSpatialReference based on meter units, then queryFeatures() automatically converts the values from feet to meter units.

Parameters
query Query autocast
optional
Autocasts from Object

Specifies the attributes and spatial filter of the query. If no parameters are specified, then all features satisfying the layer's configuration/filters are returned.

options Object
optional

An object with the following properties.

Specification
signal AbortSignal
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns
Type Description
Promise<FeatureSet> When resolved, a FeatureSet containing an array of graphic features is returned.
Example
const subtypeGroupLayer = new SubtypeGroupLayer({
  url: fsUrl  // points to a Feature Service layer url
});

// obtain a sublayer by a subtype code
const sublayer = subtypeGroupLayer.findSublayerForSubtypeCode(2);

// query all features from the layer and only return
// attributes specified in outFields.
const query = { // autocasts as Query
  where: "1=1", // select all features
  returnGeometry: false,
  outFields: ["State_Name", "City_Name", "pop2010"]
};

layer.queryFeatures(query).then(function(results){
  console.log(results.features);  // prints the array of features to the console
});

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

updateAttachment

Method
updateAttachment(feature, attachmentId, attachment){Promise<FeatureEditResult>}
Since: ArcGIS Maps SDK for JavaScript 4.26 SubtypeSublayer since 4.20, updateAttachment added at 4.26.

Updates an existing attachment for a feature. This operation is available only if the layer's capabilities.data.supportsAttachment is set to true.

Parameters
feature Graphic

The feature containing the attachment to be updated.

attachmentId Number

Id of the attachment to be updated.

HTML form that contains a file upload field pointing to the file to be added as an attachment.

Returns
Type Description
Promise<FeatureEditResult> When resolved, a FeatureEditResult object is returned. FeatureEditResult indicates whether or not the edit was successful. If successful, the objectId of the result is the Id of the new attachment. If unsuccessful, it also includes an error name and error message.

when

Method
when(callback, errback){Promise}

when() may be leveraged once an instance of the class is created. This method takes two input parameters: a callback function and an errback function. The callback executes when the instance of the class loads. The errback executes if the instance of the class fails to load.

Parameters
callback Function
optional

The function to call when the promise resolves.

errback Function
optional

The function to execute when the promise fails.

Returns
Type Description
Promise Returns a new promise for the result of callback that may be used to chain additional functions.
Example
// Although this example uses MapView, any class instance that is a promise may use when() in the same way
let view = new MapView();
view.when(function(){
  // This function will execute once the promise is resolved
}, function(error){
  // This function will execute if the promise is rejected due to an error
});

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