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
| Property | Type | Class |
|---|---|---|
capabilities readonly | | |
| | ||
| | ||
datesInUnknownTimezone readonly | | |
| | ||
| | ||
editFieldsInfo readonly | | |
editingInfo readonly | EditingInfo | null | undefined | |
effectiveCapabilities readonly | | |
effectiveEditingEnabled readonly | | |
| | ||
fieldsIndex readonly | | |
| | ||
| | ||
| | ||
geometryFieldsInfo readonly | | |
"point" | "polygon" | "polyline" | "multipoint" | "multipatch" | "mesh" | | |
| | ||
| | ||
| | ||
| | ||
isTable readonly | | |
| | ||
| | ||
preferredTimeZone readonly | | |
relationships readonly | Relationship[] | null | undefined | |
| | ||
| | ||
serviceDefinitionExpression readonly | | |
serviceItemId readonly | | |
| | ||
| | ||
subtypeField readonly | | |
subtypes readonly | | |
| | ||
| | ||
version readonly | |
capabilities
Describes the layer's supported capabilities.
Example
// Once the layer loads, check if the// supportsAdd operations is enabled on the layerawait featureLayer.load();if (featureLayer.capabilities.operations.supportsAdd) { // if new features can be created in the layer // set up the UI for editing setupEditing();} dateFieldsTimeZone
- 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.
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
- 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
datesInUnknownTimezoneis true. The layer's editingEnabled property will be set tofalse. - When setting
timeExtentin 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 usinglayer.timeInfo.fullTimeExtentin conjunction with TimeSlider, the local timezone offset must be removed. See the code snippet below.
- Default value
- false
Examples
// Only download data for the year 2020.// if the layer supports unknown time zone then create// the dates in UTCif (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 timezoneif (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 datesfunction removeLocalOffset(localTime) { return new Date( localTime.getUTCFullYear(), localTime.getUTCMonth(), localTime.getUTCDate(), localTime.getUTCHours(), localTime.getUTCMinutes(), localTime.getUTCSeconds(), localTime.getUTCMilliseconds() );} definitionExpression
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 pumilaconst 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 50ftlayer.definitionExpression = "HEIGHT > 50"; editFieldsInfo
- 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
- Type
- EditingInfo | null | undefined
Specifies information about editing.
effectiveCapabilities
- 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
- 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
- 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
- Type
- FieldsIndex<Field>
A convenient property that can be used to make case-insensitive lookups for a field by name. It can also provide a list of the date fields in a layer.
Example
// lookup a field by name. name is case-insensitiveconst field = layer.fieldsIndex.get("SoMeFiEld");
if (field) { console.log(field.name); // SomeField} floorInfo
- 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.
gdbVersion
The version of the geodatabase of the feature service data. Read the Overview of versioning topic for more details about this capability.
geometryFieldsInfo
- Type
- GeometryFieldsInfo | null | undefined
Provides information on the system maintained area and length fields along with their respective units.
- See also
geometryType
- 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.
hasM
- 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
- 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.
isTable
- 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.
- Default value
- false
layerId
- 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 Itemconst layer = new FeatureLayer({ portalItem: { id: "8d26f04f31f642b6828b7023b84c2188" }, layerId: 2});// If not specified, the first layer (layerId: 0) will be returnedconst layer = new FeatureLayer({ portalItem: { id: "8d26f04f31f642b6828b7023b84c2188" }});// Can also be used if URL points to service and not layerconst 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 snippetconst 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
- 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.
Example
// See the sample snippet for the source and fields propertiesconst layer = new FeatureLayer({ source: features, fields: fields, objectIdField: "ObjectID", // field name of the Object IDs geometryType: "point", renderer: <renderer>}); relationships
- 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.
Example
// print out layer's relationship length and each relationship info to consolelayer.when(function () { console.log("layer relationships", layer.relationships.length);
layer.relationships.forEach(function (relationship) { console.log("relationship id:", relationship.id) console.log("relationship cardinality:", relationship.cardinality) console.log("relationship key field:", relationship.keyField) console.log("relationship name:", relationship.name) console.log("relationship relatedTableId:", relationship.relatedTableId) });}); serviceDefinitionExpression
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'".
sourceJSON
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
- Type
- SpatialReference
subtypes
An array of subtypes defined in the layer.
- See also
title
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
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 Onlinelayer.url = "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/origins/FeatureServer/0";// Layer from Map Service on ArcGIS Serverlayer.url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2";// Can also be used if URL points to service and not layerconst 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.});Methods
| Method | Signature | Class |
|---|---|---|
getField(fieldName: string): Field | null | undefined | | |
getFieldDomain(fieldName: string, options?: FieldDomainOptions): DomainUnion | null | undefined | |
getField
- Signature
-
getField (fieldName: string): Field | null | undefined
Returns the Field instance for a field name (case-insensitive).
- See also
getFieldDomain
- 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
| Parameter | Type | Description | Required |
|---|---|---|---|
| fieldName | Name of the field. | | |
| options | An object specifying additional options. See the object specification table below for the required properties of this object. | |
- Returns
- DomainUnion | null | undefined
The Domain object associated with the given field name for the given feature.
Example
// Get a range domain associated with the first feature// returned from queryFeatures().layer.queryFeatures(query).then(function(results){ const domain = layer.getFieldDomain("Height", {feature: results.features[0]}); console.log("domain", domain)});