import type Graphic from "../Graphic.js"; import type PopupTemplate from "../PopupTemplate.js"; import type Collection from "../core/Collection.js"; import type FormTemplate from "../form/FormTemplate.js"; import type Extent from "../geometry/Extent.js"; import type Layer from "./Layer.js"; import type FeatureTemplate from "./support/FeatureTemplate.js"; import type FeatureType from "./support/FeatureType.js"; import type Field from "./support/Field.js"; import type FieldConfiguration from "./support/FieldConfiguration.js"; import type LabelClass from "./support/LabelClass.js"; import type PortalItem from "../portal/PortalItem.js"; import type DynamicDataLayer from "../rest/layerSources/DynamicDataLayer.js"; import type AttachmentInfo from "../rest/query/support/AttachmentInfo.js"; import type AttributeBinsFeatureSet from "../rest/support/AttributeBinsFeatureSet.js"; import type FeatureSet from "../rest/support/FeatureSet.js"; import type Query from "../rest/support/Query.js"; import type AttributeTableTemplate from "../tables/AttributeTableTemplate.js"; import type { ClonableMixin } from "../core/Clonable.js"; import type { ReadonlyArrayOrCollection } from "../core/Collection.js"; import type { MultiOriginJSONSupportMixin } from "../core/MultiOriginJSONSupport.js"; import type { EditOptions, Edits, EditsResult, FeatureEditResult } from "../editing/types.js"; import type { LayerEvents, LayerProperties } from "./Layer.js"; import type { LayerSaveAsOptions, LayerSaveOptions, FeatureTitleOptions } from "./types.js"; import type { APIKeyMixin, APIKeyMixinProperties } from "./mixins/APIKeyMixin.js"; import type { BlendLayer, BlendLayerProperties } from "./mixins/BlendLayer.js"; import type { CustomParametersMixin, CustomParametersMixinProperties } from "./mixins/CustomParametersMixin.js"; import type { DisplayFilteredLayer, DisplayFilteredLayerProperties } from "./mixins/DisplayFilteredLayer.js"; import type { EditBusLayer, EditBusLayerEvents } from "./mixins/EditBusLayer.js"; import type { FeatureEffectLayer, FeatureEffectLayerProperties } from "./mixins/FeatureEffectLayer.js"; import type { FeatureLayerBase, FeatureLayerBaseProperties } from "./mixins/FeatureLayerBase.js"; import type { FeatureReductionLayer, FeatureReductionLayerProperties } from "./mixins/FeatureReductionLayer.js"; import type { OperationalLayer, OperationalLayerProperties } from "./mixins/OperationalLayer.js"; import type { OrderedLayer, OrderedLayerProperties } from "./mixins/OrderedLayer.js"; import type { PortalLayer, PortalLayerProperties } from "./mixins/PortalLayer.js"; import type { PublishableLayer, PublishableLayerProperties } from "./mixins/PublishableLayer.js"; import type { RefreshableLayerEvents, RefreshableLayer, RefreshableLayerProperties } from "./mixins/RefreshableLayer.js"; import type { ScaleRangeLayer, ScaleRangeLayerProperties } from "./mixins/ScaleRangeLayer.js"; import type { TemporalLayer, TemporalLayerProperties } from "./mixins/TemporalLayer.js"; import type { TrackableLayer, TrackableLayerProperties } from "./mixins/TrackableLayer.js"; import type { PortalItemProperties } from "../portal/PortalItem.js"; import type { RendererUnion } from "../renderers/types.js"; import type { RequestOptions } from "../request/types.js"; import type { AttachmentQueryProperties } from "../rest/support/AttachmentQuery.js"; import type { AttributeBinsQueryProperties } from "../rest/support/AttributeBinsQuery.js"; import type { QueryProperties } from "../rest/support/Query.js"; import type { RelationshipQueryProperties } from "../rest/support/RelationshipQuery.js"; import type { TopFeaturesQueryProperties } from "../rest/support/TopFeaturesQuery.js"; import type { CreatePopupTemplateOptions } from "../support/popupUtils.js"; import type { ObjectId } from "../views/types.js"; import type { AttributeTableTemplateProperties } from "../tables/AttributeTableTemplate.js"; import type { DynamicDataLayerProperties } from "../rest/layerSources/DynamicDataLayer.js"; import type { FieldConfigurationProperties } from "./support/FieldConfiguration.js"; import type { FieldProperties } from "./support/Field.js"; import type { FormTemplateProperties } from "../form/FormTemplate.js"; import type { LabelClassProperties } from "./support/LabelClass.js"; import type { PopupTemplateProperties } from "../PopupTemplate.js"; import type { HeatmapRendererProperties } from "../renderers/HeatmapRenderer.js"; import type { PieChartRendererProperties } from "../renderers/PieChartRenderer.js"; import type { DictionaryRendererProperties } from "../renderers/DictionaryRenderer.js"; import type { DotDensityRendererProperties } from "../renderers/DotDensityRenderer.js"; import type { UniqueValueRendererProperties } from "../renderers/UniqueValueRenderer.js"; import type { ClassBreaksRendererProperties } from "../renderers/ClassBreaksRenderer.js"; import type { SimpleRendererProperties } from "../renderers/SimpleRenderer.js"; import type { FeatureTemplateProperties } from "./support/FeatureTemplate.js"; import type { FeatureTypeProperties } from "./support/FeatureType.js"; export interface FeatureLayerProperties extends LayerProperties, APIKeyMixinProperties, CustomParametersMixinProperties, PortalLayerProperties, OperationalLayerProperties, RefreshableLayerProperties, ScaleRangeLayerProperties, TrackableLayerProperties, TemporalLayerProperties, OrderedLayerProperties, BlendLayerProperties, DisplayFilteredLayerProperties, PublishableLayerProperties, FeatureEffectLayerProperties, FeatureReductionLayerProperties, FeatureLayerBaseProperties, Partial> { /** * This property is used to configure the associated layer's [Feature Table](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-feature-table/). It is meant to configure how the columns display within the table in regard to visibility, column order, and sorting. * * > [!WARNING] * > * > This property differs from a [FeatureTable's tableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/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](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) and [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) documentation for more information. * * @since 4.31 * @see [Sample - FeatureTable Component](https://developers.arcgis.com/javascript/latest/sample-code/feature-table/) */ attributeTableTemplate?: AttributeTableTemplateProperties | null; /** * An object that allows you to create a dynamic layer with data * either from map service sublayers or data from a registered workspace. * See [DynamicMapLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/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](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicDataLayer/). * * If you already have a [Sublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/) instance, you * can call the [Sublayer.createFeatureLayer()](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#createFeatureLayer) * method on the Sublayer to construct the layer for you. * * This only applies to map services with * [dynamic layers](https://enterprise.arcgis.com/en/server/latest/publish-services/linux/about-dynamic-layers.htm) enabled. * * > [!WARNING] * > * > **Known Limitations** * > * > FeatureLayers with a `dynamicDataSource` cannot be persisted to web maps, web scenes, and portal items. * * @since 4.7 * @see [Sublayer.source](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#source) * @see [Sublayer.createFeatureLayer()](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#createFeatureLayer) * @example * const layer = new FeatureLayer({ * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/AGP/Census/MapServer", * title: "United States Population", * popupTemplate: { * title: "{states.STATE_NAME}", * content: "{expression/per_ancestry}% of the {states.POP2007} people in {states.STATE_NAME} have " * + "Norwegian ancestry.", * expressionInfos: [{ * name: "per_ancestry", * expression: "Round( ( $feature['ancestry.norwegian'] / $feature['states.POP2007'] ) * 100, 1)" * }], * fieldInfos: [{ * fieldName: "states.POP2007", * fieldFormat: { * type: "number", * useGrouping: "always", * maximumFractionDigits: 0 * } * }] * }, * dynamicDataSource: { * type: "data-layer", * dataSource: { * type: "join-table", * leftTableSource: { * type: "map-layer", * mapLayerId: 3 * }, * rightTableSource: { * type: "data-layer", * dataSource: { * type: "table", * workspaceId: "CensusFileGDBWorkspaceID", * dataSourceName: "ancestry" * } * }, * leftTableKey: "STATE_NAME", * rightTableKey: "State", * joinType: "left-outer-join" * } * } * }); */ dynamicDataSource?: DynamicDataLayerProperties | null; /** * An array of [FieldConfiguration](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/) objects that control how fields are displayed in popups and other UI elements. Each object specifies options for an individual field, such as its display name, via `alias`, and formatting rules, via `fieldFormat`. Assign this property before the layer loads to ensure the configurations take effect. For more information, see the [FieldConfiguration](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/) documentation. * * If no field configurations are provided, they are automatically created when a [popupTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#popupTemplate) is assigned to the layer. If no [popupTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#popupTemplate) is set, you can manually define field configurations to customize how fields are shown. * * > [!WARNING] * > * > Support is limited in version 4.34. For details, see the [FieldConfiguration](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/) documentation. * * To modify field configurations, clone [fieldConfigurations](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fieldConfigurations), make the changes, and then reassign the updated clone back to `FeatureLayer.fieldConfigurations`. * * @since 4.34 * @see [getFieldConfiguration()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#getFieldConfiguration) * @see [getFieldAlias()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#getFieldAlias) * @see [FieldConfiguration](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/) * @example * // Adding a new field configuration * const addNewConfig = (layer, fieldName, alias, * fieldFormat) => { * // Check if there is already an existing configuration for fieldName * const existingConfig = layer.getFieldConfiguration(fieldName); * if (!existingConfig) { * const newConfig = new FieldConfiguration({ name: fieldName, alias, fieldFormat }); * const newConfigs = clone(layer.fieldConfigurations); * newConfigs.push(newConfig); * layer.fieldConfigurations = newConfigs; * } * }; * @example * // Updating an existing field configuration * const updateConfig = (layer, fieldName, alias, * fieldFormat) => { * const existingConfig = layer.getFieldConfiguration(fieldName); * if (existingConfig) { * const newConfig = existingConfig.clone(); * newConfig.alias = alias; * newConfig.fieldFormat = fieldFormat; * * const index = layer.fieldConfigurations.indexOf(existingConfig); * const newConfigs = clone(layer.fieldConfigurations); * newConfigs[index] = newConfig; * layer.fieldConfigurations = newConfigs; * } * }; * @example * // Deleting an existing field configuration * const deleteConfig = (layer, fieldName) => { * const existingConfig = layer.getFieldConfiguration(fieldName); * if (existingConfig) { * const index = layer.fieldConfigurations.indexOf(existingConfig); * var newConfigs = clone(layer.fieldConfigurations); * newConfigs.splice(index, 1); * layer.fieldConfigurations = newConfigs; * } * }; */ fieldConfigurations?: FieldConfigurationProperties[] | null; /** * 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. * * When creating a FeatureLayer from [client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#client-side), this property * should be set in the constructor along with the [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source) property. The `objectId` * field also must be set either in this array or in the [objectIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#objectIdField) property. * * @see [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source) * @see [objectIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#objectIdField) * @see [Add an array of client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#client-side) * @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 and renderer properties * const layer = new FeatureLayer({ * // geometryType and spatialReference are inferred * // from the input source features * source: features, * // Object ID field is inferred from the fields array * fields: fields, * renderer: renderer * }); */ fields?: FieldProperties[]; /** * The [template](https://developers.arcgis.com/javascript/latest/references/core/form/FormTemplate/) used in an associated layer's [FeatureForm](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureForm/). All of the properties and field configurations set on the layer's [Feature Form](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-feature-form/) are handled via the [FormTemplate](https://developers.arcgis.com/javascript/latest/references/core/form/FormTemplate/). * * @since 4.16 * @see [Sample - Update Feature Attributes](https://developers.arcgis.com/javascript/latest/sample-code/editing-groupedfeatureform/) * @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 * featureLayer.formTemplate = formTemplate; * * // Pass the layer to the FeatureForm * const form = new FeatureForm({ * container: "form", // html div referencing the form * layer: featureLayer * }); */ formTemplate?: FormTemplateProperties | null; /** * The label definition for this layer, specified as an array of * [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/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](https://developers.arcgis.com/javascript/latest/labeling/) for more information and known limitations. * * > [!WARNING] * > * > **Known Limitations** * > * > 3D [SceneViews](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) only support displaying one [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) per feature. * * @see [Sample: Add multiple label classes to a layer](https://developers.arcgis.com/javascript/latest/sample-code/labels-multiple-classes/) * @see [Sample: Multi-line labels](https://developers.arcgis.com/javascript/latest/sample-code/labels-multiline/) * @see [Sample: Flat vs. volumetric 3D symbol layers](https://developers.arcgis.com/javascript/latest/sample-code/symbols-points-3d/) * @example * const statesLabelClass = new LabelClass({ * labelExpressionInfo: { expression: "$feature.NAME" }, * symbol: { * type: "text", // autocasts as new TextSymbol() * color: "black", * haloSize: 1, * haloColor: "white" * } * }); * * featureLayer.labelingInfo = [ statesLabelClass ]; */ labelingInfo?: LabelClassProperties[] | null; /** * 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](https://developers.arcgis.com/javascript/latest/sample-code/intro-popuptemplate/) * for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) interacts with a * [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/). * * A default popup template is automatically used if no `popupTemplate` has been defined when * [Popup.defaultPopupTemplateEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/#defaultPopupTemplateEnabled) * is set to `true`. * * @see [createPopupTemplate()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#createPopupTemplate) * @see [SceneView.popup](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#popup) * @see [View2D.popup](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/#popup) */ popupTemplate?: PopupTemplateProperties | null; /** * Refresh interval of the layer in minutes. Value of `0` indicates no refresh. * At each refresh interval, the data is only updated if the `lastEditDate` in the layer's metadata is different from the `lastEditDate` field. * If the `lastEditDate` metadata info is not available, the FeatureLayer refreshes unconditionally. * * @default 0 * @since 4.6 * @see [refresh()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#refresh) * @see [refresh event](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#event-refresh) * @example * // the layer will be refreshed every 1 minute. * layer.refreshInterval = 1; * @see [RefreshableLayer.refresh()](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/RefreshableLayer/#refresh) * @see [refresh event](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/RefreshableLayer/#event-refresh) * @example * // the layer will be refreshed every minute. * layer.refreshInterval = 1; */ refreshInterval?: number; /** * 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](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source), * [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fields), [objectIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#objectIdField) properties. * * @see [Styles and data visualization](https://developers.arcgis.com/javascript/latest/visualization/) * @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" * } * } * }; */ renderer?: (((SimpleRendererProperties & { type: "simple" }) | (ClassBreaksRendererProperties & { type: "class-breaks" }) | (UniqueValueRendererProperties & { type: "unique-value" }) | (DotDensityRendererProperties & { type: "dot-density" }) | (DictionaryRendererProperties & { type: "dictionary" }) | (PieChartRendererProperties & { type: "pie-chart" })) | (HeatmapRendererProperties & { type: "heatmap" })) | null; /** * A collection of [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) objects used to create a FeatureLayer. * The geometry of each feature all must have a matching [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType). * This property must be set when creating a FeatureLayer from [client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#client-side). * When creating a FeatureLayer from client-side features, the `objectId` field must be set * either in the [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fields) array or via [objectIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#objectIdField). * * The [spatialReference](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#spatialReference) and [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType) properties * are determined based on the features provided to this property. If the `source` is an empty * array at the time of layer initialization, then [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType) must be set. * * The source is not updated after the FeatureLayer is initialized. Use [applyEdits()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#applyEdits) method to add, remove, and update features * from a client-side feature layer at runtime. Once `applyEdits()` resolves successfully, use [queryFeatures()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#queryFeatures) * to return updated features. * * @see [Add an array of client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#client-side) * @see [Sample - Add 100,000 features to feature collection](https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-large-collection/) * @example * let features = [ * { * geometry: { * type: "point", * x: -100, * y: 38 * }, * attributes: { * ObjectID: 1, * DepArpt: "KATL", * MsgTime: Date.now(), * FltId: "UAL1" * } * }, * ... * ]; * * // geometryType and spatialReference of the layer * // will be inferred from the first feature in the array * // if it has a geometry. * let layer = new FeatureLayer({ * source: features, // autocast as a Collection of new Graphic() * objectIdField: "ObjectID" * }); * @example * // Create an empty non-spatial feature layer * // Set geometryType property to null when creating non-spatial feature layer * const layer = new FeatureLayer({ * source: [], * objectIdField: "OBJECTID", * fields: [{ * name: "OBJECTID", * type: "oid" * }], * geometryType: null * }); * layer.load().then(() => console.log(layer.isTable)) */ source?: ReadonlyArrayOrCollection; /** * An array of feature templates defined in the feature layer. * See [ArcGIS Pro subtypes document](https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/an-overview-of-subtypes.htm). * * @since 4.4 */ templates?: FeatureTemplateProperties[] | null; /** * An array of [types](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureType/) defined in the feature service exposed by ArcGIS REST API. * Each item includes information about the type, such as the type ID, name, and definition expression. * * @since 4.4 */ types?: FeatureTypeProperties[] | null; } export interface FeatureLayerEvents extends EditBusLayerEvents, RefreshableLayerEvents, LayerEvents {} /** * * [Overview](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#overview) * * [Creating a FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#creating-a-featurelayer) * * [Querying](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#querying) * * [Data Visualization](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#data-visualization) * * [Known limitations](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#limits) * * * ## Overview * * A FeatureLayer is a single layer that can be created from a * [Map Service](https://enterprise.arcgis.com/en/server/latest/publish-services/windows/what-is-a-map-service.htm) * or [Feature Service](https://enterprise.arcgis.com/en/server/latest/publish-services/windows/what-is-a-feature-service-.htm); * ArcGIS Online or ArcGIS Enterprise portal items; or from an array of client-side features. The layer can be either a * spatial (has geographic features) or non-spatial (table). * * Spatial layer is composed of discrete features, each of which has a [Geometry](https://developers.arcgis.com/javascript/latest/references/core/geometry/Geometry/) * that allows it to be rendered in either a 2D [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) or * 3D [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) as a * [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) with spatial context. Features also contain data * [Graphic.attributes](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#attributes) that provide additional information about * the real-world feature it represents; attributes may be viewed in [popup](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#popupTemplate) windows * and used for [rendering](https://developers.arcgis.com/javascript/latest/references/core/renderers/Renderer/) the layer. * FeatureLayers may be [queried](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#queryFeatures), [analyzed](https://developers.arcgis.com/javascript/latest/spatial-analysis/intro-geometry-operators/), * and [rendered](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#renderer) to visualize data in a spatial context. * * Non-spatial layer is a table which does not have a spatial column representing geographic features. * * * * ## Creating a FeatureLayer * * FeatureLayers may be created in one of three ways: from a [service URL](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#url), an ArcGIS portal [item ID](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#portalItem), * or from an [array of client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source). * *
* Read More * * ### Reference a service URL * * To create a FeatureLayer instance from a service, you must set the [url](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#url) property * to the REST endpoint of a layer in either a Feature Service * or a Map Service. For a layer to be visible in a view, it must be added to the [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) * referenced by the view. See [Map.add()](https://developers.arcgis.com/javascript/latest/references/core/Map/#add) for information about adding layers to a map. * * ```js * const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); * // points to the states layer in a service storing U.S. census data * const fl = new FeatureLayer({ * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3" * }); * map.add(fl); // adds the layer to the map * ``` * * Non-spatial table instance can be created from the table [url](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#url) in a service and the table must be loaded by calling [load()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#load) * method. * * ```js * // Add a non-spatial table. * const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); * // points to the non-spatial table in a service storing San Francisco crime incidents. * const table = new FeatureLayer({ * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/1" * }); * table.load().then(function() { * // table is loaded. ready to be queried on the server. * }); * ``` * * If the service is requested from a different domain, a [CORS enabled server](https://developers.arcgis.com/javascript/latest/cors/) or a [proxy](https://developers.arcgis.com/javascript/latest/proxies/) is required. * * ### Reference an ArcGIS portal Item ID * * You can also create a FeatureLayer from its ID if it exists as an item in ArcGIS Online or ArcGIS Enterprise. * For example, the following snippet shows how to add a new FeatureLayer instance to a map using the * [portalItem](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#portalItem) property. * * ```js * // points to a hosted Feature Layer in ArcGIS Online * const fl = new FeatureLayer({ * portalItem: { // autocasts as esri/portal/PortalItem * id: "8444e275037549c1acab02d2626daaee" * } * }); * map.add(fl); // adds the layer to the map * ``` * * The following snippet shows how to create a FeatureLayer referencing a table using the * [portalItem](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#portalItem) property. * * ```js * // points to a hosted table in ArcGIS Online * const table = new FeatureLayer({ * portalItem: { // autocasts as esri/portal/PortalItem * id: "123f4410054b43d7a0bacc1533ceb8dc" * } * }); * * // Before adding the table to the map, it must first be loaded and confirm it is the right type. * table.load().then(function() { * if (table.isTable) { * map.tables.add(table); * } * }); * ``` * * * ### Add an array of client-side features * * A FeatureLayer can be created from client-side features such as an array of [graphics](https://developers.arcgis.com/javascript/latest/references/core/Graphic/). * These graphics may have [geometries](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#geometry) for spatial layers or may be non-spatial. * If the graphics do not include geometries and the [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType) is `null`, the resulting layer will be a non-spatial FeatureLayer. * Since a FeatureLayer requires a defined schema, several properties must be specified when initializing a layer with client-side data. * * **Automatic property inference:** If required properties are not explicitly set, the API attempts to infer values from the provided parameters or features * in the [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source). For example, the [spatialReference](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#spatialReference), [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType), [hasZ](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#hasZ) * and [hasM](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#hasM) properties can be derived from the features provided in the [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source). However, if the source is an empty array at the time of * initialization, the [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType) cannot be inferred, and the layer will fail to initialize when the layer is added to the map. * * **Geometry type and spatial reference:** For spatial data, the [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType) must be defined explicitly, if the [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source) * is empty at the time layer's initialization. A valid [spatialReference](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#spatialReference) is also required. * * **Field schema:** Both spatial and non-spatial feature collections must include an [objectIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#objectIdField), which provides a unique identifier * for each feature. This must be indicated along with an array of [field](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fields) objects, providing the schema of each field. * Certain characters are not supported in field names. See [field naming guidelines](https://support.esri.com/en-us/knowledge-base/what-characters-should-not-be-used-in-arcgis-for-field--000005588) * for details. If the data includes date fields with values recorded in a time zone other than `UTC`, the [dateFieldsTimeZone](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#dateFieldsTimeZone) property should be set to * ensure correct results in [date-based queries](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#date-query). * * Once all required properties are configured, the array of features must be assigned to the [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source) property. See * [create a FeatureLayer with client-side graphics sample](https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/). * * **Runtime updates:** FeatureLayer's [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source) is not updated after the FeatureLayer is initialized. If features are added, removed or updated at runtime, * then use [applyEdits()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#applyEdits) to update the features then use [queryFeatures()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#queryFeatures) to return updated features. Check out * [Working with large feature collections](https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-large-collection/) * to see this in action. * * Attribute values used in attribute queries executed against client-side feature layer, and layer views are case sensitive. * * ```js * const layer = new FeatureLayer({ * // create an instance of esri/layers/support/Field for each field object * fields: [ * { * name: "ObjectID", * alias: "ObjectID", * type: "oid" * }, { * name: "type", * alias: "Type", * type: "string" * }, { * name: "place", * alias: "Place", * type: "string" * },{ * name: "recordedDate", * alias: "recordedDate", * type: "date" * }], * dateFieldsTimeZone: "America/New_York", // date field values in are eastern time zone * objectIdField: "ObjectID", // inferred from fields array if not specified * geometryType: "point", // geometryType and spatialReference are inferred from the first feature * // in the source array if they are not specified. * spatialReference: { wkid: 4326 }, * source: graphics, // an array of graphics with geometry and attributes * // popupTemplate and symbol are not required in each feature * // since those are handled with the popupTemplate and * // renderer properties of the layer * popupTemplate: popupTemplate, * // a default simple renderer will be applied if not set. * renderer: uvRenderer // UniqueValueRenderer based on `type` attribute * }); * map.add(layer); * ``` * * A client-side non-spatial table can be created by setting the layer's [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType) property to `null`, * then the table must be loaded by calling the [load()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#load) method. * * ```js * // Create an empty non-spatial feature layer * // Set geometryType property to null when creating non-spatial feature layer * const layer = new FeatureLayer({ * source: [], * objectIdField: "OBJECTID", * fields: [{ * name: "OBJECTID", * type: "oid" * }, * { * name: "type", * type: "string", * }], * geometryType: null * }); * layer.load().then(() => console.log(layer.isTable)) * ``` * *
* * * ## Querying * * Features within a FeatureLayer are rendered as [features](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) inside a * [FeatureLayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/). A FeatureLayerView may or may not have all features from the associated FeatureLayer. * To determine this, check the [FeatureLayerView.hasAllFeatures](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#hasAllFeatures) property on the FeatureLayerView. * If `hasAllFeatures` is `true`, the FeatureLayerView has all features from the layer, not just those visible in the view extent. * * When `hasAllFeatures` is `true`, calling [FeatureLayerView.queryFeatures()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#queryFeatures) on the FeatureLayerView * runs against all features in the layer. Otherwise, the `FeatureLayerView.queryFeatures()` runs only against features available for drawing in the FeatureLayerView. * To limit the query to features currently visible in the view when `hasAllFeatures` is `true`, set the query’s [Query.geometry](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#geometry) * property to the View's [View2D.extent](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/#extent). * *
* Read More * * ```js * // returns all the graphics from the layer view * view.whenLayerView(layer).then((layerView) => { * reactiveUtils.when( * () => !layerView.updating, * (val) => { * const query = layerView.createQuery(); * // check if layerView has all features in the layer * // if true, set query.geoemtry to view.extent to run * // the query against features visible in the view * if (layerView.hasAllFeatures) { * query.geometry = view.extent; * } * * layerView.queryFeatures(query).then((results) =>{ * console.log(results); * }); * } * ); * }); * ``` * * When accessing features from a query on the [FeatureLayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/), note that * features are returned as they are displayed in the view, including any generalization that may have been * applied to the features to enhance performance. To obtain feature geometries at full resolution, first check the FeatureLayerView’s * [FeatureLayerView.hasFullGeometries](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#hasFullGeometries) property; if it is `true`, use the * [FeatureLayerView.queryFeatures()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#queryFeatures) method on the FeatureLayerView; * otherwise, use the [queryFeatures()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#queryFeatures) method on the FeatureLayer. * * The [query methods](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#queryFeatures) in the FeatureLayer class query features directly from the service. * For example, the following snippet returns all features from the service, not just the features drawn in the * [FeatureLayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/). * * ```js * // Queries for all the features in the service (not the graphics in the view) * layer.queryFeatures().then((results) => { * // prints an array of all the features in the service to the console * console.log(results.features); * }); * ``` * * For information regarding how to create a LayerView * for a particular layer, see [View.whenLayerView()](https://developers.arcgis.com/javascript/latest/references/core/views/View/#whenLayerView). * *
* * * ## Data Visualization * * Features in a FeatureLayer are visualized by setting a [Renderer](https://developers.arcgis.com/javascript/latest/references/core/renderers/Renderer/) to the * [renderer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#renderer) property of the layer. See the [Styles and data visualization](https://developers.arcgis.com/javascript/latest/visualization/) guide for * a comprehensive set of examples of how to visualize data in a FeatureLayer. * * FeatureLayer supports [FeatureLayerView.highlight()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#highlight), which is enabled by default when users click or tap features to view the popup. You can also call the * [FeatureLayerView.highlight()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#highlight) method on the * [FeatureLayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/) to highlight features in other workflows. * * > [!WARNING] * > * > * > **Known Limitations** * > * > Locations with a very high density of features may not display all available features at small scales. * > Very large datasets may require potentially long initial load times, particularly at small scales. * > FeatureLayers are not optimized for high-frequency, dynamic data, or real-time streaming use cases. As a result, they may not perform efficiently with rapidly updating data streams. * > For real-time or dynamic data updates, use [StreamLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/StreamLayer/), which are designed for efficient handling of high-frequency streaming data and dynamic features. * > Server-side and client-side feature tile caching allow features to load much faster after the initial data download. * > We are continuously improving our feature fetching strategy and load time efficiency in each release. * > The [big-integer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/#type) field type is still in beta and may not be fully supported in the JavaScript SDK. Console * > warnings will be thrown when a layer has a `big-integer` field. To disable the warnings use the following flag: * > ```js * > * > ``` * * @since 4.0 * @see [Sample - Add FeatureLayer to your Map](https://developers.arcgis.com/javascript/latest/sample-code/intro-layers/) * @see [Sample - Create a FeatureLayer with client-side graphics](https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/) * @see [Sample - Query features from a FeatureLayer](https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query/) * @see [FeatureLayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/) */ export default class FeatureLayer extends __FeatureLayerSansType { /** The layer type provides a convenient way to check the type of the layer without the need to import specific layer modules. */ get type(): "feature"; } export abstract class __FeatureLayerSansType extends FeatureLayerSuperclass { /** * @deprecated * Do not directly reference this property. * Use EventNames and EventTypes helpers from \@arcgis/core/Evented */ "@eventTypes": FeatureLayerEvents; /** * @see [Client-side FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#client-side) * @example * // Typical usage * // Create featurelayer from feature service * const layer = new FeatureLayer({ * // URL to the service * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0" * }); * * // Typical usage * // Create featurelayer from client-side graphics * const layer = new FeatureLayer({ * source: graphics, * fields: [{ * name: "ObjectID", * alias: "ObjectID", * type: "oid" * }, { * name: "place", * alias: "Place", * type: "string" * }], * objectIdField: "ObjectID", * geometryType: "point" * }); */ constructor(properties?: FeatureLayerProperties); /** * This property is used to configure the associated layer's [Feature Table](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-feature-table/). It is meant to configure how the columns display within the table in regard to visibility, column order, and sorting. * * > [!WARNING] * > * > This property differs from a [FeatureTable's tableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/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](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) and [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) documentation for more information. * * @since 4.31 * @see [Sample - FeatureTable Component](https://developers.arcgis.com/javascript/latest/sample-code/feature-table/) */ get attributeTableTemplate(): AttributeTableTemplate | null | undefined; set attributeTableTemplate(value: AttributeTableTemplateProperties | null | undefined); /** * Array of Chart Items of type WebMapWebChart available on the feature layer. * * @since 4.29 */ accessor charts: object[] | null | undefined; /** * An object that allows you to create a dynamic layer with data * either from map service sublayers or data from a registered workspace. * See [DynamicMapLayer](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/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](https://developers.arcgis.com/javascript/latest/references/core/rest/layerSources/DynamicDataLayer/). * * If you already have a [Sublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/) instance, you * can call the [Sublayer.createFeatureLayer()](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#createFeatureLayer) * method on the Sublayer to construct the layer for you. * * This only applies to map services with * [dynamic layers](https://enterprise.arcgis.com/en/server/latest/publish-services/linux/about-dynamic-layers.htm) enabled. * * > [!WARNING] * > * > **Known Limitations** * > * > FeatureLayers with a `dynamicDataSource` cannot be persisted to web maps, web scenes, and portal items. * * @since 4.7 * @see [Sublayer.source](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#source) * @see [Sublayer.createFeatureLayer()](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/#createFeatureLayer) * @example * const layer = new FeatureLayer({ * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/AGP/Census/MapServer", * title: "United States Population", * popupTemplate: { * title: "{states.STATE_NAME}", * content: "{expression/per_ancestry}% of the {states.POP2007} people in {states.STATE_NAME} have " * + "Norwegian ancestry.", * expressionInfos: [{ * name: "per_ancestry", * expression: "Round( ( $feature['ancestry.norwegian'] / $feature['states.POP2007'] ) * 100, 1)" * }], * fieldInfos: [{ * fieldName: "states.POP2007", * fieldFormat: { * type: "number", * useGrouping: "always", * maximumFractionDigits: 0 * } * }] * }, * dynamicDataSource: { * type: "data-layer", * dataSource: { * type: "join-table", * leftTableSource: { * type: "map-layer", * mapLayerId: 3 * }, * rightTableSource: { * type: "data-layer", * dataSource: { * type: "table", * workspaceId: "CensusFileGDBWorkspaceID", * dataSourceName: "ancestry" * } * }, * leftTableKey: "STATE_NAME", * rightTableKey: "State", * joinType: "left-outer-join" * } * } * }); */ get dynamicDataSource(): DynamicDataLayer | null | undefined; set dynamicDataSource(value: DynamicDataLayerProperties | null | undefined); /** * Determines if the layer is editable. * * @default true * @since 4.18 * @see [applyEdits()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#applyEdits) */ accessor editingEnabled: boolean; /** * An array of [FieldConfiguration](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/) objects that control how fields are displayed in popups and other UI elements. Each object specifies options for an individual field, such as its display name, via `alias`, and formatting rules, via `fieldFormat`. Assign this property before the layer loads to ensure the configurations take effect. For more information, see the [FieldConfiguration](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/) documentation. * * If no field configurations are provided, they are automatically created when a [popupTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#popupTemplate) is assigned to the layer. If no [popupTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#popupTemplate) is set, you can manually define field configurations to customize how fields are shown. * * > [!WARNING] * > * > Support is limited in version 4.34. For details, see the [FieldConfiguration](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/) documentation. * * To modify field configurations, clone [fieldConfigurations](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fieldConfigurations), make the changes, and then reassign the updated clone back to `FeatureLayer.fieldConfigurations`. * * @since 4.34 * @see [getFieldConfiguration()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#getFieldConfiguration) * @see [getFieldAlias()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#getFieldAlias) * @see [FieldConfiguration](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/) * @example * // Adding a new field configuration * const addNewConfig = (layer, fieldName, alias, * fieldFormat) => { * // Check if there is already an existing configuration for fieldName * const existingConfig = layer.getFieldConfiguration(fieldName); * if (!existingConfig) { * const newConfig = new FieldConfiguration({ name: fieldName, alias, fieldFormat }); * const newConfigs = clone(layer.fieldConfigurations); * newConfigs.push(newConfig); * layer.fieldConfigurations = newConfigs; * } * }; * @example * // Updating an existing field configuration * const updateConfig = (layer, fieldName, alias, * fieldFormat) => { * const existingConfig = layer.getFieldConfiguration(fieldName); * if (existingConfig) { * const newConfig = existingConfig.clone(); * newConfig.alias = alias; * newConfig.fieldFormat = fieldFormat; * * const index = layer.fieldConfigurations.indexOf(existingConfig); * const newConfigs = clone(layer.fieldConfigurations); * newConfigs[index] = newConfig; * layer.fieldConfigurations = newConfigs; * } * }; * @example * // Deleting an existing field configuration * const deleteConfig = (layer, fieldName) => { * const existingConfig = layer.getFieldConfiguration(fieldName); * if (existingConfig) { * const index = layer.fieldConfigurations.indexOf(existingConfig); * var newConfigs = clone(layer.fieldConfigurations); * newConfigs.splice(index, 1); * layer.fieldConfigurations = newConfigs; * } * }; */ get fieldConfigurations(): FieldConfiguration[] | null | undefined; set fieldConfigurations(value: FieldConfigurationProperties[] | null | undefined); /** * 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. * * When creating a FeatureLayer from [client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#client-side), this property * should be set in the constructor along with the [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source) property. The `objectId` * field also must be set either in this array or in the [objectIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#objectIdField) property. * * @see [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source) * @see [objectIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#objectIdField) * @see [Add an array of client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#client-side) * @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 and renderer properties * const layer = new FeatureLayer({ * // geometryType and spatialReference are inferred * // from the input source features * source: features, * // Object ID field is inferred from the fields array * fields: fields, * renderer: renderer * }); */ get fields(): Field[]; set fields(value: FieldProperties[]); /** * The [template](https://developers.arcgis.com/javascript/latest/references/core/form/FormTemplate/) used in an associated layer's [FeatureForm](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureForm/). All of the properties and field configurations set on the layer's [Feature Form](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-feature-form/) are handled via the [FormTemplate](https://developers.arcgis.com/javascript/latest/references/core/form/FormTemplate/). * * @since 4.16 * @see [Sample - Update Feature Attributes](https://developers.arcgis.com/javascript/latest/sample-code/editing-groupedfeatureform/) * @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 * featureLayer.formTemplate = formTemplate; * * // Pass the layer to the FeatureForm * const form = new FeatureForm({ * container: "form", // html div referencing the form * layer: featureLayer * }); */ get formTemplate(): FormTemplate | null | undefined; set formTemplate(value: FormTemplateProperties | null | undefined); /** * The label definition for this layer, specified as an array of * [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/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](https://developers.arcgis.com/javascript/latest/labeling/) for more information and known limitations. * * > [!WARNING] * > * > **Known Limitations** * > * > 3D [SceneViews](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) only support displaying one [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) per feature. * * @see [Sample: Add multiple label classes to a layer](https://developers.arcgis.com/javascript/latest/sample-code/labels-multiple-classes/) * @see [Sample: Multi-line labels](https://developers.arcgis.com/javascript/latest/sample-code/labels-multiline/) * @see [Sample: Flat vs. volumetric 3D symbol layers](https://developers.arcgis.com/javascript/latest/sample-code/symbols-points-3d/) * @example * const statesLabelClass = new LabelClass({ * labelExpressionInfo: { expression: "$feature.NAME" }, * symbol: { * type: "text", // autocasts as new TextSymbol() * color: "black", * haloSize: 1, * haloColor: "white" * } * }); * * featureLayer.labelingInfo = [ statesLabelClass ]; */ get labelingInfo(): LabelClass[] | null | undefined; set labelingInfo(value: LabelClassProperties[] | null | undefined); /** * Indicates whether to display labels for this layer. If `true`, labels will * appear as defined in the [labelingInfo](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#labelingInfo) property. * * > [!WARNING] * > * > **Known Limitations** * > * > 3D [SceneViews](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) only support displaying one [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) per feature. * * @default true */ accessor labelsVisible: boolean; /** * Indicates whether the layer will be included in the legend. * * @default true */ accessor legendEnabled: boolean; /** * An array of field names from the service to include with each feature. * To fetch the values from all fields in the layer, use `["*"]`. Fields specified in * `outFields` will be requested alongside with required fields for [rendering](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#renderer), * [labeling](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#labelingInfo) and setting the [elevation info](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#elevationInfo) for the layer. * The required fields and `outFields` are used to populate * [FeatureLayerView.availableFields](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#availableFields). * Set this property to include the fields that will be used for client-side * [queries](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#queryFeatures) * if the fields are not part of required fields used for rendering. * * @see [FeatureLayerView.availableFields](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#availableFields) * @see [fieldUtils](https://developers.arcgis.com/javascript/latest/references/core/layers/support/fieldUtils/) * @example * // Includes all fields from the service in the layer * fl.outFields = ["*"]; * @example * // Get the specified fields from the service in the layer * // These fields will be added to FeatureLayerView.availableFields * // along with rendering and labeling fields. Use these fields * // for client-side filtering and querying. * fl.outFields = ["NAME", "POP_2010", "FIPS", "AREA"]; * @example * // set the outFields for the layer coming from webmap * webmap.when(function () { * layer = webmap.layers.at(1); * layer.outFields = ["*"]; * }); */ accessor outFields: string[] | null | undefined; /** * Indicates whether to display popups when features in the layer are clicked. The layer needs to have a [popupTemplate](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#popupTemplate) to define what * information should be displayed in the popup. Alternatively, a default popup template may be automatically used if * [Popup.defaultPopupTemplateEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/#defaultPopupTemplateEnabled) is set to `true`. * * @default true * @see [createPopupTemplate()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#createPopupTemplate) * @see [SceneView.popup](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#popup) * @see [View2D.popup](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/#popup) */ accessor popupEnabled: boolean; /** * 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](https://developers.arcgis.com/javascript/latest/sample-code/intro-popuptemplate/) * for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) interacts with a * [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/). * * A default popup template is automatically used if no `popupTemplate` has been defined when * [Popup.defaultPopupTemplateEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/#defaultPopupTemplateEnabled) * is set to `true`. * * @see [createPopupTemplate()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#createPopupTemplate) * @see [SceneView.popup](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#popup) * @see [View2D.popup](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/#popup) */ get popupTemplate(): PopupTemplate | null | undefined; set popupTemplate(value: PopupTemplateProperties | null | undefined); /** * Refresh interval of the layer in minutes. Value of `0` indicates no refresh. * At each refresh interval, the data is only updated if the `lastEditDate` in the layer's metadata is different from the `lastEditDate` field. * If the `lastEditDate` metadata info is not available, the FeatureLayer refreshes unconditionally. * * @default 0 * @since 4.6 * @see [refresh()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#refresh) * @see [refresh event](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#event-refresh) * @example * // the layer will be refreshed every 1 minute. * layer.refreshInterval = 1; * @see [RefreshableLayer.refresh()](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/RefreshableLayer/#refresh) * @see [refresh event](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/RefreshableLayer/#event-refresh) * @example * // the layer will be refreshed every minute. * layer.refreshInterval = 1; */ accessor refreshInterval: number; /** * 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](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source), * [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fields), [objectIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#objectIdField) properties. * * @see [Styles and data visualization](https://developers.arcgis.com/javascript/latest/visualization/) * @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" * } * } * }; */ get renderer(): RendererUnion | null | undefined; set renderer(value: (((SimpleRendererProperties & { type: "simple" }) | (ClassBreaksRendererProperties & { type: "class-breaks" }) | (UniqueValueRendererProperties & { type: "unique-value" }) | (DotDensityRendererProperties & { type: "dot-density" }) | (DictionaryRendererProperties & { type: "dictionary" }) | (PieChartRendererProperties & { type: "pie-chart" })) | (HeatmapRendererProperties & { type: "heatmap" })) | null | undefined); /** * Apply perspective scaling to screen-size symbols in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * When `true`, screen sized objects such as [icons](https://developers.arcgis.com/javascript/latest/references/core/symbols/IconSymbol3DLayer/), * [labels](https://developers.arcgis.com/javascript/latest/references/core/symbols/LabelSymbol3D/) or [callouts](https://developers.arcgis.com/javascript/latest/references/core/symbols/callouts/Callout3D/) integrate * better in the 3D scene by applying a certain perspective projection to the * sizing of features. This only applies when using a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * * `layer.screenSizePerspectiveEnabled = true` * * ![screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/references/core/symbols/symbols-screenSize-perspective.png) * * `layer.screenSizePerspectiveEnabled = false` * * ![no-screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/references/core/symbols/symbols-no-screenSize-perspective.png) * * > [!WARNING] * > * > **Known Limitations** * > * > Screen size perspective is currently not optimized for situations where the camera is very near the ground, or for scenes * > with visual elements located far from the ground surface. In these cases it may be better to turn off screen size perspective. * > As screen size perspective changes the size based on distance to the camera, it should be set to false when using * > [size visual variables](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/SizeVariable/). * * @default true * @since 4.4 * @see [Sample: Point styles for cities](https://developers.arcgis.com/javascript/latest/sample-code/visualization-point-styles/) */ accessor screenSizePerspectiveEnabled: boolean; /** * A collection of [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) objects used to create a FeatureLayer. * The geometry of each feature all must have a matching [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType). * This property must be set when creating a FeatureLayer from [client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#client-side). * When creating a FeatureLayer from client-side features, the `objectId` field must be set * either in the [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fields) array or via [objectIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#objectIdField). * * The [spatialReference](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#spatialReference) and [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType) properties * are determined based on the features provided to this property. If the `source` is an empty * array at the time of layer initialization, then [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#geometryType) must be set. * * The source is not updated after the FeatureLayer is initialized. Use [applyEdits()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#applyEdits) method to add, remove, and update features * from a client-side feature layer at runtime. Once `applyEdits()` resolves successfully, use [queryFeatures()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#queryFeatures) * to return updated features. * * @see [Add an array of client-side features](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#client-side) * @see [Sample - Add 100,000 features to feature collection](https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-large-collection/) * @example * let features = [ * { * geometry: { * type: "point", * x: -100, * y: 38 * }, * attributes: { * ObjectID: 1, * DepArpt: "KATL", * MsgTime: Date.now(), * FltId: "UAL1" * } * }, * ... * ]; * * // geometryType and spatialReference of the layer * // will be inferred from the first feature in the array * // if it has a geometry. * let layer = new FeatureLayer({ * source: features, // autocast as a Collection of new Graphic() * objectIdField: "ObjectID" * }); * @example * // Create an empty non-spatial feature layer * // Set geometryType property to null when creating non-spatial feature layer * const layer = new FeatureLayer({ * source: [], * objectIdField: "OBJECTID", * fields: [{ * name: "OBJECTID", * type: "oid" * }], * geometryType: null * }); * layer.load().then(() => console.log(layer.isTable)) */ get source(): Collection; set source(value: ReadonlyArrayOrCollection); /** * An array of feature templates defined in the feature layer. * See [ArcGIS Pro subtypes document](https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/an-overview-of-subtypes.htm). * * @since 4.4 */ get templates(): FeatureTemplate[] | null | undefined; set templates(value: FeatureTemplateProperties[] | null | undefined); /** * The name of the field holding the type ID for the features. * * @since 4.4 */ accessor typeIdField: string | null | undefined; /** * An array of [types](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureType/) defined in the feature service exposed by ArcGIS REST API. * Each item includes information about the type, such as the type ID, name, and definition expression. * * @since 4.4 */ get types(): FeatureType[] | null | undefined; set types(value: FeatureTypeProperties[] | null | undefined); /** * This property contains an array of field names that are used to uniquely identify a feature in the layer. * * @since 4.33 */ readonly uniqueIdFields?: string[] | null; /** * Adds an attachment to a feature. This operation is available only if the layer's * [capabilities.data.supportsAttachment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) is set to `true`. * * @param feature - Feature to which the attachment is to be added. * @param attachment - HTML form that contains a file upload field pointing to the file to be added as an attachment. * @returns When resolved, a [FeatureEditResult](https://developers.arcgis.com/javascript/latest/references/core/editing/types/#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`. * @since 4.9 * @see [capabilities.data.supportsAttachment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) * @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" * //
* // Select a file: * //
* 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); * }); * }); * }); * }); */ addAttachment(feature: Graphic, attachment: HTMLFormElement | FormData): Promise; /** * 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. * Only applicable to layers in a [feature service](https://developers.arcgis.com/rest/services-reference/feature-service.htm) * and client-side features set through the FeatureLayer's [source](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#source) property. Attachments can also be added, updated or deleted. * * If client-side features are added, removed or updated at runtime using [applyEdits()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#applyEdits) then use FeatureLayer's * [queryFeatures()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#queryFeatures) method to return updated features. * * > [!WARNING] * > * > **Notes** * > * > - FeatureLayers are not optimized for high-frequency, dynamic data, or real-time streaming use cases. As a result, they may not perform efficiently with rapidly updating data streams. * > For real-time or dynamic data updates, use [StreamLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/StreamLayer/), which are designed for efficient handling of high-frequency streaming data and dynamic features. * > - When calling the applyEdits method on a service that does not have [vertical coordinate system](https://pro.arcgis.com/en/pro-app/help/mapping/properties/vertical-coordinate-systems.htm) 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. * > - As of version 4.17, using applyEdits to add geometries with z-values to a FeatureLayer with `hasZ: false` no longer silently drops the z-value and now throws an error. * * @param edits - Object containing features and attachments to be added, updated or deleted. * @param options - Additional edit options to specify when editing features or attachments. * @returns When resolved, an [EditsResult](https://developers.arcgis.com/javascript/latest/references/core/editing/types/#EditsResult) * object is returned. * @see [Sample - Edit features](https://developers.arcgis.com/javascript/latest/sample-code/editing-applyedits/) * @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 = featureLayer.applyEdits({ * addFeatures: [addFeature], * deleteFeatures: deleteFeatures * }); * } */ applyEdits(edits: Edits, options?: EditOptions): Promise; /** * Creates default field configuration objects that define the display properties of fields. * These field configurations are generated from the layer's [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fields) property. * * @returns An array of field configuration objects, or `null` if * the layer does not have any fields that require formatting. * @since 4.34 * @see [fieldConfigurations](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fieldConfigurations) * @example * const fieldConfigs = featureLayer.createFieldConfigurations(); * featureLayer.fieldConfigurations = fieldConfigs; */ createFieldConfigurations(): FieldConfiguration[] | null | undefined; /** * Creates a popup template for the layer, populated with all the fields of the layer. * * @param options - Options for creating the popup template. * @returns The popup template, or `null` if the layer does not * have any fields. * @since 4.11 */ createPopupTemplate(options?: CreatePopupTemplateOptions): PopupTemplate | null | undefined; /** * Creates query parameter object that can be used to fetch features that * satisfy the layer's configurations such as [definitionExpression](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#definitionExpression), * [gdbVersion](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#gdbVersion), and [historicMoment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#historicMoment). * It will return `Z` and `M` values based on the layer's [data capabilities](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities). * It sets the query parameter's [Query.outFields](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#outFields) property to `["*"]`. * The results will include geometries of features and values for all * [available fields](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#availableFields) for * [client-side queries](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#queryFeatures) * or all fields in the layer for [server side queries](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#queryFeatures). * * @returns The query object representing the layer's definition expression * and other configurations. * @see [Sample - Query features from a FeatureLayer](https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query/) * @example * // this snippet shows the query parameter object that is returned * // from FeatureLayer.createQuery(). * const queryParams = new Query(); * const dataCapabilities = layer.get("capabilities.data"); * * queryParams.gdbVersion = layer.gdbVersion; * queryParams.historicMoment = layer.historicMoment; * queryParams.returnGeometry = true; * * if (dataCapabilities) { * if (dataCapabilities.supportsZ && layer.returnZ != null) { * queryParams.returnZ = layer.returnZ; * } * * if (dataCapabilities.supportsM && layer.returnM != null) { * queryParams.returnM = layer.returnM; * } * } * * queryParams.outFields = ["*"]; * queryParams.where = layer.definitionExpression || "1=1"; * queryParams.multipatchOption = layer.geometryType === "multipatch" ? "xyFootprint" : null; * @example * // 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); * }); */ createQuery(): Query; /** * Deletes attachments from a feature. This operation is available only if the layer's * [capabilities.data.supportsAttachment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) is set to `true`. * * @param feature - Feature containing attachments to be deleted. * @param attachmentIds - Ids of the attachments to be deleted. * @returns When resolved, an array of [FeatureEditResults](https://developers.arcgis.com/javascript/latest/references/core/editing/types/#FeatureEditResult) * 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`. * @since 4.9 * @see [capabilities.data.supportsAttachment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) */ deleteAttachments(feature: Graphic, attachmentIds: number[]): Promise; /** * Returns the title of a [feature](https://developers.arcgis.com/javascript/latest/references/core/Graphic/). The feature title is generated based on the following conditions for a `FeatureLayer`. * - If the feature has a popup title configured, then the popup title will be returned. * - If the feature does not have a popup title, then the [displayField](#displayField) value will be returned. * - If there is no `displayField`, then the [objectId](#objectIdField) will be returned. * * @param graphic - The [graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) for which to generate a title. * @param options - Additional options that control how the title is generated. * @returns When resolved, returns the feature's title string. * @since 4.34 */ getFeatureTitle(graphic: Graphic, options?: FeatureTitleOptions): Promise; /** * Returns a [FeatureType](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureType/) describing the feature's type. * This is applicable if the layer containing the feature has a [typeIdField](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#typeIdField). * * @param feature - A feature from this layer. * @returns The [FeatureType](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureType/) describing the feature's type. * @since 4.7 */ getFeatureType(feature: Graphic | null | undefined): FeatureType | null | undefined; /** * Returns the alias of the specified field. Previously, this value was commonly retrieved from [FeatureLayer.popupTemplate.fieldInfos[x].label](https://developers.arcgis.com/javascript/latest/references/core/popup/FieldInfo/#label) or [FeatureLayer.fields[x].alias](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/#alias). While these properties are still supported, this method is now the recommended approach for obtaining a field's alias. * * The alias is resolved in the following order: * * 1. [Field configuration alias](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fieldConfigurations) * 2. [Field.alias](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Field/#alias) defined on the field. * * @param fieldName - The name of the field. * @returns The field alias of the specified field. * @since 4.34 * @see [fieldConfigurations](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fieldConfigurations) * @see [getFieldConfiguration()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#getFieldConfiguration) */ getFieldAlias(fieldName: string): string | null | undefined; /** * Returns the [FieldConfigurations](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/) for the specified field. The field configuration provides optional formatting and display information for the field. * * Previously, field formatting was commonly retrieved from [FeatureLayer.popupTemplate.fieldInfos[x].format](https://developers.arcgis.com/javascript/latest/references/core/popup/FieldInfo/#format). This is no longer needed, instead use [FeatureLayer.getFieldConfiguration(fieldname).fieldFormat](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldConfiguration/#fieldFormat) to retrieve the field configuration formatting. * * @param fieldName - The name of the field. * @returns The field configuration of the specified field. * @since 4.34 * @see [fieldConfigurations](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#fieldConfigurations) * @see [getFieldAlias()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#getFieldAlias) */ getFieldConfiguration(fieldName: string): FieldConfiguration | null | undefined; /** * Query information about attachments associated with features. It will return an error if the layer's * [capabilities.data.supportsAttachment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) property is `false`. * Attachments for multiple features can be queried if the layer's [capabilities.operations.supportsQueryAttachments](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) * is `true`. * * > [!WARNING] * > * > **Known Limitations** * > * > When the layer's[capabilities.operations.supportsQueryAttachments](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) property is * > `false`, [AttachmentQuery.objectIds](https://developers.arcgis.com/javascript/latest/references/core/rest/support/AttachmentQuery/#objectIds) property only accepts a single * > `objectId`. * * @param attachmentQuery - Specifies the attachment parameters for query. * @param options - An object with the following properties. * @returns When resolved, returns an object containing * [AttachmentInfos](https://developers.arcgis.com/javascript/latest/references/core/rest/query/support/AttachmentInfo/) grouped by the source * feature objectIds. * @since 4.9 * @see [capabilities.data.supportsAttachment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) * @see [capabilities.operations.supportsQueryAttachments](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) * @example * layer.when(function () { * // queryObjectIds for all features within the layer * layer.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 * layer.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); * }) * }); * }); */ queryAttachments(attachmentQuery: AttachmentQueryProperties, options?: RequestOptions): Promise>; /** * Executes a [AttributeBinsQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/AttributeBinsQuery/) against a feature service, which groups features into bins based on ranges in numeric or date fields, and returns a * [AttributeBinsFeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/AttributeBinsFeatureSet/) containing the series of bins. Please refer to the [AttributeBinsQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/AttributeBinsQuery/) document for more detailed information * on how to configure the bin parameters. * * Binned data can condense complex information into meaningful insight. This query allows you to classify data into meaningful categories and summarize the data within each bin with summary statistics. * Binned data can be effectively visualized in histograms (or bar charts), providing clearer insights into data distributions and trends. * It can reveal underlying patterns that might be obscured in raw data. For example, bins can show concentrations of values in common ranges. * * > [!WARNING] * > * > **Notes** * > * > The `queryAttributeBins()` method is unrelated to querying bins in [FeatureReductionBinning](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureReductionBinning/). * * @param binsQuery - Specifies the parameters of the `queryAttributeBins()` operation. The [AttributeBinsQuery.binParameters](https://developers.arcgis.com/javascript/latest/references/core/rest/support/AttributeBinsQuery/#binParameters) property must be set. * @param options - An object with the following properties. * @returns When resolved, returns a [FeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) containing * a series of bins. Each feature in the [AttributeBinsFeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/AttributeBinsFeatureSet/) represents a bin. The attributes of each feature contains statistics summarizing the data in the bin, including count, average, standard deviation, etc. * @since 4.32 * @see [Sample - Attribute Bins Query](https://developers.arcgis.com/javascript/latest/sample-code/query-attribute-bins/) * @see [AttributeBinsQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/AttributeBinsQuery/) * @example * // Query the temperature field in the feature layer and create a histogram * // Analyze temperature data over a year, create 100 bins for different temperature ranges * // to assess frequency and identify patterns. * const binQuery = new AttributeBinsQuery({ * where: "UnitTop = 0", * binParameters: new AutoIntervalBinParameters({ * bins: 100, * field: "temp", * start: 0, // lowest temp value to be included in the bin query * end: 30 // highest temp value to be included * }) * }); * * layer.queryAttributeBins(query).then((results) => { * const bins = results.features.map((bin) => { * return { * minValue: bin.attributes.lowerBoundary, * maxValue: bin.attributes.upperBoundary, * count: bin.attributes.temperature_count, * }; * }); * * // get the lower boundary of the first bin * const min = results.features[0].attributes.lowerBoundary; * // get the upper boundary of the last bin * const max = results.features[results.features.length - 1].attributes.upperBoundary; * // calculate the average for the bins * const average = results.features[0].attributes.lowerBoundary + results.features[results.features.length - 1].attributes.upperBoundary) / 2; * * const histogram = new Histogram({ * container: "histogramDiv", * bins: bins, * min: min, * max: max, * average: average, * barCreatedFunction:(index, element) => { * element.setAttribute("fill", "#FFA500"); * element.setAttribute("opacity", 0.5); * }, * labelFormatFunction: (value, type) => { * return (Math.round(value)).toLocaleString(); * }, * dataLines: [{ * value: histogram.min, * label: histogram.min.toLocaleString() * }, { * value: histogram.average, * label: histogram.average.toLocaleString() * }, { * value: histogram.max, * label: histogram.max.toLocaleString() * }] * }); * }); */ queryAttributeBins(binsQuery: AttributeBinsQueryProperties, options?: RequestOptions): Promise; /** * Executes a [Query](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/) against the feature service and * returns the [Extent](https://developers.arcgis.com/javascript/latest/references/core/geometry/Extent/) of features that satisfy the query. If no * parameters are specified, then the extent and count of all features * satisfying the layer's configuration/filters are returned. * * > [!WARNING] * > * > To query for the extent of features/graphics available to or visible in the * > [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) on the client rather than making a server-side query, you must use the * > [FeatureLayerView.queryExtent()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#queryExtent) method. * * @param query - Specifies the attributes and spatial * filter of the query. If no parameters are specified, then the extent and count of all features * satisfying the layer's configuration/filters are returned. * @param options - An object with the following properties. * @returns When resolved, returns the extent and count of the features * that satisfy the input query. See the object specification table below for details. * Property | Type | Description * ---------|------|------------- * count | Number | The number of features that satisfy the input query. * extent | [Extent](https://developers.arcgis.com/javascript/latest/references/core/geometry/Extent/) \| null | The extent of the features that satisfy the query. * @see [Sample - Zoom to extent of all features](https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-queryextent/) * @example * // Queries for the extent of all features matching the layer's configurations * // e.g. definitionExpression * layer.queryExtent().then(function(results){ * // go to the extent of the results satisfying the query * view.goTo(results.extent); * }); * @example * const layer = new FeatureLayer({ * url: fsUrl // points to a Feature Service layer url * }); * * const query = new Query(); * query.where = "region = 'Southern California'"; * * layer.queryExtent(query).then((results) =>{ * view.goTo(results.extent); // go to the extent of the results satisfying the query * }); */ queryExtent(query?: QueryProperties | null | undefined, options?: RequestOptions): Promise<{ count: number; extent: Extent | null; }>; /** * Executes a [Query](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/) against the feature service 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. * * > [!WARNING] * > * > To query for the count of features/graphics available to or visible in the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) * > on the client rather than making a server-side query, you must use the * > [FeatureLayerView.queryFeatureCount()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#queryFeatureCount) method. * * @param 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. * @param options - An object with the following properties. * @returns When resolved, returns the number of features that satisfy the query. * @see [Sample - Query features from a FeatureLayer](https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query/) * @example * // Queries for the count of all features matching the layer's configurations * // e.g. definitionExpression * layer.queryFeatureCount().then((numFeatures) => { * // prints the total count to the console * console.log(numFeatures); * }); * @example * const layer = new FeatureLayer({ * url: fsUrl // points to a Feature Service layer url * }); * * const query = new Query(); * query.where = "region = 'Southern California'"; * * const featureCount = await layer.queryFeatureCount(query); * console.log(featureCount); // prints the number of results satisfying the query */ queryFeatureCount(query?: QueryProperties | null | undefined, options?: RequestOptions): Promise; /** * Executes a [Query](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/) against the feature service and returns a * [FeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) once the promise resolves. * A [FeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) contains an array of [features](https://developers.arcgis.com/javascript/latest/references/core/Graphic/). * See the [querying](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#querying) * section for more information on how to query features from a layer. * * > [!WARNING] * > * > **Notes** * > * > To query features available to or visible in the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) on the client rather than making a server-side query, you must * > use the [FeatureLayerView.queryFeatures()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#queryFeatures) method. * > * > When querying a service with z-values and no [vertical coordinate system](https://pro.arcgis.com/en/pro-app/help/mapping/properties/vertical-coordinate-systems.htm) information, * > the z-values will automatically be converted to match the [Query.outSpatialReference](https://developers.arcgis.com/javascript/latest/references/core/rest/support/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()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#queryFeatures) automatically converts the values from `feet` to `meter` units. * * @param 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. * @param options - An object with the following properties. * @returns When resolved, a [FeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) containing * an array of graphic features is returned. * @see [Sample - Query features from a FeatureLayer](https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query/) * @see [Query and filter guide](https://developers.arcgis.com/javascript/latest/query-filter/) * @example * // Queries for all the features matching the layer's configurations * // e.g. definitionExpression * layer.queryFeatures().then((results) => { * // prints the array of result graphics to the console * console.log(results.features); * }); * @example * const layer = new FeatureLayer({ * url: fsUrl // points to a Feature Service layer url * }); * * const query = new Query(); * query.where = "STATE_NAME = 'Washington'"; * query.outSpatialReference = { wkid: 102100 }; * query.returnGeometry = true; * query.outFields = [ "CITY_NAME" ]; * * layer.queryFeatures(query).then((results) => { * console.log(results.features); // prints the array of features to the console * }); * @example * // Get a query object for the layer's current configuration * 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((results) => { * // prints the array of result graphics to the console * console.log(results.features); * }); * @example * const layer = new FeatureLayer({ * url: fsUrl // points to a Feature Service layer url * }); * * // 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"] * }; * * const results = await layer.queryFeatures(query); * console.log(results.features); // prints the array of features to the console */ queryFeatures(query?: QueryProperties | null | undefined, options?: RequestOptions): Promise; /** * Executes a [Query](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/) against the feature 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. * * > [!WARNING] * > * > To query for ObjectIDs of features available to or visible in the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/) on the client rather * > than making a server-side query, you must use the * > [FeatureLayerView.queryObjectIds()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#queryObjectIds) method. * * @param 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. * @param options - An object with the following properties. * @returns When resolved, returns an array of numbers representing the object IDs of the features satisfying the query. * @see [Sample - Query Related Features](https://developers.arcgis.com/javascript/latest/sample-code/query-related-features/) * @example * // Queries for all the Object IDs of features matching the layer's configurations * // e.g. definitionExpression * layer.queryObjectIds().then((results) => { * // prints the array of Object IDs to the console * console.log(results); * }); * @example * const layer = new FeatureLayer({ * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3" * }); * * const query = new Query({ * where: "SUB_REGION = 'Pacific'" * }); * * const ids = await layer.queryObjectIds(query); * console.log(ids); // an array of object IDs */ queryObjectIds(query?: QueryProperties | null | undefined, options?: RequestOptions): Promise; /** * Executes a [RelationshipQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/RelationshipQuery/) against the feature service and * returns [FeatureSets](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) grouped by source layer or table objectIds. * * @param relationshipQuery - Specifies relationship parameters * for querying related features or records from a layer or a table. * @param options - An object with the following properties. * @returns When resolved, returns [FeatureSets](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) grouped * by source layer/table objectIds. Each [FeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) contains an array of [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) * features including the values of the fields requested by the user. * @since 4.9 * @see [relationships property](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#relationships) * @see [Sample - Query Related Features](https://developers.arcgis.com/javascript/latest/sample-code/query-related-features/) * @example * const objectIds = [385, 416]; * * // relationship query parameter * const query = { * outFields: ["*"], * relationshipId: relationshipId, * objectIds: objectIds * } * * // query related features for given objectIds * layer.queryRelatedFeatures(query).then(function (result) { * objectIds.forEach(function (objectId) { * // print out the attributes of related features if the result * // is returned for the specified objectId * if (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); * }); */ queryRelatedFeatures(relationshipQuery: RelationshipQueryProperties, options?: RequestOptions): Promise>; /** * Executes a [RelationshipQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/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. * * @param relationshipQuery - Specifies relationship parameters * for querying related features or records from a layer or a table. * @param options - An object with the following properties. * @returns When resolved, returns a hashmap containing key value pairs. Key in this case is the `objectId` * of the feature and value is the number of related features. * @since 4.17 * @see [relationships property](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#relationships) * @see [Sample - Query Related Features](https://developers.arcgis.com/javascript/latest/sample-code/query-related-features/) * @example * const objectIds = [385, 416]; * * // relationship query parameter * const query = { * outFields: ["*"], * relationshipId: relationshipId, * objectIds: objectIds * } * * // query related features for given objectIds * layer.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); * }); */ queryRelatedFeaturesCount(relationshipQuery: RelationshipQueryProperties, options?: RequestOptions): Promise>; /** * Executes a [TopFeaturesQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/) against a feature service and returns * the count of features or records that satisfy the query. * * > [!WARNING] * > * > **Known Limitations** * > * > Currently, the `queryTopFeatureCount` is only supported with server-side [FeatureLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/). * * @param topFeaturesQuery - Specifies the attributes, spatial, temporal, and top * filter of the query. The [TopFeaturesQuery.topFilter](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/#topFilter) parameter must be set. * @param options - An object with the following properties. * @returns When resolved, returns the number of features satisfying the query. * @since 4.20 * @see [Query and filter guide](https://developers.arcgis.com/javascript/latest/query-filter/) * @see [TopFeaturesQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/) * @see [TopFilter](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFilter/) * @example * // set the query to return a count * // of features that has most sales grouped by regions. * // top query will run against all features available in the service * const query = new TopFeaturesQuery({ * topFilter: new TopFilter({ * topCount: 1, * groupByFields: ["Region"], * orderByFields: ["Sales DESC"] * }) * }); * featureLayer.queryTopFeatureCount(query) * .then(function(response){ * // returns the number of the features that have the most sales by region. * }); */ queryTopFeatureCount(topFeaturesQuery?: TopFeaturesQueryProperties, options?: RequestOptions): Promise; /** * Executes a [TopFeaturesQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/) against a feature service and returns a * [FeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) once the promise resolves. * The [FeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) contains an array of top [features](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) * grouped and ordered by specified fields. For example, you can call this method to query top three counties grouped * by state names while ordering them based on their populations in a descending order. * * > [!WARNING] * > * > **Known Limitations** * > * > Currently, the `queryTopFeatures` is only supported with server-side [FeatureLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/). * * @param topFeaturesQuery - Specifies the attributes, spatial, temporal, and top * filter of the query. The [TopFeaturesQuery.topFilter](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/#topFilter) parameter must be set. * @param options - An object with the following properties. * @returns When resolved, returns a [FeatureSet](https://developers.arcgis.com/javascript/latest/references/core/rest/support/FeatureSet/) containing * an array of features that are grouped and ordered specified fields. * @since 4.20 * @see [Sample - Aggregate spatial statistics](https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query-aggregate/) * @see [Query and filter guide](https://developers.arcgis.com/javascript/latest/query-filter/) * @see [TopFeaturesQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/) * @see [TopFilter](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFilter/) * @example * // Query the most visited national parks in each state * // and order them by the most visited * // query will run against all features available in the service * const query = new TopFeaturesQuery({ * outFields: ["State, TOTAL, Park"], * topFilter: new TopFilter({ * topCount: 1, * groupByFields: ["State"], * orderByFields: ["TOTAL DESC"] * }) * }); * featureLayer.queryTopFeatures(query) * .then(function(response){ * // returns a feature set with features containing the most visited * // national park in each state ordered by the number of visits. * // The following attributes are returned as well: State, TOTAL, Park * }); */ queryTopFeatures(topFeaturesQuery: TopFeaturesQueryProperties, options?: RequestOptions): Promise; /** * Executes a [TopFeaturesQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/) against a feature service and returns * the [Extent](https://developers.arcgis.com/javascript/latest/references/core/geometry/Extent/) of features that satisfy the query. * * > [!WARNING] * > * > **Known Limitations** * > * > Currently, the `queryTopFeaturesExtent` is only supported with server-side [FeatureLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/). * * @param topFeaturesQuery - Specifies the attributes, spatial, temporal, and top * filter of the query. The [TopFeaturesQuery.topFilter](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/#topFilter) parameter must be set. * @param options - An object with the following properties. * @returns When resolved, returns the extent and count of the features * that satisfy the input query. See the object specification table below for details. * Property | Type | Description * ---------|------|------------- * count | Number | The number of features that satisfy the query. * extent | [Extent](https://developers.arcgis.com/javascript/latest/references/core/geometry/Extent/) \| null | The extent of features that satisfy the query. * @since 4.20 * @see [Query and filter guide](https://developers.arcgis.com/javascript/latest/query-filter/) * @see [TopFeaturesQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/) * @see [TopFilter](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFilter/) * @example * // Get the count and extent of the three highest magnitude earthquakes * // in each region. * const query = new TopFeaturesQuery({ * where: "mag >= 6", * geometry: studyExtent, * topFilter: new TopFilter({ * topCount: 3, * groupByFields: ["region"], * orderByFields: ["mag DESC"] * }) * }); * featureLayer.queryTopFeaturesExtent(query) * .then(function(response){ * // returns the count and extent of top three earthquakes within each region * }); */ queryTopFeaturesExtent(topFeaturesQuery?: TopFeaturesQueryProperties, options?: RequestOptions): Promise<{ count: number; extent: Extent | null; }>; /** * Executes a [TopFeaturesQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/) against a feature service and returns an * array of Object IDs of features that satisfy the query. * * > [!WARNING] * > * > **Known Limitations** * > * > Currently, the `queryTopObjectIds` is only supported with server-side [FeatureLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/). * * @param topFeaturesQuery - Specifies the attributes, spatial, temporal, and top * filter of the query. The [TopFeaturesQuery.topFilter](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/#topFilter) parameter must be set. * @param options - An object with the following properties. * @returns When resolved, returns an array of numbers representing the object IDs of features * satisfying the query. * @since 4.20 * @see [Query and filter guide](https://developers.arcgis.com/javascript/latest/query-filter/) * @see [TopFeaturesQuery](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFeaturesQuery/) * @see [TopFilter](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TopFilter/) * @example * // Get the objectIds top three earthquakes * // grouped by regions and ordered by their magnitude levels * // top query will only run against earthquakes that have mag >=6. * const query = new TopFeaturesQuery({ * where: "mag >= 6", * topFilter: new TopFilter({ * topCount: 3, * groupByFields: ["region"], * orderByFields: ["mag DESC"] * }) * }); * featureLayer.queryTopObjectIds(query) * .then(function(response){ * // returns an array of object ids of top three earthquakes within each region * }); */ queryTopObjectIds(topFeaturesQuery?: TopFeaturesQueryProperties, options?: RequestOptions): Promise; /** * Fetches all the data for the layer. The data is only updated if the `lastEditDate` in the layer's metadata is different from * the `lastEditDate` field. If the `lastEditDate` metadata info is not available, the FeatureLayer refreshes unconditionally. * * @since 4.6 * @see [refreshInterval](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#refreshInterval) * @see [refresh event](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#event-refresh) * @see [RefreshableLayer.refreshInterval](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/RefreshableLayer/#refreshInterval) * @see [refresh event](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/RefreshableLayer/#event-refresh) */ refresh(): void; /** * Saves the layer to its existing portal item in the [Portal](https://developers.arcgis.com/javascript/latest/references/core/portal/Portal/) * authenticated within the user's current session. If the layer is not saved to a * [PortalItem](https://developers.arcgis.com/javascript/latest/references/core/portal/PortalItem/), then you should use [saveAs()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#saveAs). * * > [!WARNING] * > * > **Known Limitations** * > * > You can only save service-backed FeatureLayers. Client-side layers cannot be saved. * * @param options - Various options for saving the layer. * @returns When resolved, returns the portal item to which the layer is saved. * @since 4.24 * @example const portalItem = await layer.save(); */ save(options?: LayerSaveOptions): Promise; /** * Saves the layer to a new portal item in the [Portal](https://developers.arcgis.com/javascript/latest/references/core/portal/Portal/) * authenticated within the user's current session. * * > [!WARNING] * > * > **Known Limitations** * > * > You can only save service-backed FeatureLayers. Client-side layers cannot be saved. * * @param portalItem - The portal item to which the layer will be saved. * @param options - Various options for saving the layer. * @returns When resolved, returns the portal item to which the layer is saved. * @since 4.24 * @example * const portalItem = new PortalItem(); * await layer.saveAs(portalItem); */ saveAs(portalItem: PortalItemProperties, options?: LayerSaveAsOptions): Promise; /** * Updates an existing attachment for a feature. This operation is available only if the layer's * [capabilities.data.supportsAttachment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) is set to `true`. * * @param feature - The feature containing the attachment to be updated. * @param attachmentId - Id of the attachment to be updated. * @param attachment - HTML form that contains a file upload field pointing to the file to be added as an attachment. * @returns When resolved, a [FeatureEditResult](https://developers.arcgis.com/javascript/latest/references/core/editing/types/#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`. * @since 4.9 * @see [capabilities.data.supportsAttachment](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#capabilities) */ updateAttachment(feature: Graphic, attachmentId: number, attachment: HTMLFormElement | FormData): Promise; } declare const FeatureLayerSuperclass: typeof Layer & typeof ClonableMixin & typeof APIKeyMixin & typeof CustomParametersMixin & typeof MultiOriginJSONSupportMixin & typeof PortalLayer & typeof OperationalLayer & typeof RefreshableLayer & typeof ScaleRangeLayer & typeof TrackableLayer & typeof TemporalLayer & typeof OrderedLayer & typeof BlendLayer & typeof DisplayFilteredLayer & typeof EditBusLayer & typeof PublishableLayer & typeof FeatureEffectLayer & typeof FeatureReductionLayer & typeof FeatureLayerBase