Skip to content
Types
import type { FeatureLayerBase } from "@arcgis/core/layers/mixins/FeatureLayerBase.js";
Subclasses:
CatalogLayer, FeatureLayer, SubtypeGroupLayer
Since
ArcGIS Maps SDK for JavaScript 4.25

FeatureLayerBase is a mixin that adds common properties and methods to FeatureLayer, SubtypeGroupLayer and CatalogLayer.

Properties

PropertyTypeClass
capabilities
readonly
editFieldsInfo
readonly
editingInfo
readonly
fieldsIndex
readonly
"point" | "polygon" | "polyline" | "multipoint" | "multipatch" | "mesh"
isTable
readonly
relationships
readonly
serviceItemId
readonly
subtypeField
readonly
subtypes
readonly
url
version
readonly

capabilities

readonly Property
Type
FeatureLayerCapabilities

Describes the layer's supported capabilities.

Example
// Once the layer loads, check if the
// supportsAdd operations is enabled on the layer
await featureLayer.load();
if (featureLayer.capabilities.operations.supportsAdd) {
// if new features can be created in the layer
// set up the UI for editing
setupEditing();
}
Property
Type
string | null | undefined

Copyright information for the layer.

dateFieldsTimeZone

Property
Type
TimeZone | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.28

The time zone that dates are stored in. This property does not apply to date fields referenced by timeInfo or editFieldsInfo.

Even though dates are transmitted as UTC epoch values, this property may be useful when constructing date or time where clauses for querying. If constructing date or time where clauses, use FieldsIndex.getTimeZone() to get the time zone for the given date field.

Set this property in the layer constructor if you are creating client-side feature layers to indicate the time zone of the date fields. The date field must exist in the layer's fields array for client-side feature layers if the dateFieldsTimeZone is specified.

See also
Example
const layer = new FeatureLayer({
// layer's fields definition
fields: [
{
name: "ObjectID",
alias: "ObjectID",
type: "oid"
}, {
name: "type",
alias: "Type",
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
});
map.add(layer);

datesInUnknownTimezone

readonly Property
Type
boolean

This property is set by the service publisher and indicates that dates should be considered without the local timezone. This applies to both requests and responses.

Known Limitations

  • This capability is only available with services published with ArcGIS Enterprise 10.9 or greater.
  • Editing is not supported for FeatureLayers if datesInUnknownTimezone is true. The layer's editingEnabled property will be set to false.
  • When setting timeExtent in a Query, the layer view's filter.timeExtent or layer's timeExtent, dates must be defined in terms of UTC as illustrated in the code below. When using layer.timeInfo.fullTimeExtent in conjunction with TimeSlider, the local timezone offset must be removed. See the code snippet below.
See also
Default value
false
Examples
// Only download data for the year 2020.
// if the layer supports unknown time zone then create
// the dates in UTC
if (layer.datesInUnknownTimezone) {
layer.timeExtent = new TimeExtent({
start: new Date(Date.UTC(2020, 0, 1)),
end: new Date(Date.UTC(2021, 0, 1))
});
}
else {
layer.timeExtent = new TimeExtent({
start: new Date(2020, 0, 1),
end: new Date(2021, 0, 1)
});
}
// set up the timeslider for a service with an unknown timezone
if (layer.datesInUnknownTimezone) {
const timeSlider = new TimeSlider({
view: view,
container: "timeSliderDiv",
timeVisible: true,
});
view.ui.add(timeSlider, "bottom-left");
view.whenLayerView(layer).then((layerView) => {
// get the layer's fullTimeExtent and remove the local
// time zone offset
const timExtent = new TimeExtent({
start: removeLocalOffset(layer.timeInfo.fullTimeExtent.start),
end: removeLocalOffset(layer.timeInfo.fullTimeExtent.end)
});
timeSlider.fullTimeExtent = timExtent;
timeSlider.stops = {
interval: layer.timeInfo.interval;
};
});
}
// Remove the local time zone offset from dates
function removeLocalOffset(localTime) {
return new Date(
localTime.getUTCFullYear(),
localTime.getUTCMonth(),
localTime.getUTCDate(),
localTime.getUTCHours(),
localTime.getUTCMinutes(),
localTime.getUTCSeconds(),
localTime.getUTCMilliseconds()
);
}

definitionExpression

Property
Type
string | null | undefined

The SQL where clause used to filter features on the client. Only the features that satisfy the definition expression are displayed in the View. Setting a definition expression is useful when the dataset is large and you don't want to bring all features to the client for analysis. Definition expressions may be set when a layer is constructed prior to it loading in the view or after it has been added to the map. If the definition expression is set after the layer has been added to the map, the view will automatically refresh itself to display the features that satisfy the new definition expression.

Examples
// Set definition expression in constructor to only display trees with scientific name Ulmus pumila
const layer = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0",
definitionExpression: "Sci_Name = 'Ulmus pumila'"
});
// Set the definition expression directly on layer instance to only display trees taller than 50ft
layer.definitionExpression = "HEIGHT > 50";

displayField

Property
Type
string | null | undefined

The name of the layer's primary display field. The value of this property matches the name of one of the fields of the layer.

editFieldsInfo

readonly Property
Type
EditFieldsInfo | null | undefined

The editor tracking fields, which record who adds or edits the data through the feature service and when edits are made.

editingInfo

readonly Property
Type
EditingInfo | null | undefined

Specifies information about editing.

effectiveCapabilities

readonly Property
Type
FeatureLayerCapabilities | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.26

Describes effective capabilities of the layer taking in to consideration privileges of the currently signed-in user.

effectiveEditingEnabled

readonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.26

Indicates whether the layer is editable taking in to consideration privileges of the currently signed-in user.

elevationInfo

autocast Property
Type
ElevationInfo | null | undefined

Specifies how features are placed on the vertical axis (z). This property may only be used in a SceneView. See the ElevationInfo sample for an example of how this property may be used.

If the elevation info is not specified, the effective elevation depends on the context and could vary per graphic.

fieldsIndex

readonly Property
Type
FieldsIndex<Field>

A convenient property that can be used to make case-insensitive lookups for a field by name. It can also provide a list of the date fields in a layer.

Example
// lookup a field by name. name is case-insensitive
const field = layer.fieldsIndex.get("SoMeFiEld");
if (field) {
console.log(field.name); // SomeField
}

floorInfo

autocast Property
Type
LayerFloorInfo | null | undefined

When a feature layer is configured as floor-aware, it has a floorInfo property defined. A floor-aware layer is a layer that contains indoor GIS data representing features that can be located on a specific floor of a building.

fullExtent

autocast Property
Type
Extent | null | undefined

The full extent of the layer.

gdbVersion

Property
Type
string | null | undefined

The version of the geodatabase of the feature service data. Read the Overview of versioning topic for more details about this capability.

geometryFieldsInfo

readonly Property
Type
GeometryFieldsInfo | null | undefined

Provides information on the system maintained area and length fields along with their respective units.

See also

geometryType

Property
Type
"point" | "polygon" | "polyline" | "multipoint" | "multipatch" | "mesh"

The geometry type of features in the layer. All features must be of the same type. This property is read-only when the layer is created from a url.

When creating a FeatureLayer from client-side features, this property is inferred by the geometryType of the features provided in the layer's source property. If the layer's source is an empty array at the time of initialization, this property must be set.

See also

globalIdField

Property
Type
string | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.33

The name of a gid field containing a globally unique identifier for each feature in the layer. This may be null or undefined if the layer does not have a globally unique identifier field.

See also

hasM

Property
Type
boolean

Indicates whether the client-side features in the layer have M (measurement) values. Use the supportsM property in the FeatureLayer's capabilities.data object to verify if M values are supported on feature service features.

hasZ

Property
Type
boolean

Indicates whether the client-side features in the layer have Z (elevation) values. Refer to elevationInfo for details regarding placement and rendering of features with z-values in 3D SceneViews. Use the supportsZ property in the FeatureLayer's capabilities.data object to verify if Z values are supported on feature service features.

historicMoment

autocast Property
Type
Date | null | undefined

The historic moment to query. If historicMoment is not specified, the query will apply to the current features.

isTable

readonly Property
Type
boolean

Returns true if the layer is loaded from a non-spatial table in a service. Non-spatial tables do not have a spatial column that represent geographic features.

See also
Default value
false

layerId

Property
Type
number

The layer ID, or layer index, of a Feature Service layer. This is particularly useful when loading a single feature layer with the portalItem property from a service containing multiple layers. You can specify this value in one of two scenarios:

  • When loading the layer via the portalItem property.
  • When pointing the layer's url directly to a feature service.

If a layerId is not specified in either of the above scenarios, then the first layer in the service (layerId = 0) is selected.

Examples
// loads the third layer in the given Portal Item
const layer = new FeatureLayer({
portalItem: {
id: "8d26f04f31f642b6828b7023b84c2188"
},
layerId: 2
});
// If not specified, the first layer (layerId: 0) will be returned
const layer = new FeatureLayer({
portalItem: {
id: "8d26f04f31f642b6828b7023b84c2188"
}
});
// Can also be used if URL points to service and not layer
const layer = new FeatureLayer({
// Notice that the url doesn't end with /2
url: "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer",
layerId: 2
});
// This code returns the same layer as the previous snippet
const layer = new FeatureLayer({
// The layer id is specified in the URL
url: "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer/2",
});

objectIdField

Property
Type
string

The name of the object id Field containing a unique identifier for each feature in the layer. The object id field for a FeatureLayer can contain either numeric or string values. Some feature layers use one or more unique id fields to uniquely identify features. Due to the complexity of object ids and unique ids, it is strongly recommended to use Graphic.getObjectId() method to obtain a feature's unique identifier.

If this property is not defined when creating a client-side feature layer, the object-id field will be automatically inferred from the layer's fields array.

See also
Example
// See the sample snippet for the source and fields properties
const layer = new FeatureLayer({
source: features,
fields: fields,
objectIdField: "ObjectID", // field name of the Object IDs
geometryType: "point",
renderer: <renderer>
});

preferredTimeZone

readonly Property
Type
TimeZone | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.28

The IANA time zone the author of the service intended data from date fields to be viewed in.

relationships

readonly Property
Type
Relationship[] | null | undefined

Array of relationships set up for the layer. Each object in the array describes the layer's Relationship with another layer or table.

See also
Example
// print out layer's relationship length and each relationship info to console
layer.when(function () {
console.log("layer relationships", layer.relationships.length);
layer.relationships.forEach(function (relationship) {
console.log("relationship id:", relationship.id)
console.log("relationship cardinality:", relationship.cardinality)
console.log("relationship key field:", relationship.keyField)
console.log("relationship name:", relationship.name)
console.log("relationship relatedTableId:", relationship.relatedTableId)
});
});

returnM

Property
Type
boolean | null | undefined

When true, indicates that M values will be returned. When false, indicates that M values will never be returned. The layer view determines whether to include M values in feature queries when the property value is undefined.

returnZ

Property
Type
boolean | null | undefined

When true, indicates that z-values will always be returned. When false, indicates that z-values will never be returned. The layer view determines whether to include z-values in feature queries when the property value is undefined.

serviceDefinitionExpression

readonly Property
Type
string | null | undefined

The service definition expression limits the features available for display and query. You can define additional filters on the layer in addition to the service definition expression by setting layer's definitionExpression. For example, if the service definition expression is set to display data where "STATE_NAME = 'California'" you could use definitionExpression to only display a subset of the features in California, for example using "COUNTY='San Diego'".

See also

serviceItemId

readonly Property
Type
string | null | undefined
Since
ArcGIS Maps SDK for JavaScript 5.0

Indicates the portal item of the hosted feature service that contains this layer.

sourceJSON

Property
Type
Record<string, any> | null | undefined

The feature service's metadata JSON exposed by the ArcGIS REST API. While most commonly used properties are exposed on the FeatureLayer class directly, this property gives access to all information returned by the feature service. This property is useful if working in an application built using an older version of the API which requires access to feature service properties from a more recent version.

spatialReference

autocast Property
Type
SpatialReference

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

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

subtypeField

readonly Property
Type
string

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

subtypes

readonly Property
Type
Subtype[] | null | undefined

An array of subtypes defined in the layer.

See also

title

Property
Type
string | null | undefined

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

When loading a layer by service url, the title is derived from the service name. If the service has several layers, then the title of each layer will be the concatenation of the service name and the layer name. When the layer is loaded from a portal item, the title of the portal item will be used instead. Finally, if a layer is loaded as part of a webmap or a webscene, then the title of the layer as stored in the webmap/webscene will be used.

url

Property
Type
string | null | undefined

The absolute URL of the REST endpoint of the layer, non-spatial table or service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online.

If the url points directly to a service, then the layer must be specified in the layerId property. If no layerId is given, then the first layer in the service will be loaded.

Examples
// Hosted Feature Service on ArcGIS Online
layer.url = "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/origins/FeatureServer/0";
// Layer from Map Service on ArcGIS Server
layer.url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2";
// Can also be used if URL points to service and not layer
const layer = new FeatureLayer({
// Notice that the url doesn't end with /2
url: "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer",
layerId: 2
});
// Non-spatial table in San Francisco incidents service.
const table = new FeatureLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/1"
});
// table must be loaded so it can be used in the app.
table.load().then(function() {
// table is loaded. ready to be queried.
});

version

readonly Property
Type
number | null | undefined

The version of ArcGIS Server in which the layer is published.

Example
// Prints the version number to the console - e.g. 10.91, 11.2, 11.3.
console.log(layer.version);

Methods

MethodSignatureClass
getField(fieldName: string): Field | null | undefined
getFieldDomain(fieldName: string, options?: FieldDomainOptions): DomainUnion | null | undefined

getField

Method
Signature
getField (fieldName: string): Field | null | undefined

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

See also
Parameters
ParameterTypeDescriptionRequired
fieldName

Name of the field.

Returns
Field | null | undefined

the matching field or undefined

getFieldDomain

Method
Signature
getFieldDomain (fieldName: string, options?: FieldDomainOptions): DomainUnion | null | undefined

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

Parameters
ParameterTypeDescriptionRequired
fieldName

Name of the field.

options

An object specifying additional options. See the object specification table below for the required properties of this object.

Returns
DomainUnion | null | undefined

The Domain object associated with the given field name for the given feature.

Example
// Get a range domain associated with the first feature
// returned from queryFeatures().
layer.queryFeatures(query).then(function(results){
const domain = layer.getFieldDomain("Height", {feature: results.features[0]});
console.log("domain", domain)
});