UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

204 lines (202 loc) • 9.48 kB
import type { IdentifiableMixin, IdentifiableMixinProperties } from "../../core/Identifiable.js"; import type { JSONSupportMixin } from "../../core/JSONSupport.js"; import type { Loadable, LoadableMixinProperties } from "../../core/Loadable.js"; import type { AbortOptions } from "../../core/promiseUtils.js"; import type { ServiceCapabilities, LayerInfo, TableInfo, ServiceEdits, ServiceEditsResult, ServiceEditOptions, ServiceContents } from "./types.js"; export interface FeatureServiceProperties extends LoadableMixinProperties, IdentifiableMixinProperties, Partial<Pick<FeatureService, "layerInfos" | "tableInfos" | "url" | "userTypeExtensions">> {} /** * 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](https://developers.arcgis.com/javascript/latest/references/core/rest/featureService/utils/) using the [createFeatureServices()](https://developers.arcgis.com/javascript/latest/references/core/rest/featureService/utils/#createFeatureServices) method. * * @since 4.28 */ export default class FeatureService extends FeatureServiceSuperclass { /** * @example * // Create a FeatureService from a url * const featureService = new FeatureService({ * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer" * }); * @example * // Create a FeatureService using [createFeatureServices()](https://developers.arcgis.com/javascript/latest/references/core/rest/featureService/utils/#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(); */ constructor(properties?: FeatureServiceProperties); /** Describes the layer's supported capabilities. */ get capabilities(): ServiceCapabilities | null | undefined; /** * Describes effective capabilities of the service taking in to consideration privileges of the currently signed-in user. * * @since 4.30 */ get effectiveCapabilities(): ServiceCapabilities | null; /** Contains info of all layers in the Feature Service. */ accessor layerInfos: LayerInfo[]; /** * Indicates whether the instance has loaded. When `true`, * the properties of the object can be accessed. A WebMap is considered loaded * when its [WebDocument2D.layers](https://developers.arcgis.com/javascript/latest/references/core/WebDocument2D/#layers) and [WebDocument2D.basemap](https://developers.arcgis.com/javascript/latest/references/core/WebDocument2D/#basemap) are created, but not * yet loaded. * * @default false */ get loaded(): boolean; /** Contains info of all tables in the Feature Service. */ accessor tableInfos: TableInfo[]; /** 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. */ accessor url: string; /** Describes the service's userTypeExtensions. */ accessor userTypeExtensions: string[]; /** The url that points to the utility network layer, if it exists. */ get utilityNetworkUrl(): string | null; /** The url to the version management service, if the data is versioned. */ get versionManagementServiceUrl(): string | null; /** * 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](https://developers.arcgis.com/rest/services-reference/feature-service.htm). * * * > [!WARNING] * > * > 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. `applyEdits()` will pass in a `sessionId` during an active edit session. * * > [!WARNING] * > * > The `deleteAssociations`, `combineGroupedObjects`, and `divideGroupedObjects` edits are in beta and are reserved for * > future use in a telecom domain network. * * @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 Results returned from the [applyEdits()](https://developers.arcgis.com/javascript/latest/references/core/rest/featureService/FeatureService/#applyEdits) method. It contains features * that were added, deleted or updated in different feature layers. It also contains the edit moment. * @example * // Adding multiple features with a single edit object * import Graphic from "esri/Graphic"; * import Point from "esri/geometry/Point"; * import FeatureService from "esri/rest/featureService/FeatureService"; * * const featureService = new FeatureService({ * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer", * }); * * await featureService.load(); * * featureService.applyEdits( * [ * { * id: 0, // The layer ID, or layer index, of a Feature Service layer * identifierFields: { objectIdField: "OBJECTID" }, * addFeatures: [ * new Graphic({ * geometry: new Point({ * x: -1329300, * y: 4038900, * spatialReference: { * wkid: 102100, * }, * }), * attributes: { * description: "Feature description", * }, * }), * new Graphic({ * geometry: new Point({ * x: -13300000, * y: 4039000, * spatialReference: { * wkid: 102100, * }, * }), * attributes: { * description: "Feature description", * }, * }), * ], * }, * ], * { * gdbVersion: null, * globalIdUsed: false, * honorSequenceOfEdits: false, * usePreviousEditMoment: false, * }, * ); * * // Adding multiple features with multiple edit objects * await featureService.applyEdits( * [ * { * id: 0, // The layer ID, or layer index, of a Feature Service layer * identifierFields: { objectIdField: "OBJECTID" }, * addFeatures: [ * new Graphic({ * geometry: new Point({ * x: -13294000, * y: 4038800, * spatialReference: { * wkid: 102100, * }, * }), * attributes: { * description: "Feature description", * }, * }), * ], * }, * { * id: 0, // The layer ID, or layer index, of a Feature Service layer * identifierFields: { objectIdField: "OBJECTID" }, * addFeatures: [ * new Graphic({ * geometry: new Point({ * x: -13292000, * y: 4038800, * spatialReference: { * wkid: 102100, * }, * }), * attributes: { * description: "Feature description", * }, * }), * ], * }, * ], * { * gdbVersion: null, * globalIdUsed: false, * honorSequenceOfEdits: true, * usePreviousEditMoment: false, * }, * ); */ applyEdits(edits: ServiceEdits[], options?: ServiceEditOptions): Promise<ServiceEditsResult[]>; /** * Triggers the loading of the feature service instance and fetches all layers and tables. * * Fully loads the Feature Service definition. * * @param options - Additional options. * @returns Resolves when the Feature Service is [loaded](https://developers.arcgis.com/javascript/latest/references/core/rest/featureService/FeatureService/#loaded). */ fetchAllLayersAndTables(options?: AbortOptions | null | undefined): Promise<ServiceContents>; /** * Triggers the loading of the feature service instance. * * Fully loads the Feature Service definition. * * @param options - Additional options. * @returns Resolves when the Feature Service is [loaded](https://developers.arcgis.com/javascript/latest/references/core/rest/featureService/FeatureService/#loaded). */ load(options?: AbortOptions | null | undefined): Promise<this>; } declare const FeatureServiceSuperclass: typeof Loadable & typeof IdentifiableMixin & typeof JSONSupportMixin