import UtilityNetworkTraceViewModel from "@arcgis/core/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js";const UtilityNetworkTraceViewModel = await $arcgis.import("@arcgis/core/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js");- Inheritance:
- UtilityNetworkTraceViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.22
Provides the logic for the UtilityNetworkTrace widget and component.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
declaredClass readonly inherited | ||
| | ||
| | ||
| | ||
| | ||
string[] | | |
| | ||
| | ||
| | ||
state readonly | | |
| | ||
| | ||
| |
defaultGraphicColor
- Type
- GraphicColor
- Since
- ArcGIS Maps SDK for JavaScript 4.23
The default color to assign the aggregated geometry of a trace result.
- Default value
- { color: [255, 255, 0, 0.6], haloOpacity: 0.9, fillOpacity: 0.2, hex: "#FFFF00" }
enableResultArea
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.27
When true, provides the ability to show the convex hull or buffer.
- Default value
- false
flags
- Type
- FlagProperty[]
An array of map points to load into the widget to lookup flags.
- Default value
- []
Example
const unt = new UtilityNetworkTrace({ view: view, showSelectionAttributes: true, selectOnComplete: true, showGraphicsOnComplete: true, selectedTraces: ["{E8D545B8-596D-4656-BF5E-16C1D7CBEC9B}"], flags: [ { type: "starting-point", mapPoint: { spatialReference: { latestWkid: 3857, wkid: 102100 }, x: -9814829.166046409, y: 5127094.1017433 } }, { type: "barrier", mapPoint: { spatialReference: { latestWkid: 3857, wkid: 102100 }, x: -9814828.449441982, y: 5127089.085566963 } } ]}); resultAreaProperties
- Since
- ArcGIS Maps SDK for JavaScript 4.27
The properties to determine the size and color of the result area convex hull or buffer, and determines if it displays on the map when the trace completes.
- Default value
- { type: "convexhull", distance: 10, unit: "meters", areaUnit: "square-meters", color: { color: [255, 165, 0, 0.5], haloOpacity: 0.9, fillOpacity: 0.2, hex: "#ffa500" }, show: false }
Example
const unt = new UtilityNetworkTrace({ un: un, view: view, enableResultArea: true, resultAreaProperties: { type: "buffer", distance: 10, unit: "feet", areaUnit: "square-feet", color: { color: [255, 165, 0, 0.5], haloOpacity: 0.9, fillOpacity: 0.2, hex: "#ffa500" }, show: true }}); selectedTraces
- Type
- string[]
An array of global Ids of traces to select on initial load.
- Default value
- []
selectOnComplete
- Type
- boolean
When true, the utility network elements are selected in the view when traces are completed.
- Default value
- true
showGraphicsOnComplete
- Type
- boolean
When true, a graphic layer is added to the view to highlight the utility network elements when traces are completed.
- Default value
- true
showSelectionAttributes
- Type
- boolean
Determines whether to show the list of selected features from completed traces.
- Default value
- true
traceResults
- Type
- Array<TraceResultExtend>
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Stores the result of completed traces.
utilityNetwork
- Type
- UtilityNetwork | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Determines the utility network to use.
Methods
| Method | Signature | Class |
|---|---|---|
addFlagByHit(type: TraceLocationType): Promise<boolean> | | |
addResultAreaToMap(trace: TraceResultExtend): Promise<void> | | |
addResultGraphicToView(trace: TraceResultExtend, color: GraphicColor): Promise<void> | | |
addTerminal(selectedTerminal: string, feature: FlagProperty): void | | |
callTrace(): Promise<boolean> | | |
changeResultGraphicColor(color: GraphicColor, trace: TraceResultExtend): void | | |
checkCanTrace(): ValidSetup | | |
checkSelectionExist(): boolean | | |
clearResult(trace: TraceItem): void | | |
createResultAreaGraphic(traceResults: TraceResultExtend): Promise<Graphic | null | undefined> | | |
emit inherited | emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean | |
executeTrace(traceItem: TraceItem, url: string, params: TraceParameters): Promise<TraceResultExtend> | | |
getValidSources(): Array<NetworkSourceJSON> | | |
hasEventListener inherited | hasEventListener<Type extends EventNames<this>>(type: Type): boolean | |
loadUtilityNetwork(): Promise<UtilityNetwork | null | undefined> | | |
manageFilterBarrier(status: boolean, feature: FlagProperty): void | | |
mergeSelection(status: boolean, trace: TraceItem): void | | |
on inherited | on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle | |
queryFeaturesById(dataItems: NetworkElement[]): Promise<FeatureSetInfo[] | null | undefined> | | |
queryFlagByHitTest(event: CreateEvent, flagType: TraceLocationType): Promise<boolean> | | |
removeAllResultAreaGraphics(): void | | |
removeFlag(flag: FlagProperty): void | | |
removeResultAreaFromMap(trace: TraceResultExtend): void | | |
removeResultGraphicFromView(trace: TraceResultExtend): void | | |
removeSelection(): void | | |
removeTerminal(selectedTerminal: string, feature: FlagProperty): void | | |
reset(): void | | |
selectFeaturesById(resultSet: NetworkElement[]): void | | |
selectResults(resultSet: NetworkElement[]): void | | |
selectTraces(state: boolean, traceId: string): void | | |
selectTracesOnLoad(): void | | |
zoomToAsset(geometry: GoToTarget2D | GoToTarget3D): void | |
addResultAreaToMap
- Signature
-
addResultAreaToMap (trace: TraceResultExtend): Promise<void>
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Creates a graphic from the trace result and adds it to the map. If a trace has both aggregated geometries and elements as results, aggregated geometries will be used to generate this area.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| trace | The aggregate of the trace configuration settings and the results for that trace. | |
addResultGraphicToView
- Signature
-
addResultGraphicToView (trace: TraceResultExtend, color: GraphicColor): Promise<void>
Create a graphic on the view's MapView.graphics for the aggregated results of all the features returned by the trace.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| trace | The aggregate of the trace configuration settings and the results for that trace. | | |
| color | The color for the graphic of the trace results in the view's MapView.graphics. | |
addTerminal
- Signature
-
addTerminal (selectedTerminal: string, feature: FlagProperty): void
Adds the selected terminal to a flag point.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| selectedTerminal | The terminal id of the selected terminal. | | |
| feature | The flag to assign the terminal. | |
- Returns
- void
changeResultGraphicColor
- Signature
-
changeResultGraphicColor (color: GraphicColor, trace: TraceResultExtend): void
Change the graphic color for the aggregated results of a trace.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| color | The color for the graphic of the trace results in the view's MapView.graphics. | | |
| trace | The aggregate of the trace configuration settings and the results for that trace. | |
- Returns
- void
checkCanTrace
- Signature
-
checkCanTrace (): ValidSetup
May be used to verify if all requirements are met to execute a trace (at least 1 starting point and at least 1 trace type selected).
- Returns
- ValidSetup
Represents whether a trace is setup correctly.
checkSelectionExist
- Signature
-
checkSelectionExist (): boolean
Indicates if any selection exists on the view.
- Returns
- boolean
Returns
trueif selection exists on the view.
createResultAreaGraphic
- Signature
-
createResultAreaGraphic (traceResults: TraceResultExtend): Promise<Graphic | null | undefined>
Creates a buffer or convex hull graphic of the trace result.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| traceResults | The aggregate of the trace configuration settings and the results for that trace. | |
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
Emits an event on the instance. This method should only be used when creating subclasses of this class.
executeTrace
- Signature
-
executeTrace (traceItem: TraceItem, url: string, params: TraceParameters): Promise<TraceResultExtend>
Executes the trace and returns all trace results as graphics and/or feature selections and functions.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| traceItem | The trace item input for the trace. | | |
| url | The URL of the service being traced. | | |
| params | The trace input parameters. | |
- Returns
- Promise<TraceResultExtend>
Represents the trace results and its properties.
getValidSources
- Signature
-
getValidSources (): Array<NetworkSourceJSON>
Gets the valid edge and junction layers within the view that are part of the Utility Network and can be used for placing flags in the view.
- Returns
- Array<NetworkSourceJSON>
The edge or junction layer info.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
loadUtilityNetwork
- Signature
-
loadUtilityNetwork (): Promise<UtilityNetwork | null | undefined>
Reads the web map and loads the UtilityNetwork if it exists.
- Returns
- Promise<UtilityNetwork | null | undefined>
Resolves when the UtilityNetwork has been loaded.
manageFilterBarrier
- Signature
-
manageFilterBarrier (status: boolean, feature: FlagProperty): void
Enables or disables the filter barrier setting on barrier flags.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| status | Whether the filter barrier is enabled or disabled. | | |
| feature | The barrier flag for which the filter barrier is enabled or disabled. | |
- Returns
- void
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | An event or an array of events to listen for. | |
| listener | EventedCallback<this["@eventTypes"][Type]> | The function to call when the event fires. | |
- Returns
- ResourceHandle
Returns an event handler with a
remove()method that should be called to stop listening for the event(s).Property Type Description remove Function When called, removes the listener from the event.
Example
view.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint);}); queryFeaturesById
- Signature
-
queryFeaturesById (dataItems: NetworkElement[]): Promise<FeatureSetInfo[] | null | undefined>
Query the layers by ObjectID for more attributes not present on the trace result elements.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| dataItems | An array of NetworkElements. | |
- Returns
- Promise<FeatureSetInfo[] | null | undefined>
When resolved, an array of FeatureSetInfo is returned.
queryFlagByHitTest
- Signature
-
queryFlagByHitTest (event: CreateEvent, flagType: TraceLocationType): Promise<boolean>
Takes the result of a hit test to lookup the asset to create a flag for the trace.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| event | The create event. | | |
| flagType | The type of flag. It must be either | |
removeAllResultAreaGraphics
- Signature
-
removeAllResultAreaGraphics (): void
Removes all the graphics from the result area graphic layer
- Returns
- void
removeFlag
- Signature
-
removeFlag (flag: FlagProperty): void
Removes the selected flag from the view.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| flag | The FlagProperty to identify the flag to be removed. | |
- Returns
- void
removeResultAreaFromMap
- Signature
-
removeResultAreaFromMap (trace: TraceResultExtend): void
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Removes the result area graphic from the Map.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| trace | The aggregate of the trace configuration settings and the results for that trace. | |
- Returns
- void
removeResultGraphicFromView
- Signature
-
removeResultGraphicFromView (trace: TraceResultExtend): void
Removes a specific trace result graphic from the view's MapView.graphics.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| trace | The trace for which the graphic will be removed. | |
- Returns
- void
removeSelection
- Signature
-
removeSelection (): void
Removes the selection from the layer view.
- Returns
- void
removeTerminal
- Signature
-
removeTerminal (selectedTerminal: string, feature: FlagProperty): void
Removes the selected terminal from the flag.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| selectedTerminal | The terminal id of the selected terminal. | | |
| feature | The flag to remove the terminal. | |
- Returns
- void
reset
- Signature
-
reset (): void
Clears all inputs (flags, trace types) and all results (selections, graphics) in the view.
- Returns
- void
selectFeaturesById
- Signature
-
selectFeaturesById (resultSet: NetworkElement[]): void
Performs a selection on a layer view based on a list of ObjectIDs.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| resultSet | An array of NetworkElements. | |
- Returns
- void
selectResults
- Signature
-
selectResults (resultSet: NetworkElement[]): void
Loops through the trace result elements to group them by network source id and selects them on the layer view.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| resultSet | An array of NetworkElements. | |
- Returns
- void
selectTraces
- Signature
-
selectTraces (state: boolean, traceId: string): void
Set the trace type to be run from the available trace configurations in the WebMap.
selectTracesOnLoad
- Signature
-
selectTracesOnLoad (): void
Preset a trace type to be run from the available trace configurations in the WebMap when the widget loads.
- Returns
- void
zoomToAsset
- Signature
-
zoomToAsset (geometry: GoToTarget2D | GoToTarget3D): void
Zoom to a flag's feature or a result feature in the view.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to zoom to. | |
- Returns
- void
Type definitions
TraceItem
TraceItem extends the named trace configuration and adds a property to manage the selection on the view.
- Supertypes
- NamedTraceConfigurationProperties
DisplayField
DisplayField represents the attribute field used as a display label for flags and selected features.
FlagProperty
FlagProperty represents the properties to define each flag point (starting points and barriers).
- Supertypes
- TraceLocationProperties
type
- Type
- TraceLocationType
The flag type being set. Must be either "starting point" or "barrier". The stopping-point type is reserved for future use.
Possible Values
| Value | Description |
|---|---|
| starting-point | The flag set will be the starting location of the trace. |
| barrier | The flag set will mark the location to stop the trace. |
allTerminals
- Type
- TerminalConfiguration | null | undefined
The available terminals to define the permissible paths based on the terminal configurations. The default terminal is always set.
GraphicColor
GraphicColor represents the color for the trace result graphic in the graphics layer.
ResultAreaPropertiesExtend
ResultAreaPropertiesExtend represents the properties to determine the size and color of the result area convex hull or buffer, and whether it displays on the map when the trace completes.
- Supertypes
- ResultAreaProperties
TraceResultExtend
TraceResultExtend organizes the results based on the trace configuration and the trace results.
trace
- Type
- TraceItem
TraceItem extends the named trace configuration and adds a property to manage the selection on the view.
graphicColor
- Type
- GraphicColor
The color for the graphic of the trace results in the graphics layer.
ValidSetup
ValidSetup verifies whether a trace meets all the requirements before it can execute.
UtilityNetworkTraceViewModelAddFlagCompleteEvent
symbol
- Type
- SimpleMarkerSymbol | PictureMarkerSymbol | null | undefined
The symbol of the flag point graphic.
UtilityNetworkTraceViewModelAddFlagErrorEvent
symbol
- Type
- SimpleMarkerSymbol | PictureMarkerSymbol | null | undefined
The symbol of the flag point graphic.
UtilityNetworkTraceViewModelCreateResultAreaEvent
graphic
The graphic of the result area generated from the trace if UtilityNetworkTrace.enableResultArea is true.