import Network from "@arcgis/core/networks/Network.js";const Network = await $arcgis.import("@arcgis/core/networks/Network.js");- Inheritance:
- Network→
Accessor
- Subclasses:
- UtilityNetwork
- Since
- ArcGIS Maps SDK for JavaScript 4.20
Class defining high level properties that describes utility networks and trace networks.
- See also
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
datasetName readonly | | |
declaredClass readonly inherited | ||
featureServiceUrl readonly | | |
| | ||
| | ||
| | ||
| | ||
layerId readonly | | |
| | ||
loaded readonly | | |
loadError readonly inherited | ||
loadStatus readonly inherited | "not-loaded" | "loading" | "failed" | "loaded" | |
loadWarnings readonly inherited | any[] | |
networkServiceUrl readonly | | |
networkSystemLayers readonly | | |
owner readonly | | |
parsedUrl readonly | | |
schemaGeneration readonly | | |
| | ||
| | ||
| | ||
type readonly | "utility" | "trace" | |
dataElement
- Type
- NetworkDataElementJSON | null | undefined
The full network definition, accessible only when the network is loaded.
featureServiceUrl
- Type
- string
Returns the root feature service url which this network is part of.
Example
`https://utilitynetwork.esri.com/server/rest/services/NapervilleElectric/FeatureServer/` gdbVersion
The version of the geodatabase of the feature service data. Read the Overview of versioning topic for more details about this capability.
id
- Type
- string
Random unique id (UUID) to identify a network as defined in the webmap spec. Generated during sharing of the webmap.
layerUrl
- Type
- string
The full url to the network layer id as defined in the webmap spec.
e.g. https://utilitynetwork.esri.com/server/rest/services/NapervilleElectric/FeatureServer/17 (where 17 is the layer id of the network)
loaded
- Type
- boolean
Indicates whether the network instance has loaded. When true,
all the properties of the object can be accessed.
- Default value
- false
loadError
The Error object returned if an error occurred while loading.
loadStatus
- Type
- "not-loaded" | "loading" | "failed" | "loaded"
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. |
- Default value
- "not-loaded"
loadWarnings
- Type
- any[]
A list of warnings which occurred while loading.
networkServiceUrl
- Type
- string
Returns the url of network server.
Example
`https://utilitynetwork.esri.com/server/rest/services/NapervilleElectric/UtilityNetworkServer/` networkSystemLayers
- Type
- NetworkSystemLayers | null
Contains the url and IDs of the utility network rules, subnetworks, and dirty areas tables or layers.
Example
// Print out the dirty areas layer url in the utility networkview.when(async () => { // Check if the webmap contains utility networks if(webmap?.utilityNetworks?.length > 0) { // Assigns the utility network at index 0 utilityNetwork = webmap.utilityNetworks.at(0);
// Load the utility network await utilityNetwork.load();
// Print the dirty areas layer url and id console.log(`Dirty areas layer id: ${utilityNetwork.networkSystemLayers.dirtyAreasLayerId}`); console.log(`Dirty areas layer url: ${utilityNetwork.networkSystemLayers.dirtyAreasLayerUrl}`); }}); sourceJSON
- Type
- any
spatialReference
- Type
- SpatialReference
The spatial reference of the network, defined at the creation of the network, usually from the service territory class.
title
- Type
- string
The name of the network as defined in the webmap spec. Represents the layer name of the network layer defined while sharing the webmap.
Methods
| Method | Signature | Class |
|---|---|---|
fromPortalItem static | fromPortalItem(params: NetworkFromPortalItemParameters): Promise<UtilityNetwork | null | undefined> | |
cancelLoad inherited | cancelLoad(): this | |
getLayerIdBySourceId(sourceId: number): number | null | undefined | | |
getObjectIdsFromElements(elements: NetworkElement[]): LayerInfo[] | | |
getSourceIdByLayerId(layerId: number): number | null | undefined | | |
isFulfilled inherited | isFulfilled(): boolean | |
isRejected inherited | isRejected(): boolean | |
isResolved inherited | isResolved(): boolean | |
load(): Promise<this> | | |
queryNamedTraceConfigurations(query: QueryNamedTraceConfigurationsParametersProperties, options?: RequestOptions | null | undefined): Promise<NamedTraceConfiguration[]> | | |
submitTopologyValidationJob(props: ValidateTopologyProperties, options?: RequestOptions | null | undefined): Promise<TopologyValidationJobInfo | null | undefined> | | |
validateTopology(props: ValidateTopologyProperties, options?: RequestOptions | null | undefined): Promise<ValidateNetworkTopologyResult> | | |
when inherited | when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2> |
fromPortalItem
- Signature
-
fromPortalItem (params: NetworkFromPortalItemParameters): Promise<UtilityNetwork | null | undefined>
Creates a new network instance from an ArcGIS Online or ArcGIS Enterprise portal item.
Known Limitations
This method does not populate the UtilityNetwork.sharedNamedTraceConfigurations for a UtilityNetwork instance.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| params | The parameters for loading the portal item. | |
- Returns
- Promise<UtilityNetwork | null | undefined>
Returns a promise which resolves to the new utility network instance.
Example
// Create a utility network from a specified portal item that contains a utility network feature serviceconst item = new PortalItem({ id: "77c7ae75eb3e4e08a7ad98cb37fefe88",});
const utilityNetwork = await UtilityNetwork.fromPortalItem(item);
await utilityNetwork.load();console.log("utilityNetwork loaded? ", utilityNetwork.loadStatus); cancelLoad
- Signature
-
cancelLoad (): this
Cancels a load() operation if it is already in progress.
- Returns
- this
getLayerIdBySourceId
- Signature
-
getLayerIdBySourceId (sourceId: number): number | null | undefined
The network consists of sources (classes) and each source has a unique Id. These source Ids are used to perform traversal in the network topology. The trace end points are not aware of layers and only returns sources of results. This method returns the layerId for given a source Id. Used as a helper method to process trace results.
getObjectIdsFromElements
- Signature
-
getObjectIdsFromElements (elements: NetworkElement[]): LayerInfo[]
Groups network elements by their layerId. Returns a list containing the objectIds within each layer.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| elements | Array of network elements. | |
- Returns
- LayerInfo[]
Array of objects containing layerId and objectIds.
isFulfilled
- Signature
-
isFulfilled (): boolean
isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected).
If it is fulfilled, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
isRejected
- Signature
-
isRejected (): boolean
isRejected() may be used to verify if creating an instance of the class is rejected.
If it is rejected, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been rejected.
isResolved
- Signature
-
isResolved (): boolean
isResolved() may be used to verify if creating an instance of the class is resolved.
If it is resolved, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been resolved.
queryNamedTraceConfigurations
- Signature
-
queryNamedTraceConfigurations (query: QueryNamedTraceConfigurationsParametersProperties, options?: RequestOptions | null | undefined): Promise<NamedTraceConfiguration[]>
- Since
- ArcGIS Maps SDK for JavaScript 4.25
Named trace configurations allow you to add and store complex traces in a network that can be shared across an organization through web maps and consumed by web and field applications. This method returns a list of NamedTraceConfiguration objects that meet specific search conditions. Used to find existing named trace configurations in a utility network.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| query | The query parameters that are used to determine which named trace configurations will be returned. | | |
| options | The request options specified by the user in the data request. See RequestOptions for available properties. | |
- Returns
- Promise<NamedTraceConfiguration[]>
Resolves with an array of named trace configurations filtered based on the query parameters.
Examples
// Initialize the query object with global IDs of the named trace configurations to query.const query = { globalIds: ["5dbb5a13-ab2f-452d-bfcb-6f98154ccb9d", "cf568e46-f200-486c-adb1-d008a3da0ed1"],}
// Query the utility network named trace configurations// and filter the results by the query object.const namedTraceConfigurations = await utilityNetwork.queryNamedTraceConfigurations(query);
// Print the named trace configurations to the console.console.log(namedTraceConfigurations)// Calling this method without parameters returns all named trace configurations in the utility network.const namedTraceConfigurations = await utilityNetwork.queryNamedTraceConfigurations({});
// Print all the named trace configurations to the console.console.log(namedTraceConfigurations); submitTopologyValidationJob
- Signature
-
submitTopologyValidationJob (props: ValidateTopologyProperties, options?: RequestOptions | null | undefined): Promise<TopologyValidationJobInfo | null | undefined>
- Since
- ArcGIS Maps SDK for JavaScript 4.26
Whenever the network is edited or modified, the network and its features become out of date in the network topology. Validating the network topology maintains consistency and up-to-date content between the feature editing space and network topology space. Validating a network topology may include all or a subset of the dirty areas layer present in the network.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| props | The parameters that are used to validate the network topology. | | |
| options | The request options specified by the user in the data request. See RequestOptions for available properties. | |
- Returns
- Promise<TopologyValidationJobInfo | null | undefined>
Resolves with the results returned from validating network topology.
Example
const extent = new Extent({ xmin: 470789.0888, ymin: 3597733.2051, xmax: 531454.2759999996, ymax: 3639864.802100001, spatialReference: { wkid: 26911, latestWkid: 26911 }});
const validationResult = await network.submitTopologyValidationJob({ validateArea: extent, validationType: "rebuild", validationSet: [ { sourceId: 4134325151, globalIds: ["{7865BAA6-ED9C-4346-9F72-894A49E10C73}"] } ]}); validateTopology
- Signature
-
validateTopology (props: ValidateTopologyProperties, options?: RequestOptions | null | undefined): Promise<ValidateNetworkTopologyResult>
- Since
- ArcGIS Maps SDK for JavaScript 4.26
Whenever the network is edited or modified, the network and its features become out of date in the network topology. Validating the network topology maintains consistency and up-to-date content between the feature editing space and network topology space. Validating a network topology may include all or a subset of the dirty areas layer present in the network.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| props | The parameters that are used to validate the network topology. | | |
| options | The request options specified by the user in the data request. See RequestOptions for available properties. | |
- Returns
- Promise<ValidateNetworkTopologyResult>
Resolves with the results returned from validating network topology.
Example
const extent = new Extent({ xmin: 470789.0888, ymin: 3597733.2051, xmax: 531454.2759999996, ymax: 3639864.802100001, spatialReference: { wkid: 26911, latestWkid: 26911 }});
const result = await network.validateTopology({ validateArea: extent}); when
- Signature
-
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
when() may be leveraged once an instance of the class is created. This method takes two input parameters: an onFulfilled function and an onRejected function.
The onFulfilled executes when the instance of the class loads. The
onRejected executes if the instance of the class fails to load.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| onFulfilled | OnFulfilledCallback<this, TResult1> | null | undefined | The function to call when the promise resolves. | |
| onRejected | The function to execute when the promise fails. | |
- Returns
- Promise<TResult1 | TResult2>
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 waylet 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
ValidateTopologyProperties
- Since
- ArcGIS Maps SDK for JavaScript 4.27
ValidateTopologyProps represents the parameters for validating a network topology.
- Supertypes
- Pick<ValidateNetworkTopologyParametersProperties‚ "validationType" | "validateArea" | "validationSet" | "outSpatialReference">
Example
const validationResult = await network.validateTopology({ validateArea: extent, gdbVersion: "sde.DEFAULT", validationType: "rebuild", validationSet: [ { sourceId: 4134325151, globalIds: ["{7865BAA6-ED9C-4346-9F72-894A49E10C73}"] } ]}); NetworkFromPortalItemParameters
portalItem
- Type
- PortalItem
The object representing an ArcGIS Online or ArcGIS Enterprise portal item from which to load the network.