import SubtypeSublayer from "@arcgis/core/layers/support/SubtypeSublayer.js";const SubtypeSublayer = await $arcgis.import("@arcgis/core/layers/support/SubtypeSublayer.js");- 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
- Example
- // Only includes one SubtypeSublayer from the SubtypeGroupLayerlet layer = new SuptypeGroupLayer({url: "https://sampleserver7.arcgisonline.com/server/rest/services/UtilityNetwork/NapervilleElectric/FeatureServer/0",sublayers: [{ // autocasts as a Collection of SubtypeSublayerssubtypeCode: 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
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| readonly | | |
| readonly inherited | ||
| | ||
| readonly | | |
| readonly | | |
| readonly | Field[] | |
| readonly | | |
| | ||
| readonly | SubtypeGroupLayer["geometryType"] | null | undefined | |
| readonly | | |
| | ||
| LabelClass[] | null | undefined | | |
| | ||
| | ||
| "show" | "hide" | | |
| readonly inherited | ||
| readonly inherited | "not-loaded" | "loading" | "failed" | "loaded" | |
| readonly inherited | any[] | |
| | ||
| | ||
| readonly | | |
| | ||
| | ||
| | ||
| | ||
| readonly | Relationship[] | null | undefined | |
| | ||
| readonly | | |
| | ||
| readonly | | |
| FeatureTemplate[] | null | undefined | | |
| | ||
| readonly | "subtype-sublayer" | |
| readonly inherited | ||
| readonly | | |
| |
attributeTableTemplate
- Type
- AttributeTableTemplate | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.31
This property is used to configure the associated layer's FeatureTable. It is meant to configure how the columns display within the table in regard to visibility, column order, and sorting.
This property differs from the table's FeatureTable's tableTemplate property. The TableTemplate provides more fine-grained control over how the table is rendered within the application by offering more advanced configurations such as custom cell rendering, column formatting, and more. TableTemplate is useful for application-level development that remains within an application. Use the attributeTableTemplate property to access the table's settings across different applications. By using this property, the settings can be saved within a webmap or layer. Please refer to the AttributeTableTemplate and TableTemplate documentation for more information.
capabilities
- Type
- FeatureLayerCapabilities | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Describes the layer's supported capabilities.
editingEnabled
- Type
- boolean
Determines if the layer is editable.
- See also
- Default value
- true
effectiveCapabilities
- Type
- FeatureLayerCapabilities | null | undefined
Describes effective capabilities of the layer taking in to consideration privileges of the currently signed-in user.
effectiveEditingEnabled
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 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
- Type
- Field[]
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 schemaconst 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 propertyconst layer = new SubtypeSublayer({// Object ID field is inferred from the fields arrayfields: fields});
fieldsIndex
- Type
- FieldsIndex<Field>
A convenient property that can be used to make case-insensitive lookups for a field by name. It can also provide a list of the date fields in a layer.
- Example
- // lookup a field by name. name is case-insensitiveconst field = layer.fieldsIndex.get("someField");if (field) {console.log(field.name); // SomeField}
formTemplate
- Type
- FormTemplate | null | undefined
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 templateconst 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 templateconst 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 layersubtypeSublayer.formTemplate = formTemplate;// Pass the layer to the FeatureFormconst form = new FeatureForm({container: "form", // html div referencing the formlayer: subtypeSublayer});
geometryType
- Type
- SubtypeGroupLayer["geometryType"] | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.27
The geometry type of features in the layer. All features must be of the same type.
labelingInfo
- Type
- LabelClass[] | null | undefined
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
- Type
- 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
- Type
- boolean
Indicates whether the layer will be included in the legend.
- Default value
- true
listMode
- Type
- "show" | "hide"
Indicates how the layer should display in the LayerList widget. The possible values are listed below.
| Value | Description |
|---|---|
| show | The layer is visible in the table of contents. |
| hide | The layer is hidden in the table of contents. |
- Default value
- "show"
loadError
The Error object returned if an error occurred while loading.
loadStatus
- Type
- "not-loaded" | "loading" | "failed" | "loaded"
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. |
- Default value
- "not-loaded"
loadWarnings
- Type
- any[]
A list of warnings which occurred while loading.
maxScale
- Type
- 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
- Type
- 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
opacity
- Type
- 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% transparentlayer.opacity = 0.5;
parent
- Type
- SubtypeGroupLayer | null | undefined
The SubtypeGroupLayer to which the sublayer belongs.
popupEnabled
- Type
- 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
popupTemplate
- Type
- PopupTemplate | null | undefined
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.
A default popup template is automatically used if no popupTemplate has been defined when
Popup.defaultPopupTemplateEnabled
is set to true.
relationships
- Type
- Relationship[] | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.31
Array of relationships set up for the layer. Each object in the array describes the layer's Relationship with another layer or table.
- See also
- Example
- // print out layer's relationship length and each relationship info to consolelayer.when(function () {console.log("layer relationships", layer.relationships.length);layer.relationships.forEach(function (relationship) {console.log("relationship id:", relationship.id)console.log("relationship cardinality:", relationship.cardinality)console.log("relationship key field:", relationship.keyField)console.log("relationship name:", relationship.name)console.log("relationship relatedTableId:", relationship.relatedTableId)});});
renderer
- Type
- SimpleRenderer | ClassBreaksRenderer | UniqueValueRenderer | null | undefined
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.
- Example
- // all features in the layer will be visualized with// a 6pt black marker symbol and a thin, white outlinelayer.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
- Type
- SpatialReference
The spatial reference of the layer. When creating the layer from a url, the spatial reference is read from the service.
subtypeCode
- Type
- number
The unique identifier representing the SubtypeSublayer created from the SubtypeGroupLayer.
templates
- Type
- FeatureTemplate[] | null | undefined
An array of feature templates defined in the feature layer. See ArcGIS Pro subtypes document.
uid
- Type
- string
- Since
- ArcGIS Maps SDK for JavaScript 4.33
An automatically generated unique identifier assigned to the instance. The unique id is generated each time the application is loaded.
url
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
- Type
- 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 viewlayer.visible = false;
Methods
| Method | Signature | Class |
|---|---|---|
| addAttachment(feature: Graphic, attachment: HTMLFormElement | FormData): Promise<FeatureEditResult> | | |
| applyEdits(edits: Edits, options?: EditOptions): Promise<EditsResult> | | |
| inherited | cancelLoad(): this | |
| inherited | clone(): this | |
| createPopupTemplate(options?: CreatePopupTemplateOptions): PopupTemplate | null | undefined | | |
| createQuery(): Query | | |
| deleteAttachments(feature: Graphic, attachmentIds: number[]): Promise<FeatureEditResult[]> | | |
| getFeatureTitle(graphic: Graphic, options?: FeatureTitleOptions): Promise<string> | | |
| getField(fieldName: string): Field | null | undefined | | |
| getFieldDomain(fieldName: string): DomainUnion | null | undefined | | |
| inherited | isFulfilled(): boolean | |
| inherited | isRejected(): boolean | |
| inherited | isResolved(): boolean | |
| inherited | load(options?: AbortOptions | null | undefined): Promise<this> | |
| queryAttachments(attachmentQuery: AttachmentQuery | AttachmentQueryProperties, options?: RequestOptions): Promise<Record<string, AttachmentInfo[]>> | | |
| queryFeatureCount(query?: QueryProperties | null | undefined, options?: RequestOptions): Promise<number> | | |
| queryFeatures(query?: QueryProperties | null | undefined, options?: RequestOptions): Promise<FeatureSet> | | |
| queryObjectIds(query?: QueryProperties | null | undefined, options?: RequestOptions): Promise<number[]> | | |
| queryRelatedFeatures(relationshipQuery: RelationshipQueryProperties, options?: RequestOptions): Promise<Record<string, FeatureSet>> | | |
| queryRelatedFeaturesCount(relationshipQuery: RelationshipQueryProperties, options?: RequestOptions): Promise<Record<string, number>> | | |
| updateAttachment(feature: Graphic, attachmentId: number, attachment: HTMLFormElement | FormData): Promise<FeatureEditResult> | | |
| inherited | when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2> |
addAttachment
- Signature
-
addAttachment (feature: Graphic, attachment: HTMLFormElement | FormData): Promise<FeatureEditResult>
Adds an attachment to a feature. This operation is available only if the layer's capabilities.data.supportsAttachment is true.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| feature | Feature to associate with the added attachment. | | |
| attachment | HTML form that contains a file upload field specifying the file to be added as an attachment. | |
- Returns
- 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:jsonformData.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);});});});});
applyEdits
- Signature
-
applyEdits (edits: Edits, options?: EditOptions): Promise<EditsResult>
Applies edits to features in a layer. New features can be created and existing features can be updated or deleted. Feature geometries and/or attributes may be modified. Attachments can also be added, updated or deleted.
When calling the applyEdits method on a service that does not have vertical coordinate system information,
the z-values of the geometries in the edits object will automatically be converted to match the spatial reference of the layer.
Example: The service has a horizontal spatial reference with feet units, and applyEdits() is called with z-values based on meter units,
then the method will automatically convert the z values from meter to feet units.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| edits | Object containing features and attachments to be added, updated or deleted. | | |
| options | Additional edit options to specify when editing features or attachments. | |
- Returns
- Promise<EditsResult>
When resolved, an EditsResult object is returned.
- Example
- function addFeature(geometry) {const attributes = {};attributes["Description"] = "This is the description";attributes["Address"] = "380 New York St";// Date.now() returns number of milliseconds elapsed// since 1 January 1970 00:00:00 UTC.attributes["Report_Date"] = Date.now();const addFeature = new Graphic({geometry: geometry,attributes: attributes});const deleteFeatures = [{ objectId: 467 },{ objectId: 500 }];// or specify globalIds of features to be deleted// const deleteFeature = [// { globalId: "18633204-1801-4d35-a73a-174563608ad9" }// ];const promise = subtypeSublayer.applyEdits({addFeatures: [addFeature],deleteFeatures: deleteFeatures});}
cancelLoad
- Signature
-
cancelLoad (): this
Cancels a load() operation if it is already in progress.
- Returns
- this
clone
- Signature
-
clone (): this
Creates a deep clone of this object. Any properties that store values by reference will be assigned copies of the referenced values on the cloned instance.
- Returns
- this
A deep clone of the class instance that invoked this method.
createPopupTemplate
- Signature
-
createPopupTemplate (options?: CreatePopupTemplateOptions): PopupTemplate | null | undefined
Creates a popup template for the layer, populated with all the fields of the layer.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | Options for creating the popup template. | |
- Returns
- PopupTemplate | null | undefined
The popup template, or
nullif the layer does not have any fields.
createQuery
- Signature
-
createQuery (): Query
Creates query parameters that can be used to fetch features that satisfy the layer's current filters, and definitions.
- Returns
- 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 interestqueryParams.geometry = extentForRegionOfInterest;// Add to the layer's current definitionExpressionqueryParams.where = queryParams.where + " AND TYPE = 'Extreme'";// query the layer with the modified params objectlayer.queryFeatures(queryParams).then(function(results){// prints the array of result graphics to the consoleconsole.log(results.features);});
deleteAttachments
- Signature
-
deleteAttachments (feature: Graphic, attachmentIds: number[]): Promise<FeatureEditResult[]>
- Since
- ArcGIS Maps SDK for JavaScript 4.26
Deletes attachments from a feature. This operation is available only if the layer's
capabilities.data.supportsAttachment is set to true.
Parameters
- Returns
- Promise<FeatureEditResult[]>
When resolved, a FeatureEditResult object is returned. FeatureEditResult indicates whether or not the edit was successful. If successful, the
objectIdof the result is the Id of the new attachment. If unsuccessful, it also includes an errornameand errormessage.
getFeatureTitle
- Signature
-
getFeatureTitle (graphic: Graphic, options?: FeatureTitleOptions): Promise<string>
- Since
- ArcGIS Maps SDK for JavaScript 4.34
Returns the title of a feature. The feature title is generated based on the following conditions for a SubtypeSublayer.
- If the feature has a popup title configured, then the popup title will be returned.
- Otherwise, the objectId of the associated feature will be returned.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| graphic | The graphic for which to generate a title. | | |
| options | Additional options that control how the title is generated. | |
getFieldDomain
- Signature
-
getFieldDomain (fieldName: string): DomainUnion | null | undefined
Returns the Domain associated with the given field name. The domain can be either a CodedValueDomain or RangeDomain.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| fieldName | Name of the field. | |
- Returns
- DomainUnion | null | undefined
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)});
isFulfilled
- Signature
-
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
- boolean
Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
isRejected
- Signature
-
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
- boolean
Indicates whether creating an instance of the class has been rejected.
isResolved
- Signature
-
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
- boolean
Indicates whether creating an instance of the class has been resolved.
load
- Signature
-
load (options?: AbortOptions | null | undefined): Promise<this>
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.
queryAttachments
- Signature
-
queryAttachments (attachmentQuery: AttachmentQuery | AttachmentQueryProperties, options?: RequestOptions): Promise<Record<string, AttachmentInfo[]>>
- Since
- ArcGIS Maps SDK for JavaScript 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
| Parameter | Type | Description | Required |
|---|---|---|---|
| attachmentQuery | Specifies the attachment parameters for query. | | |
| options | An object with the following properties. | |
- Returns
- Promise<Record<string, AttachmentInfo[]>>
When resolved, returns an object containing AttachmentInfos grouped by the source feature objectIds.
- Example
- subtypeGroupLayer.when(function () {// queryObjectIds for all features within the layersubtypeGroupLayer.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 falsesubtypeGroupLayer.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);})});});
queryFeatureCount
- Signature
-
queryFeatureCount (query?: QueryProperties | null | undefined, options?: RequestOptions): Promise<number>
Executes a Query against the service and returns the number of features that satisfy the query. If no parameters are specified, then the total number of features satisfying the layer's configuration/filters is returned.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| query | Specifies the attributes and spatial filter of the query.
When no parameters are passed to this method, all features in the client are returned. To only return features
visible in the view, set the | | |
| options | An object with the following properties. | |
- Example
- // returns a count of all features in the layerawait count = layer.queryFeatureCount();console.log("Feature count: ", count);
queryFeatures
- Signature
-
queryFeatures (query?: QueryProperties | null | undefined, options?: RequestOptions): Promise<FeatureSet>
Executes a Query against the feature service and returns a FeatureSet 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 Query.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.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| query | 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 | An object with the following properties. | |
- Returns
- 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 codeconst sublayer = subtypeGroupLayer.findSublayerForSubtypeCode(2);// query all features from the layer and only return// attributes specified in outFields.const query = { // autocasts as Querywhere: "1=1", // select all featuresreturnGeometry: 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});
queryObjectIds
- Signature
-
queryObjectIds (query?: QueryProperties | null | undefined, options?: RequestOptions): Promise<number[]>
Executes a Query against the service and returns an array of Object IDs for features that satisfy the input query. If no parameters are specified, then the Object IDs of all features satisfying the layer's configuration/filters are returned.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| query | Specifies the attributes and spatial filter of the query.
When no parameters are passed to this method, all features in the client are returned. To only return features
visible in the view, set the | | |
| options | An object with the following properties. | |
- Example
- // Queries for all the Object IDs of featuresawait result = subtypeSublayer.queryObjectIds();// prints the array of Object IDs to the consoleconsole.log(result);
queryRelatedFeatures
- Signature
-
queryRelatedFeatures (relationshipQuery: RelationshipQueryProperties, options?: RequestOptions): Promise<Record<string, FeatureSet>>
- Since
- ArcGIS Maps SDK for JavaScript 4.31
Executes a RelationshipQuery against the feature service and returns FeatureSets grouped by source layer or table objectIds.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| relationshipQuery | Specifies relationship parameters for querying related features or records from a layer or a table. | | |
| options | An object with the following properties. | |
- Returns
- Promise<Record<string, FeatureSet>>
When resolved, returns FeatureSets grouped by source layer/table objectIds. Each FeatureSet contains an array of Graphic features including the values of the fields requested by the user.
- Example
- const objectIds = [385, 416];// relationship query parameterconst query = {outFields: ["*"],relationshipId: relationshipId,objectIds: objectIds}// query related features for given objectIdssublayer.queryRelatedFeatures(query).then(function (result) {objectIds.forEach(function (objectId) {// print out the attributes of related features if the result// is returned for the specified objectIdif (result[objectId]) {console.group("relationship for feature:", objectId)result[objectId].features.forEach(function (feature) {console.log("attributes", JSON.stringify(feature.attributes));});console.groupEnd();}});}).catch(function (error) {console.log("error from queryRelatedFeatures", error);});
queryRelatedFeaturesCount
- Signature
-
queryRelatedFeaturesCount (relationshipQuery: RelationshipQueryProperties, options?: RequestOptions): Promise<Record<string, number>>
- Since
- ArcGIS Maps SDK for JavaScript 4.31
Executes a RelationshipQuery against the feature service and
when resolved, it returns an object containing key value pairs. Key in this case is the objectId
of the feature and value is the number of related features associated with the feature.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| relationshipQuery | Specifies relationship parameters for querying related features or records from a layer or a table. | | |
| options | An object with the following properties. | |
- Example
- const objectIds = [385, 416];// relationship query parameterconst query = {outFields: ["*"],relationshipId: relationshipId,objectIds: objectIds}// query related features for given objectIdssublayer.queryRelatedFeaturesCount(query).then(function (count) {console.log("queryRelatedFeaturesCount", count);// this will print out// {385: 91, 416: 23}}).catch(function (error) {console.log("error from queryRelatedFeatures", error);});
updateAttachment
- Signature
-
updateAttachment (feature: Graphic, attachmentId: number, attachment: HTMLFormElement | FormData): Promise<FeatureEditResult>
- Since
- ArcGIS Maps SDK for JavaScript 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
| Parameter | Type | Description | Required |
|---|---|---|---|
| feature | The feature containing the attachment to be updated. | | |
| attachmentId | Id of the attachment to be updated. | | |
| attachment | HTML form that contains a file upload field pointing to the file to be added as an attachment. | |
- Returns
- Promise<FeatureEditResult>
When resolved, a FeatureEditResult object is returned. FeatureEditResult indicates whether or not the edit was successful. If successful, the
objectIdof the result is the Id of the new attachment. If unsuccessful, it also includes an errornameand errormessage.
when
- Signature
-
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
when() may be leveraged once an instance of the class is created. This method takes two input parameters: an onFulfilled function and an onRejected function.
The onFulfilled executes when the instance of the class loads. The
onRejected executes if the instance of the class fails to load.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| onFulfilled | OnFulfilledCallback<this, TResult1> | null | undefined | The function to call when the promise resolves. | |
| onRejected | The function to execute when the promise fails. | |
- Returns
- Promise<TResult1 | TResult2>
Returns a new promise for the result of
onFulfilledthat 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 waylet 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});