import Sublayer from "@arcgis/core/layers/support/Sublayer.js";const Sublayer = await $arcgis.import("@arcgis/core/layers/support/Sublayer.js");- Inheritance:
- Sublayer→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.1
Represents a sublayer in a MapImageLayer or a TileLayer. MapImageLayer allows you to display, query, and analyze layers from data defined in a map service. Map services contain sublayers with properties such as renderer, labelingInfo, and definitionExpression, and others that are defined on the server. The properties of each MapImageLayer sublayer on the map service may be dynamically changed by the user or developer. The properties of each TileLayer sublayer are read-only, and cannot be modified.
Known Limitations
All properties of a TileLayer's sublayers are read-only, except the following:
The following limitations apply to sublayers from all map services published with ArcMap, or published to ArcGIS Server 10.5.1 or earlier: Arcade expressions are not supported in the renderer and popupTemplate. Visual variables are not supported in the renderer.
Dynamic layers
Sublayers may be rendered on the fly as dynamic layers. Dynamic layers are created using the source property of the sublayer. There are two types of dynamic layers: dynamic map layers and dynamic data layers.
Dynamic map layers allow you to override sublayers in the map service with new renderers, definition expressions, opacity, scale visibility, etc. Multiple dynamic map layers may exist for a single map service layer.
Dynamic data layers provide the ability to create sublayers on the fly from data inside registered workspaces. The data may be tables with or without geometries, feature classes, or rasters. These data sources are not directly visible to the services directory, but may be published and configured with the ArcGIS Server Manager. Data from tables may be joined to other tables or dynamic map layers.
- See also
Example
// defines the properties of various sublayers in a map servicelet layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [ { // sets a definition expression on sublayer 3 id: 3, definitionExpression: "pop2000 > 40000000" }, { // sublayer 2 will be rendered as defined in the map service id: 2 }, { // sublayer 1 will be included in the layer, with visibility off id: 1, visible: false }, { // sublayer 0 will have new renderer and label // expressions applied in the view on the fly id: 0, renderer: { type: "class-breaks" // autocasts as new ClassBreaksRenderer() // set renderer properties here }, labelingInfo: [ new LabelClass ( ... ) ] } ]});Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Example
// typical usagelet layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [ // autocasts as a Collection of Sublayers { // sets a definition expression on sublayer 0 id: 0, definitionExpression: "pop2000 > 40000000" }, { // creates a dynamic data layer source: { type: dynamic-layer, dataSource: { type: "table", workspaceId: "MyDatabaseWorkspaceIDSSR2", dataSourceName: "ss6.gdb.Railroads" } } } ]});Properties
| Property | Type | Class |
|---|---|---|
| | ||
capabilities readonly | | |
declaredClass readonly inherited | ||
| | ||
editFieldsInfo readonly | | |
fields readonly | Field[] | |
fieldsIndex readonly | | |
| | ||
fullExtent readonly | | |
| | ||
isTable readonly | | |
LabelClass[] | null | undefined | | |
| | ||
MapImageLayer | TileLayer | null | undefined | | |
| | ||
"hide" | "show" | "hide-children" | | |
loadError readonly inherited | ||
loadStatus readonly inherited | "not-loaded" | "loading" | "failed" | "loaded" | |
loadWarnings readonly inherited | any[] | |
| | ||
| | ||
objectIdField readonly | | |
| | ||
OrderByInfo[] | null | undefined | | |
Sublayer | MapImageLayer | TileLayer | null | undefined | | |
| | ||
| | ||
relationships readonly | Relationship[] | null | undefined | |
| | ||
| | ||
| | ||
spatialReference readonly | | |
| | ||
| | ||
type readonly | "sublayer" | |
typeIdField readonly | | |
types readonly | FeatureType[] | null | undefined | |
uid readonly inherited | ||
| | ||
| |
attributeTableTemplate
- Type
- AttributeTableTemplate | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.33
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 a 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
- SublayerCapabilities
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Describes the layer's supported capabilities.
Example
// Once the layer loads, check if `supportsAttachment`// operation is enabled on the layer
layer.when(function(){ if (layer.capabilities.data.supportsAttachment) { // if attachments are enabled on the layer setupAttachments(); }}); definitionExpression
A SQL where clause used to filter features in the image.
Only the features that satisfy the definition expression are displayed in the
View. Definition expressions
may be set when a sublayer is constructed prior to it loading in the view or after it has
been added to the MapImageLayer. To see if you can use this property, check the
supportsSublayerDefinitionExpression property of
MapImageLayer.capabilities.
Examples
let countiesLyr = layer.sublayers.find(function(sublayer){ return sublayer.title === "States";});countiesLyr.definitionExpression = "STATE = 'Nebraska'"// add a definition expression to sublayer when// it is created in MapImageLayer constructorlet layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [{ id: 0, definitionExpression: "STATE = 'Nebraska'" }]});// Set a definition expression on the sublayer with ID of 0layer.findSublayerById(0).definitionExpression = "STATE = 'Nebraska'"; editFieldsInfo
- Type
- EditFieldsInfo | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The editor tracking fields, which record who adds or edits the data through the feature service and when edits are made.
fields
- Type
- Field[]
- Since
- ArcGIS Maps SDK for JavaScript 4.15
An array of fields in the Sublayer. Each field represents an attribute that may contain a value for each feature in the Sublayer. This property is only available after the Sublayer has been loaded.
- See also
Example
// print the first Sublayer's first field to the consoleconsole.log(mapImageLayer.sublayers.items[0].fields[0]);
// OUTPUT:alias: "OBJECTID"defaultValue: undefineddescription: "the objectid"domain: nulleditable: falsename: "objectid"nullable: falsetype: "oid"valueType: null fieldsIndex
- Type
- FieldsIndex<Field>
- Since
- ArcGIS Maps SDK for JavaScript 4.15
A convenient property that can be used to make case-insensitive lookups for a fields by name. It can also provide a list of the date fields in a Sublayer. This property is only available after the Sublayer has been loaded.
Example
// lookup a field by name, name is case-insensitiveconst fieldsIndex = mapImageLayer.sublayers.items[0].fieldsIndex.get("OBjecTID");
// if there's a field by that name, print it to the consoleif (fieldsIndex) { console.log("fieldsIndex: ", fieldsIndex);} floorInfo
- Type
- LayerFloorInfo | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.21
If a map image layer contains a sublayer which is meant to be floor-aware, then that sublayer must have a floorInfo property, containing a LayerFloorInfo object which has a string property to represent the floorField.
id
- Type
- number
The sublayer's layer ID. When a source is not defined on the layer, this value represents the id of the sublayer defined by the map service. If creating a DynamicDataLayer or a DynamicMapLayer and adding it to the source property of the sublayer, the value of this property can be anything set by the developer.
Examples
// Creates a MapImageLayer instance containing only the sublayers defined below.let layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", // this service has four sublayers, but we're only going to include three. sublayers: [ { id: 2 }, { id: 1 }, { id: 0 } ]});// Creates a MapImageLayer instance containing only the sublayers defined below.let layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [{ // sets a new renderer on this sublayer id: 2, renderer: { type: "class-breaks" // autocasts as new ClassBreaksRenderer() // set renderer properties here } }, { // sets new labelingInfo on the sublayer id: 1, labelingInfo: [ new LabelClass( ... ) ] }, { // retains properties defined by the service, but makes sublayer not visible id: 0, visible: false }]}); isTable
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Returns true if the sublayer is a non-spatial table in a map service.
- Default value
- false
labelingInfo
- Type
- LabelClass[] | null | undefined
The label definition for this layer, specified as an array of LabelClass objects. Use this property to specify labeling properties for the layer such as label expression, placement, and size.
Example
let layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [{ id: 3, labelsVisible: true, // labelingInfo autocasts to an array of LabelClass objects labelingInfo: [{ labelExpression: "[name]", labelPlacement: "always-horizontal", symbol: { type: "text", // autocasts as new TextSymbol() color: [255, 255, 255, 0.7], haloColor: [0, 0, 0, 0.85], haloSize: 1, font: { size: 11 } }, minScale: 2400000, maxScale: 73000 }] }]}); labelsVisible
- Type
- boolean
Indicates if labels for the sublayer will be visible in the view.
- Default value
- true
Example
// turns on labels defined for sublayer 0layer.findSublayerById(0).labelsVisible = true; layer
- Type
- MapImageLayer | TileLayer | null | undefined
The MapImageLayer or TileLayer to which the sublayer belongs.
legendEnabled
- Type
- boolean
Indicates whether the layer will be included in the legend. When false, the layer will be excluded from the legend.
- Default value
- true
listMode
- Type
- "hide" | "show" | "hide-children"
- Since
- ArcGIS Maps SDK for JavaScript 4.11
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. |
| hide-children | Hide the children layers from 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.
Example
let layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [ { id: 0, minScale: 5000000, maxScale: 24000 }, { id: 1 minScale: 24000, maxScale: 100 } ]}); 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.
Example
let layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [ { id: 0, minScale: 5000000, maxScale: 24000 }, { id: 1, minScale: 24000, maxScale: 100 } ]}); opacity
- Type
- number
The level of opacity to set on the sublayer on a scale
from 0.0 - 1.0 where 0 is fully transparent and 1.0 is fully opaque.
If the MapImageLayer.opacity
is set, the actual opacity value of the sublayer will be the value of
MapImageLayer.opacity multiplied
by the sublayer's opacity.
Example
// Set the opacity of the layer to 0.5layer.findSublayerById(0).opacity = 0.5; orderBy
- Type
- OrderByInfo[] | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.32
Determines the order in which features are drawn in the view. You can sort features by a field value or the value returned from an Arcade expression in ascending or descending order.
When null (default), features are drawn in the order they are returned from
the service or client.
Known Limitations
- See also
Example
// Features with larger population values will// be rendered on top of smaller features.sublayer.orderBy = [ { field: "POP2024", order: "descending" }]; parent
- Type
- Sublayer | MapImageLayer | TileLayer | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.27
The parent layer to which the sublayer belongs.
popupEnabled
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.7
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 sublayer. When set, the popupTemplate
allows users to access attributes and display their values in the
view's Popup when the user clicks
the image.
Sublayers with a RasterDataSource cannot be queried and therefore do not support PopupTemplate.
Alternatively, a default popup template may be automatically used if
Popup.defaultPopupTemplateEnabled is set to true.
Known Limitations
Arcade expressions are not supported in PopupTemplates set on MapImageLayer sublayers or TileLayer sublayers unless they reference ArcGIS Enterprise 10.6 map services (or later) created from ArcGIS Pro.
Example
let layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [{ id: 0, popupTemplate: { title: "{COUNTY}", content: "{POP2007} people lived in this county in 2007" } }]}); relationships
- Type
- Relationship[] | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.30
An array of relationships associated with the sublayer. Each Relationship defines a relationship between this sublayer and another layer or table.
renderer
- Type
- RendererUnion | null | undefined
The renderer to apply to the sublayer.
This value overrides the renderer read from the map service.
To see if you can use this property, check the
supportsDynamicLayers property of
MapImageLayer.capabilities.
Known Limitations
3D symbols are not currently supported in renderers set on sublayers. Visual variables and Arcade expressions are not supported in renderers set on MapImageLayer sublayers unless they reference ArcGIS Enterprise 10.6 map services (or later) created from ArcGIS Pro.
Example
let layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [{ id: 0, renderer: { type: "simple", // autocasts as new SimpleRenderer() symbol: { type: "simple-marker", // autocasts as new SimpleMarkerSymbol() color: "black", size: 8 } } }]}); source
- Type
- DynamicMapLayer | DynamicDataLayer
An object that allows you to create a dynamic layer with data either from the map service sublayers or data from a registered workspace. See DynamicMapLayer for creating dynamic layers from map service layers for on the fly rendering, labeling, and filtering (definition expressions). To create dynamic layers from other sources in registered workspaces such as tables and table joins, see DynamicDataLayer.
Example
// Creates two sublayers that point to the same map service layer.// Each layer presents different features in the data using// definition expressions and renderers.let mapImageLayer = new MapImageLayer({ sublayers: [{ id: 10, definitionExpression: "POP < 100000", renderer: { type: "simple", // autocasts as new SimpleRenderer() symbol: smallMarker }, source: { type: "map-layer", mapLayerId: 0 } }, { id: 11, definitionExpression: "POP > 100001", renderer: { type: "simple", // autocasts as new SimpleRenderer() symbol: largeMarker }, source: { type: "map-layer", mapLayerId: 0 } }]}); sourceJSON
- Since
- ArcGIS Maps SDK for JavaScript 4.15
The map service's metadata JSON exposed by the ArcGIS REST API. While most commonly used properties are exposed on the Sublayer class directly, this property gives access to all information returned by the map service. This property is useful if working in an application built using an older version of the API which requires access to map service properties from a more recent version.
spatialReference
- Type
- SpatialReference | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.30
The spatial reference of the sublayer as defined by the service.
sublayers
- Type
- Collection<Sublayer>
If a sublayer contains sublayers, this property is a Collection of Sublayer objects belonging to the given sublayer with sublayers.
Example
// test function for determining if a MapImageLayer's sublayers// contain at least one dynamic data layerfunction hasDynamicDataLayer (layer){ if (layer.sublayers && layer.sublayers.sublayers){ return layer.sublayers.sublayers.some(function(sublayer){ return sublayer.source.type === "data-layer"; }); } else { console.log("layer does not have sublayers or nested sublayers"); return false; }} title
The title of the sublayer used to identify it in places such as the LayerList and Legend. This value can be defined in the map service or programmatically by the developer. It can also be useful for finding a specific sublayer.
Example
let radarSublayer = layer.sublayers.find(function(sublayer){ return sublayer.title === "radar";}); types
- Type
- FeatureType[] | null | undefined
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.
visible
- Type
- boolean
Indicates if the layer is visible in the view.
To see if you can use this property, check the
supportsSublayerVisibility property of
MapImageLayer.capabilities.
Example
let layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer", sublayers: [{ // this sublayer is visible by default id: 0 }, { // this sublayer will be added to the layer but not visible id: 1, visible: false }] // all other sublayers in the service are excluded from the layer});Methods
| Method | Signature | Class |
|---|---|---|
cancelLoad inherited | cancelLoad(): this | |
clone(): Sublayer | | |
createFeatureLayer(): Promise<FeatureLayer | null | undefined> | | |
createPopupTemplate(options?: CreatePopupTemplateOptions): PopupTemplate | null | undefined | | |
createQuery(): Query | | |
getFeatureType(feature: Graphic | null | undefined): FeatureType | null | undefined | | |
getFieldDomain(fieldName: string, options?: FieldDomainOptions): DomainUnion | null | undefined | | |
isFulfilled inherited | isFulfilled(): boolean | |
isRejected inherited | isRejected(): boolean | |
isResolved inherited | isResolved(): boolean | |
load inherited | load(options?: AbortOptions | null | undefined): Promise<this> | |
queryAttachments(attachmentQuery: AttachmentQueryProperties, options?: AbortOptions): Promise<Record<string, AttachmentInfo[]>> | | |
queryFeatureCount(query?: QueryProperties, options?: AbortOptions): Promise<number> | | |
queryFeatures(query?: QueryProperties, options?: AbortOptions): Promise<FeatureSet> | | |
queryObjectIds(query?: QueryProperties, options?: AbortOptions): Promise<ObjectId[]> | | |
queryRelatedFeatures(relationshipQuery: RelationshipQueryProperties, options?: AbortOptions): Promise<Record<string, FeatureSet>> | | |
queryRelatedFeaturesCount(relationshipQuery: RelationshipQueryProperties, options?: AbortOptions): Promise<Record<string, number>> | | |
reload(options?: AbortOptions | null | undefined): Promise<void> | | |
when inherited | when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2> |
cancelLoad
- Signature
-
cancelLoad (): this
Cancels a load() operation if it is already in progress.
- Returns
- this
clone
- Signature
-
clone (): Sublayer
Creates a deep clone of the sublayer.
- Returns
- Sublayer
A deep clone of the sublayer instance that invoked this method.
createFeatureLayer
- Signature
-
createFeatureLayer (): Promise<FeatureLayer | null | undefined>
- Since
- ArcGIS Maps SDK for JavaScript 4.7
A convenient method for creating a FeatureLayer instance based on the Sublayer's configuration, including dynamic sources. This allows you to take advantage of FeatureLayer capabilities not supported in Sublayer, such as the Smart Mapping creator functions.
- See also
- Returns
- Promise<FeatureLayer | null | undefined>
A promise resolving to a FeatureLayer matching the configuration of the Sublayer instance that called this method.
Example
let sublayer = mapImageLayer.findSublayerById(0);
// when the createFeatureLayer() promise resolves, load the FeatureLayer// and pass it to the createParameters functionsublayer.createFeatureLayer() .then(function(featureLayer){ return featureLayer.load(); }) .then(createParameters);
function createParameters (featureLayer) { let colorParams = { layer: featureLayer, basemap: map.basemap, field: "POPULATION", normalizationField: "SQ_MILES", legendOptions: { title: "Population density (sq. miles)" } };}
// when the promise resolves, apply the renderer to the sublayercolorRendererCreator.createContinuousRenderer(colorParams) .then(function(response){ sublayer.renderer = response.renderer; }); createPopupTemplate
- Signature
-
createPopupTemplate (options?: CreatePopupTemplateOptions): PopupTemplate | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.15
Creates a popup template for the sublayer, populated with all the fields of the sublayer.
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.
getFeatureType
- Signature
-
getFeatureType (feature: Graphic | null | undefined): FeatureType | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.15
Returns a FeatureType describing the feature's type. This is applicable if the layer containing the feature has a typeIdField.
Parameters
- Returns
- FeatureType | null | undefined
The FeatureType describing the feature's type.
getFieldDomain
- Signature
-
getFieldDomain (fieldName: string, options?: FieldDomainOptions): DomainUnion | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.15
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. | | |
| options | An object specifying additional options. See the object specification table below for the required properties of this object. | |
- 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().sublayer.queryFeatures(query).then(function(results){ const domain = sublayer.getFieldDomain("Height", {feature: results.features[0]}); 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: AttachmentQueryProperties, options?: AbortOptions): 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[]>>
queryFeatureCount
- Signature
-
queryFeatureCount (query?: QueryProperties, options?: AbortOptions): Promise<number>
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Executes a Query against the sublayer and returns the number of features that satisfy the query. If no parameters are specified, 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. If no parameters are specified, the total number of features satisfying the layer's configuration/filters is returned. | | |
| options | An object with the following properties. | |
queryFeatures
- Signature
-
queryFeatures (query?: QueryProperties, options?: AbortOptions): Promise<FeatureSet>
Executes a query against features in the sublayer.
To see if you can use this property, check the
supportsQuery property of
MapImageLayer.capabilities.
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>
Returns a promise that resolves to a FeatureSet containing the features that satisfy the query.
queryObjectIds
- Signature
-
queryObjectIds (query?: QueryProperties, options?: AbortOptions): Promise<ObjectId[]>
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Executes a Query against the sublayer 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. If no parameters are specified, then the Object IDs of all features satisfying the layer's configuration/filters are returned. | | |
| options | An object with the following properties. | |
queryRelatedFeatures
- Signature
-
queryRelatedFeatures (relationshipQuery: RelationshipQueryProperties, options?: AbortOptions): Promise<Record<string, FeatureSet>>
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Executes a RelationshipQuery against the sublayer 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.
queryRelatedFeaturesCount
- Signature
-
queryRelatedFeaturesCount (relationshipQuery: RelationshipQueryProperties, options?: AbortOptions): Promise<Record<string, number>>
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Executes a RelationshipQuery against the sublayer 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. | |
reload
- Signature
-
reload (options?: AbortOptions | null | undefined): Promise<void>
- Since
- ArcGIS Maps SDK for JavaScript 4.34
Reloads the properties for the sublayer. Use this function after modifying the sublayer's url after it was loaded.
Note: If replacing a MapImageLayer sublayer with a new url and then calling reload, the new layer must have the same schema as the the sublayer's map service.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | An object with the following properties. | |
when
- Signature
-
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
- Since
- ArcGIS Maps SDK for JavaScript 4.6
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});