require(["esri/rest/featureService/FeatureService"], (FeatureService) => { /* code goes here */ });
import FeatureService from "@arcgis/core/rest/featureService/FeatureService.js";
esri/rest/featureService/FeatureService
This class contains metadata about the feature service. The class can be constructed via a url to a feature service or from the class utils using the createFeatureServices() method.
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Examples// Create a FeatureService from a url const featureService = new FeatureService({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer" });
// Create a FeatureService using createFeatureServices() const layer1 = new FeatureLayer({url: `https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/12`}); const layer2 = new FeatureLayer({url: `https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer/13`}); const layers = [layer1, layer2]; const mapOfServices = createFeatureServices(layers); //loading featureService from map object. const featureService = await mapOfServices.get(`https://sampleserver6.arcgisonline.com/arcgis/rest/services/TestService/FeatureServer`).featureService.load();
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
Describes the layer's supported capabilities. | FeatureService | ||
Describes effective capabilities of the service taking in to consideration privileges of the currently signed-in user. | effectiveCapabilities | ||
Contains info of all layers in the Feature Service. | FeatureService | ||
Indicates whether the instance has loaded. | FeatureService | ||
The Error object returned if an error occurred while loading. | FeatureService | ||
Represents the status of a load operation. | FeatureService | ||
Contains info of all tables in the Feature Service. | FeatureService | ||
The absolute URL of the REST endpoint for the feature service. | FeatureService | ||
Describes the service's userTypeExtensions. | FeatureService | ||
The url that points to the utility network layer, if it exists. | FeatureService | ||
The url to the version management service, if the data is versioned. | FeatureService |
Property Details
-
capabilities
capabilities Capabilities
-
Describes the layer's supported capabilities.
-
effectiveCapabilities
effectiveCapabilities Capabilitiesinner,readonly
Since: ArcGIS Maps SDK for JavaScript 4.30effectiveCapabilities since 4.28, effectiveCapabilities added at 4.30. -
Describes effective capabilities of the service taking in to consideration privileges of the currently signed-in user.
-
loadError
loadError Errorreadonly
-
The Error object returned if an error occurred while loading.
- Default Value:null
-
loadStatus
loadStatus Stringreadonly
-
Represents the status of a load operation.
Value Description not-loaded The object's resources have not loaded. loading The object's resources are currently loading. loaded The object's resources have loaded without errors. failed The object's resources failed to load. See loadError for more details. Possible Values:"not-loaded" |"loading" |"failed" |"loaded"
- Default Value:not-loaded
-
url
url String
-
The absolute URL of the REST endpoint for the feature service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online.
-
userTypeExtensions
userTypeExtensions String
-
Describes the service's userTypeExtensions.
-
utilityNetworkUrl
utilityNetworkUrl Stringreadonly
-
The url that points to the utility network layer, if it exists.
-
versionManagementServiceUrl
versionManagementServiceUrl Stringreadonly
-
The url to the version management service, if the data is versioned.
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Applies edits to features in the feature service layers. | FeatureService | ||
Triggers the loading of the feature service instance and fetches all layers and tables. | FeatureService | ||
Triggers the loading of the feature service instance. | FeatureService |
Method Details
-
applyEdits
applyEdits(edits, options){Promise<ServiceEditsResult[]>}
-
Applies edits to features in the feature service layers. 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.
When calling the applyEdits method on a service that does not have vertical coordinate system information, the z-values of the geometries in the
edits
object will automatically be converted to match the spatial reference of the layer. Example: The service has a horizontal spatial reference withfeet
units, andapplyEdits()
is called with z-values based onmeter
units, then the method will automatically convert the z values frommeter
tofeet
units.applyEdits()
will pass in asessionId
during an active edit session.ParametersSpecificationObject containing features and attachments to be added, updated or deleted.
Specificationid NumberSpecifies the layer id of the layer that needs to be edited.
identifierFields ObjectaddFeatures Graphic[]|Collection<Graphic>optionalAn array or a collection of features to be added. Values of non nullable fields must be provided when adding new features. Date fields must have numeric values representing universal time.
updateFeatures Graphic[]|Collection<Graphic>optionalAn array or a collection of features to be updated. Each feature must have valid objectId. Values of non nullable fields must be provided when updating features. Date fields must have numeric values representing universal time.
optional An array or a collection of features, or an array of objects with
objectId
orglobalId
of each feature to be deleted. When an array or collection of features is passed, each feature must have a valid objectId. When an array of objects is used, each object must have a valid value set forobjectId
orglobalId
property.addAttachments AttachmentEdit[]optionalAn array of attachments to be added. Applies only when the
options.globalIdUsed
parameter is set totrue
. User must provide globalIds for all attachments to be added.updateAttachments AttachmentEdit[]optionalAn array of attachments to be updated. Applies only when the
options.globalIdUsed
parameter is set totrue
. User must provide globalIds for all attachments to be updated.optional An array of globalIds for attachments to be deleted. Applies only when the
options.globalIdUsed
parameter is set totrue
.options ObjectoptionalAdditional edit options to specify when editing features or attachments.
SpecificationgdbVersion StringoptionalThe geodatabase version to apply the edits. This parameter applies only if the capabilities.data.isVersioned property of the layer is
true
.globalIdUsed BooleanoptionalIndicates whether the edits can be applied using globalIds of features or attachments. This parameter applies only if the layer's capabilities.editing.supportsGlobalId property is
true
. Whenfalse
, globalIds submitted with the features are ignored and the service assigns new globalIds to the new features. Whentrue
, the globalIds must be submitted with the new features. When updating existing features, if theglobalIdUsed
isfalse
, the objectIds of the features to be updated must be provided. If theglobalIdUsed
istrue
, globalIds of features to be updated must be provided. When deleting existing features, set this property tofalse
as deletes operation only acceptsobjectIds
at the current version of the API.When adding, updating or deleting attachments,
globalIdUsed
parameter must be set totrue
and the attachment globalId must be set. For new attachments, the user must provide globalIds. In order for an attachment to be updated or deleted, clients must include its globalId. Attachments are not supported in an edit payload whenglobalIdUsed
isfalse
.honorSequenceOfEdits BooleanoptionalAdded at 10.5 and works with ArcGIS Server services only. This parameter specifies whether to apply edits in the order they are submitted in the JSON. If true, edits will apply in the submitted order. If false, which is the default, edits will apply in ascending layer-ID order. All the edits for the layer with the lowest ID will apply first.
usePreviousEditMoment BooleanoptionalThis option was added at 10.6. This is set by a client during long transaction editing on a branch version. This parameter is used to apply the edits with the same edit moment as the previous set of edits. This allows an editor to apply a single block of edits partially, complete another task, and then complete the block of edits. When set to true, the edits are applied with the same edit moment as the previous sets of edits. When set to false the edits are applied with a new edit moment. By default, this parameter is set to false.
ReturnsType Description Promise<ServiceEditsResult[]> - Results returned from the applyEdits method. It contains features that were added, deleted or updated in different feature layers. It also contains the edit moment.
ExamplefeatureService.applyEdits( [ { id: 1, // layer id of the layer in the feature service identifierFields: { globalIdField: "GLOBALID", objectIdField: "OBJECTID" }, addFeatures: [ new Graphic({ geometry: new Point({ x: -13293155.7588, y: 4038940.6944999993, z: 0, spatialReference: { wkid: 102100, latestWkid: 3857, xyTolerance: 0.001, zTolerance: 0.001, mTolerance: 0.001, falseX: -20037700, falseY: -30241100, xyUnits: 10000, falseZ: -100000, zUnits: 10000, falseM: -100000, mUnits: 10000 } }), attributes: { objectid: 3, name: "test", globalid: "{8E17A611-B139-46E4-A645-AC50A1DD2CCE}", created_user: "unadmin", created_date: 1694024410000, last_edited_user: "unadmin", last_edited_date: 1694024410000 } })) ] } ], { gdbVersion: "user.versionName", globalIdUsed: false, honorSequenceOfEdits: false, usePreviousEditMoment: false } );
-
fetchAllLayersAndTables
fetchAllLayersAndTables(){Promise<ServiceContents>}
-
Triggers the loading of the feature service instance and fetches all layers and tables.
Fully loads the Feature Service definition.
ReturnsType Description Promise<ServiceContents> Resolves when the Feature Service is loaded.
-
load
load(){Promise}
-
Triggers the loading of the feature service instance.
Fully loads the Feature Service definition.
Returns
Type Definitions
-
Capabilities
Capabilities Object
-
Describes the layer's supported capabilities.
- Properties
-
data Object
Describes characteristics of the data in the service.
- Specification
-
isVersioned Boolean
Indicates if the feature service is versioned.
editing ObjectDescribes editing capabilities that can be performed on the features in the layer via applyEdits().
- Specification
-
supportsGlobalId Boolean
Indicates if the
globalId
values provided by the client are used in applyEdits.supportsReturnServiceEditsInSourceSpatialReference BooleanIndicates that the service supports returning edits in the source spatial reference of the layer they belong to.
supportsAsyncApplyEdits BooleanIndicates if the service supports async apply edits.
supportsSplit BooleanIndicates whether the service supports splitting features.
operations ObjectDescribes operations that can be performed on features in the layer.
- Specification
-
supportsAdd Boolean
Indicates if new features can be added to the service.
supportsChangeTracking BooleanIndicates whether the service supports change tracking for features.
supportsDelete BooleanIndicates if features can be deleted from the service.
supportsEditing BooleanIndicates if features in the service can be edited. Use
supportsAdd
,supportsUpdate
andsupportsDelete
to determine which editing operations are supported.supportsQuery BooleanIndicates if features in the service can be queried.
supportsQueryDataElements BooleanIndicates whether the service supports querying data elements.
supportsQueryDomains BooleanIndicates whether the service supports querying domains.
supportsQueryContingentValues BooleanIndicates whether the service supports querying contingent values.
supportsSync BooleanIndicates whether the service supports synchronization.
supportsUpdate BooleanIndicates whether the service supports updating features.
query ObjectDescribes query operations that can be performed on the Feature Service.
sync ObjectDescribes the synchronization capabilities of a service.
- Properties
-
supportsAsync Boolean
Indicates whether the service supports asynchronous synchronization.
supportedSyncDataOptions BooleanIndicates the supported sync data options for the service
- Specification
-
annotations Boolean
Indicates whether annotations should be included in the sync data.
dimensions BooleanIndicates whether dimensions should be included in the sync data.
contingentValues BooleanIndicates whether contingent values should be included in the sync data.
attributeRules BooleanIndicates whether attribute rules should be included in the sync data.
utilityNetworkSystem BooleanIndicates whether the utility network system should be included in the sync data.
annotationFullModel BooleanIndicates whether the full annotation model should be included in the sync data.
include3DObjects BooleanIndicates whether 3D objects should be included in the sync data.
utilityNetworkMissingLayers BooleanIndicates whether missing utility network layers should be included in the sync data.
preserveTrueCurves BooleanIndicates whether true curves should be preserved in the sync data.
-
LayerInfo
LayerInfo Object
Since: ArcGIS Maps SDK for JavaScript 4.30FeatureService since 4.28, LayerInfo added at 4.30. -
Contains information for a layer in the Feature Service.
-
ServiceContents
ServiceContents Object
Since: ArcGIS Maps SDK for JavaScript 4.30FeatureService since 4.28, ServiceContents added at 4.30. -
Contains information returned from the service containing layerInfos, tableInfos, and server capabilities.
- Properties
-
Contains the Layer Definition of a layer.
- Specification
-
capabilities Capabilities
The capabilities of a layer in the Feature Service.
layerInfos LayerInfoContains information for a layer in the Feature Service.
Contains the Table Definition of a layer.
- Specification
-
capabilities Capabilities
The capabilities of a table in the Feature Service.
tableInfos TableInfoContains information for a table in the Feature Service.
-
ServiceEditsResult
ServiceEditsResult Object
-
Results returned from the applyEdits method. It contains features that were added, deleted or updated in different feature layers. It also contains the edit moment.
- Properties
-
id Number
The layerId of the feature layer where features were edited.
Results returned from an add operation.
Results returned from an update operation.
Results returned from a delete operation.
Results returned from an add attachments operation.
Results returned from an update attachments operation.
Results returned from a delete attachments operation.
optional Object containing all edited features belonging to the specified layer.
editMoment NumberReturns the editMoment of an edit.
-
TableInfo
TableInfo Object
Since: ArcGIS Maps SDK for JavaScript 4.30FeatureService since 4.28, TableInfo added at 4.30. -
Contains information for a table in the Feature Service.