import FeatureService from "@arcgis/core/rest/featureService/FeatureService.js";
const FeatureService = await $arcgis.import("@arcgis/core/rest/featureService/FeatureService.js");
@arcgis/core/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 | ||
The Error object returned if an error occurred while loading. | FeatureService | ||
Represents the status of a load operation. | FeatureService | ||
A list of warnings which occurred while loading. | FeatureService | ||
Indicates whether the instance has loaded. | 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
Propertycapabilities Capabilities |null |undefinedreadonly -
Describes the layer's supported capabilities.
-
effectiveCapabilities
PropertyeffectiveCapabilities Capabilities |null |undefinedinner,readonlySince: 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.
-
The Error object returned if an error occurred while loading.
- Default Value:null
-
loadStatus
PropertyloadStatus 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"
-
A list of warnings which occurred while loading.
-
url
Propertyurl 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.
-
The url that points to the utility network layer, if it exists.
-
The url to the version management service, if the data is versioned.
Method Overview
| Name | Return Type | Summary | Class |
|---|---|---|---|
Promise<ServiceEditsResult[]> | Applies edits to features in the feature service layers. | FeatureService | |
Cancels a load() operation if it is already in progress. | FeatureService | ||
Promise<ServiceContents> | Triggers the loading of the feature service instance and fetches all layers and tables. | FeatureService | |
| FeatureService | ||
| FeatureService | ||
| FeatureService | ||
Promise | Loads the resources referenced by this class. | FeatureService | |
Promise | Triggers the loading of the feature service instance. | FeatureService | |
Promise |
| FeatureService |
Method Details
-
applyEdits
MethodapplyEdits(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
editsobject will automatically be converted to match the spatial reference of the layer. Example: The service has a horizontal spatial reference withfeetunits, andapplyEdits()is called with z-values based onmeterunits, then the method will automatically convert the z values frommetertofeetunits.applyEdits()will pass in asessionIdduring an active edit session.The
deleteAssociations,combineGroupedObjects, anddivideGroupedObjectsedits are in beta and are reserved for future use in a telecom domain network.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 ObjectoptionaladdFeatures 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
objectIdorglobalIdof 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 forobjectIdorglobalIdproperty.deleteAssociations DeleteAssociationEdit[]optionalAn array of objects specifying traditional or foreign-key associations to delete. To delete associations with
deleteAssociations, all "from" and "to" properties must be specified in the DeleteAssociationEdit object.combineGroupedObjects CombineGroupedObjectsEdit[]optionalAn array of objects specifying grouped objects to combine in a telecom domain network. The objects being combined must have consecutive unit IDs, exist in the same table and unit container, and have the same attribute values.
divideGroupedObjects DivideGroupedObjectsEdit[]optionalAn array of objects specifying a grouped objects to divide, and the units to divide the objects into, in a telecom domain network.
addAttachments AttachmentEdit[]optionalAn array of attachments to be added. Applies only when the
options.globalIdUsedparameter 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.globalIdUsedparameter 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.globalIdUsedparameter 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.isDataVersioned 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 theglobalIdUsedisfalse, the objectIds of the features to be updated must be provided. If theglobalIdUsedistrue, globalIds of features to be updated must be provided. When deleting existing features, set this property tofalseas deletes operation only acceptsobjectIdsat the current version of the API.When adding, updating or deleting attachments,
globalIdUsedparameter must be set totrueand 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 whenglobalIdUsedisfalse.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.
trueCurveClient BooleanoptionalIndicates to the server whether the client is true curve capable. This parameter should be set to
truewhen submitting edits with geometries containing true curves for non-hosted feature services referencing an enterprise geodatabase. By default, this parameter is set to false.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 } );
-
Cancels a load() operation if it is already in progress.
-
fetchAllLayersAndTables
MethodfetchAllLayersAndTables(){Promise<ServiceContents>} -
Triggers the loading of the feature service instance and fetches all layers and tables.
Fully loads the Feature Service definition.
Parameteroptions.signal AbortSignal|null|undefinedoptionalSignal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named
AbortErrorwhen an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.ReturnsType Description Promise<ServiceContents> Resolves when the Feature Service is loaded.
-
isFulfilled
MethodisFulfilled(){Boolean} -
isFulfilled()may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected). If it is fulfilled,truewill be returned.ReturnsType Description Boolean Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
-
Loads the resources referenced by this class. This method automatically executes for a View and all of the resources it references in Map if the view is constructed with a map instance.
This method must be called by the developer when accessing a resource that will not be loaded in a View.
The
load()method only triggers the loading of the resource the first time it is called. The subsequent calls return the same promise.It's possible to provide a
signalto stop being interested into aLoadableinstance load status. When the signal is aborted, the instance does not stop its loading process, only cancelLoad can abort it.Parametersoptional Additional options.
Specificationsignal AbortSignal|null|undefinedoptionalSignal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named
AbortErrorwhen an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.ReturnsType Description Promise Resolves when the resources have loaded.
-
Triggers the loading of the feature service instance.
Fully loads the Feature Service definition.
Parametersoptional Additional options.
Specificationsignal AbortSignal|null|undefinedoptionalSignal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named
AbortErrorwhen an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.ReturnsType Description Promise Resolves when the Feature Service is loaded.
-
when()may be leveraged once an instance of the class is created. This method takes two input parameters: aonFulfilledfunction and anonRejectedfunction. TheonFulfilledexecutes when the instance of the class loads. TheonRejectedexecutes if the instance of the class fails to load.ParametersReturnsType Description Promise Returns a new promise for the result of onFulfilledthat may be used to chain additional functions.Example// Although this example uses MapView, any class instance that is a promise may use when() in the same way let view = new MapView(); view.when(function(){ // This function will execute once the promise is resolved }, function(error){ // This function will execute if the promise is rejected due to an error });
Type Definitions
-
Capabilities
Type DefinitionCapabilities Object -
Describes the layer's supported capabilities.
- Properties
-
data Object
Describes characteristics of the data in the service.
editing ObjectDescribes editing capabilities that can be performed on the features in the layer via applyEdits().
- Specification
-
supportsGlobalId Boolean
Indicates if the
globalIdvalues 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,supportsUpdateandsupportsDeleteto 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.
-
CombineGroupedObjectResult
Type DefinitionCombineGroupedObjectResult ObjectSince: ArcGIS Maps SDK for JavaScript 4.34FeatureService since 4.28, CombineGroupedObjectResult added at 4.34. beta -
Represents the result of combining one or more grouped objects in a telecom domain network.
-
CombineGroupedObjectsEdit
Type DefinitionCombineGroupedObjectsEdit ObjectSince: ArcGIS Maps SDK for JavaScript 4.34FeatureService since 4.28, CombineGroupedObjectsEdit added at 4.34. beta -
Specifies grouped objects to combine in a telecom domain network.
-
DeleteAssociationEdit
Type DefinitionDeleteAssociationEdit ObjectSince: ArcGIS Maps SDK for JavaScript 4.34FeatureService since 4.28, DeleteAssociationEdit added at 4.34. beta -
Specifies a traditional or foreign-key association to delete. To delete a foreign-key association,
globalIdmust be the null GUID{00000000-0000-0000-0000-000000000000}.- Properties
-
globalId String
The global ID of the association to delete.
associationType StringThe type of association.
Possible Values:"connectivity"|"junctionJunctionConnectivity"|"attachment"|"containment"|"junctionEdgeFromConnectivity"|"junctionEdgeMidspanConnectivity"|"junctionEdgeToConnectivity"
fromSourceId NumberThe source ID of the "from" feature.
fromGlobalId StringThe global ID of the "from" feature.
fromTerminalId NumberThe terminal ID of the "from" feature.
toSourceId NumberThe source ID of the "to" feature.
toGlobalId StringThe global ID of the "to" feature.
toTerminalId NumberThe terminal ID of the "to" feature.
-
DivideGroupedObjectResult
Type DefinitionDivideGroupedObjectResult ObjectSince: ArcGIS Maps SDK for JavaScript 4.34FeatureService since 4.28, DivideGroupedObjectResult added at 4.34. beta -
Represents the result of dividing a grouped object in a telecom domain network.
- Properties
-
globalId String
Global ID of the original object before division.
The global IDs of objects resulting from the division, including the original object. I.e., the GUIDs that the target object was divided into.
If the divided object was a junction object that was directly connected to one or more edge objects prior to the division, the edge objects are also divided to maintain connectivity. This array contains GUIDs of any edge objects that are connected to the divided junction objects, including those that were connected prior to the division.
-
DivideGroupedObjectsEdit
Type DefinitionDivideGroupedObjectsEdit ObjectSince: ArcGIS Maps SDK for JavaScript 4.34FeatureService since 4.28, DivideGroupedObjectsEdit added at 4.34. beta -
Specifies a grouped object to divide, and the units to divide the object into.
- Properties
-
globalId String
The global ID of the grouped object to divide.
The units to divide the grouped object into. Each number in this array describes the number of units to assign an object resulting from the division. E.g., to divide one object with 6 units into an object with 5 units and another object with 1 unit, specify
[5, 1].
-
FeatureEditResult
Type DefinitionFeatureEditResult Object -
Represents the result of editing a feature.
- Properties
-
optional Global ID of the feature that was edited.
optional Object ID of the feature that was edited.
optional If the edit failed, the edit result includes an error.
-
LayerDefinition
Type DefinitionLayerDefinition ObjectSince: ArcGIS Maps SDK for JavaScript 4.30FeatureService since 4.28, LayerDefinition added at 4.30. -
Contains information for a layer in the Feature Service.
- Properties
-
id Number
The id of a layer.
name StringThe name of a layer.
type StringThe type of the layer.
url StringThe service url of the layer.
optionalgeometryType StringThe geometry type of a layer.
Possible Values:"point"|"polyline"|"polygon"|"envelope"|"multipoint"
capabilities CapabilitiesThe capabilities of the layer.
-
LayerInfo
Type DefinitionLayerInfo ObjectSince: 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
Type DefinitionServiceContents ObjectSince: 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
-
layers LayerDefinition[]
Contains the Layer Definition of a layer.
tables TableDefinition[]Contains the Table Definition of a layer.
-
ServiceEditsResult
Type DefinitionServiceEditsResult 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.
addFeatureResults FeatureEditResult[]Results returned from an add operation.
updateFeatureResults FeatureEditResult[]Results returned from an update operation.
deleteFeatureResults FeatureEditResult[]Results returned from a delete operation.
addAttachmentResults FeatureEditResult[]Results returned from an add attachments operation.
updateAttachmentResults FeatureEditResult[]Results returned from an update attachments operation.
deleteAttachmentResults FeatureEditResult[]Results returned from a delete attachments operation.
optionaldivideGroupedObjectResults DivideGroupedObjectResult[]Results returned from a divide operation.
optionalcombineGroupedObjectResults CombineGroupedObjectResult[]Results returned from a combine operation.
optionalsplitsResults SplitsResult[]Results returned from a split operation.
optionaleditedFeatures ObjectObject containing all edited features belonging to the specified layer.
optionaleditMoment NumberReturns the editMoment of an edit.
-
SplitsResult
Type DefinitionSplitsResult Object -
Represents the result of a split operation.
-
TableDefinition
Type DefinitionTableDefinition ObjectSince: ArcGIS Maps SDK for JavaScript 4.30FeatureService since 4.28, TableDefinition added at 4.30. -
Contains information for a table in the Feature Service.
- Properties
-
id Number
The id of a table.
name StringThe name of a table.
type StringThe type of the table.
url StringThe service url of the table.
capabilities CapabilitiesThe capabilities of the table.
-
TableInfo
Type DefinitionTableInfo ObjectSince: ArcGIS Maps SDK for JavaScript 4.30FeatureService since 4.28, TableInfo added at 4.30. -
Contains information for a table in the Feature Service.