require(["esri/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel"], (UtilityNetworkTraceViewModel) => { /* code goes here */ });
import UtilityNetworkTraceViewModel from "@arcgis/core/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js";
esri/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel
Provides the logic for the UtilityNetworkTrace widget.
- See also
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
The name of the class. | Accessor | ||
The default color to assign the aggregated geometry of a trace result. | UtilityNetworkTraceViewModel | ||
When true, provides the ability to show the convex hull or buffer. | UtilityNetworkTraceViewModel | ||
An array of map points to load into the widget to lookup flags. | UtilityNetworkTraceViewModel | ||
The Geodatabase version to pass into the trace. | UtilityNetworkTraceViewModel | ||
This function provides the ability to override either the MapView goTo() or SceneView goTo() methods. | UtilityNetworkTraceViewModel | ||
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. | UtilityNetworkTraceViewModel | ||
An array of global Ids of traces to select on initial load. | UtilityNetworkTraceViewModel | ||
When true, the utility network elements are selected in the view when traces are completed. | UtilityNetworkTraceViewModel | ||
When true, a graphic layer is added to the view to highlight the utility network elements when traces are completed. | UtilityNetworkTraceViewModel | ||
Determines whether to show the list of selected features from completed traces. | UtilityNetworkTraceViewModel | ||
The view model's state. | UtilityNetworkTraceViewModel | ||
Stores the result of completed traces. | UtilityNetworkTraceViewModel | ||
Determines the utility network to use. | UtilityNetworkTraceViewModel | ||
The view from which the widget will operate. | UtilityNetworkTraceViewModel |
Property Details
-
defaultGraphicColor
defaultGraphicColor GraphicColor
Since: ArcGIS Maps SDK for JavaScript 4.23UtilityNetworkTraceViewModel since 4.22, defaultGraphicColor added at 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
enableResultArea Boolean
Since: ArcGIS Maps SDK for JavaScript 4.27UtilityNetworkTraceViewModel since 4.22, enableResultArea added at 4.27. -
When true, provides the ability to show the convex hull or buffer.
- Default Value:false
-
flags
flags FlagProperty[]
-
An array of map points to load into the widget to lookup flags.
- Default Value:[]
Exampleconst 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 } } ] });
-
gdbVersion
gdbVersion String
-
The Geodatabase version to pass into the trace.
- Default Value:"sde.DEFAULT"
-
goToOverride
goToOverride GoToOverride
-
This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.
Example// The following snippet uses the Search widget but can be applied to any // widgets that support the goToOverride property. search.goToOverride = function(view, goToParams) { goToParams.options = { duration: updatedDuration }; return view.goTo(goToParams.target, goToParams.options); };
-
resultAreaProperties
resultAreaProperties ResultAreaPropertiesExtend
Since: ArcGIS Maps SDK for JavaScript 4.27UtilityNetworkTraceViewModel since 4.22, resultAreaProperties added at 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 }
Exampleconst 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 } });
-
An array of global Ids of traces to select on initial load.
- Default Value:[]
-
selectOnComplete
selectOnComplete Boolean
-
When true, the utility network elements are selected in the view when traces are completed.
- Default Value:true
-
showGraphicsOnComplete
showGraphicsOnComplete 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
showSelectionAttributes Boolean
-
Determines whether to show the list of selected features from completed traces.
- Default Value:true
-
state
state Stringreadonly
-
The view model's state.
Possible Values:"loading" |"ready"
- Default Value:ready
-
traceResults
traceResults TraceResultExtend[]
Since: ArcGIS Maps SDK for JavaScript 4.27UtilityNetworkTraceViewModel since 4.22, traceResults added at 4.27. -
Stores the result of completed traces.
-
utilityNetwork
utilityNetwork UtilityNetwork
Since: ArcGIS Maps SDK for JavaScript 4.27UtilityNetworkTraceViewModel since 4.22, utilityNetwork added at 4.27. -
Determines the utility network to use.
-
view
view MapView
-
The view from which the widget will operate.
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds a flag point graphic for the click event on the view if there is a feature to query. | UtilityNetworkTraceViewModel | ||
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
Creates a graphic from the trace result and adds it to the map. | UtilityNetworkTraceViewModel | ||
Create a graphic on the view’s graphics for the aggregated results of all the features returned by the trace. | UtilityNetworkTraceViewModel | ||
Adds the selected terminal to a flag point. | UtilityNetworkTraceViewModel | ||
Get all parameters for the trace type selected to be run before executing the trace. | UtilityNetworkTraceViewModel | ||
Change the graphic color for the aggregated results of a trace. | UtilityNetworkTraceViewModel | ||
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). | UtilityNetworkTraceViewModel | ||
Indicates if any selection exists on the view. | UtilityNetworkTraceViewModel | ||
Removes a specific trace from the results. | UtilityNetworkTraceViewModel | ||
Creates a buffer or convex hull graphic of the trace result. | UtilityNetworkTraceViewModel | ||
Executes the trace and returns all trace results as graphics and/or feature selections and functions. | UtilityNetworkTraceViewModel | ||
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. | UtilityNetworkTraceViewModel | ||
Returns true if a named group of handles exist. | Accessor | ||
Reads the web map and loads the UtilityNetwork if it exists. | UtilityNetworkTraceViewModel | ||
Enables or disables the filter barrier setting on barrier flags. | UtilityNetworkTraceViewModel | ||
Is used to merge the feature selections in the layer views when multiple traces are run. | UtilityNetworkTraceViewModel | ||
Query the layers by ObjectID for more attributes not present on the trace result elements. | UtilityNetworkTraceViewModel | ||
Takes the result of a hit test to lookup the asset to create a flag for the trace. | UtilityNetworkTraceViewModel | ||
Removes all the graphics from the result area graphic layer | UtilityNetworkTraceViewModel | ||
Removes the selected flag from the view. | UtilityNetworkTraceViewModel | ||
Removes a group of handles owned by the object. | Accessor | ||
Removes the result area graphic from the | UtilityNetworkTraceViewModel | ||
Removes a specific trace result graphic from the view’s graphics. | UtilityNetworkTraceViewModel | ||
Removes the selection from the layer view. | UtilityNetworkTraceViewModel | ||
Removes the selected terminal from the flag. | UtilityNetworkTraceViewModel | ||
Clears all inputs (flags, trace types) and all results (selections, graphics) in the view. | UtilityNetworkTraceViewModel | ||
Performs a selection on a layer view based on a list of ObjectIDs. | UtilityNetworkTraceViewModel | ||
Loops through the trace result elements to group them by network source id and selects them on the layer view. | UtilityNetworkTraceViewModel | ||
Set the trace type to be run from the available trace configurations in the WebMap. | UtilityNetworkTraceViewModel | ||
Preset a trace type to be run from the available trace configurations in the WebMap when the widget loads. | UtilityNetworkTraceViewModel | ||
Zoom to a flag's feature or a result feature in the view. | UtilityNetworkTraceViewModel |
Method Details
-
Adds a flag point graphic for the click event on the view if there is a feature to query.
Parametertype StringThe type of flag can be a
"starting point"
or a"barrier"
.Returns
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 4.25. -
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
Since: ArcGIS Maps SDK for JavaScript 4.27UtilityNetworkTraceViewModel since 4.22, addResultAreaToMap added at 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.
Parametertrace TraceResultExtendThe aggregate of the trace configuration settings and the results for that trace.
-
addResultGraphicToView
addResultGraphicToView(trace, color){Promise}
-
Create a graphic on the view’s graphics for the aggregated results of all the features returned by the trace.
Parameterstrace TraceResultExtendThe aggregate of the trace configuration settings and the results for that trace.
color GraphicColorThe color for the graphic of the trace results in the view’s graphics.
ReturnsType Description Promise Resolves when the graphics are added to the view.
-
Adds the selected terminal to a flag point.
ParametersselectedTerminal StringThe terminal id of the selected terminal.
feature FlagPropertyThe flag to assign the terminal.
-
Get all parameters for the trace type selected to be run before executing the trace.
Returns
-
Change the graphic color for the aggregated results of a trace.
Parameterscolor GraphicColorThe color for the graphic of the trace results in the view’s graphics.
trace TraceResultExtendThe aggregate of the trace configuration settings and the results for that trace.
-
checkCanTrace
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).
ReturnsType Description ValidSetup Represents whether a trace is setup correctly.
-
Removes a specific trace from the results. This will also clear any graphics or selection in the view for that trace.
Parametertrace TraceItemThe trace that will be cleared.
-
Creates a buffer or convex hull graphic of the trace result.
ParametertraceResults TraceResultExtendThe aggregate of the trace configuration settings and the results for that trace.
Returns
-
executeTrace
executeTrace(traceItem, url, params){Promise<TraceResultExtend>}
-
Executes the trace and returns all trace results as graphics and/or feature selections and functions.
ParameterstraceItem TraceItemThe trace item input for the trace.
url StringThe URL of the service being traced.
params TraceParametersThe trace input parameters.
ReturnsType Description Promise<TraceResultExtend> Represents the trace results and its properties.
-
getValidSources
getValidSources(){Array<(EdgeSourceJSON|JunctionSourceJSON)>}
-
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.
ReturnsType Description Array<(EdgeSourceJSON|JunctionSourceJSON)> The edge or junction layer info.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
loadUtilityNetwork
loadUtilityNetwork(){Promise<UtilityNetwork>}
-
Reads the web map and loads the UtilityNetwork if it exists.
ReturnsType Description Promise<UtilityNetwork> Resolves when the UtilityNetwork has been loaded.
-
Enables or disables the filter barrier setting on barrier flags.
Parametersstatus BooleanWhether the filter barrier is enabled or disabled.
feature FlagPropertyThe barrier flag for which the filter barrier is enabled or disabled.
-
Is used to merge the feature selections in the layer views when multiple traces are run.
Parameters
-
queryFeaturesById
queryFeaturesById(dataItems){Promise<FeatureSetInfo[]>}
-
Query the layers by ObjectID for more attributes not present on the trace result elements.
ParameterdataItems NetworkElement[]An array of NetworkElements.
ReturnsType Description Promise<FeatureSetInfo[]> When resolved, an array of FeatureSetInfo is returned.
-
Takes the result of a hit test to lookup the asset to create a flag for the trace.
Parametersevent CreateToolEventInfoThe create event.
flagType StringThe type of flag. It must be either
"starting point"
or"barrier"
.Returns
-
Removes all the graphics from the result area graphic layer
-
Removes the selected flag from the view.
Parameterflag FlagPropertyThe FlagProperty to identify the flag to be removed.
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
Since: ArcGIS Maps SDK for JavaScript 4.27UtilityNetworkTraceViewModel since 4.22, removeResultAreaFromMap added at 4.27. -
Removes the result area graphic from the
Map
.Parametertrace TraceResultExtendThe aggregate of the trace configuration settings and the results for that trace.
-
Removes a specific trace result graphic from the view’s graphics.
Parametertrace TraceResultExtendThe trace for which the graphic will be removed.
-
Removes the selected terminal from the flag.
ParametersselectedTerminal StringThe terminal id of the selected terminal.
feature FlagPropertyThe flag to remove the terminal.
-
Clears all inputs (flags, trace types) and all results (selections, graphics) in the view.
-
Performs a selection on a layer view based on a list of ObjectIDs.
ParameterresultSet NetworkElement[]An array of NetworkElements.
-
Loops through the trace result elements to group them by network source id and selects them on the layer view.
ParameterresultSet NetworkElement[]An array of NetworkElements.
-
Set the trace type to be run from the available trace configurations in the WebMap.
Parameters
-
Preset a trace type to be run from the available trace configurations in the WebMap when the widget loads.
-
Zoom to a flag's feature or a result feature in the view.
Parametergeometry GoToTarget2D|GoToTarget3DThe geometry to zoom to.
Type Definitions
-
AssetGroupJSON
AssetGroupJSON Object
-
AssetGroupJSON represents the asset group. The asset group is the subtype field and represents the major classification of utility network classes.
- Properties
-
assetGroupCode Number
The asset group code.
assetGroupName StringThe asset group name.
assetTypes AssetTypeJSON[]The asset type.
-
AssetTypeJSON
AssetTypeJSON Object
-
AssetTypeJSON represents asset type. Attribute domains are assigned on the asset type field at the subtype level for each network class. It represents the minor classification of the utility network classes.
-
DisplayField
DisplayField Object
-
DisplayField represents the attribute field used as a display label for flags and selected features.
-
EdgeSourceJSON
EdgeSourceJSON Object
-
EdgeSourceJSON represents the line layers that participate in the utility network service.
- Properties
-
layerId Number
The layer id of the line layer.
assetGroups AssetGroupJSON[]The asset group attribute values for the line layer.
sourceId NumberThe network source id of the line layer.
-
FeatureSetInfo
FeatureSetInfo Object
-
FeatureSetInfo represents the information for the results in the featureset.
- Properties
-
layer FeatureLayer
The FeatureLayer of the dataset.
featureSet FeatureSetThe FeatureSet.
-
FlagProperty
FlagProperty Object
-
FlagProperty represents the properties to define each flag point (starting points and barriers).
- Properties
-
allTerminals TerminalConfiguration
The available terminals to define the permissible paths based on the terminal configurations. The default terminal is always set.
details anyAll the information returned by the hitTest.
displayField DisplayFieldThe display field of the flag.
id NumberThe id of the flag.
mapGraphic GraphicThe flag graphic.
mapPoint PointThe geometry point of the flag.
The terminals that are selected for the flag (this can be the default terminal or terminals selected by the end-user).
type StringThe flag type being set. Must be either
"starting point"
or"barrier"
.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.
-
GraphicColor
GraphicColor Object
-
GraphicColor represents the color for the trace result graphic in the graphics layer.
-
JunctionSourceJSON
JunctionSourceJSON Object
-
JunctionSourceJSON represents the point layers that participate in the utility network service.
- Properties
-
layerId Number
The layer id of the point layer.
assetGroups AssetGroupJSON[]The asset group attribute values for the point layer.
sourceId NumberThe network source id of the point layer.
-
ResultAreaPropertiesExtend
ResultAreaPropertiesExtend Object
-
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.
- Properties
-
type String
The geometry of the result area. The convex hull is the smallest convex polygon enclosing all the result elements. If a distance is defined, it will be applied as a buffer to the convex hull. The buffer is the polygon generated from an offset at each feature's vertices. The distance value will be used to buffer the features.
Possible Values:"buffer"|"convexhull"
distance NumberThe buffer or padding added to the result area.
unit LinearUnitsUnits for linear measurements.
areaUnit AreaUnitsUnits for area measurements.
color GraphicColorThe color for the result area graphic.
show BooleanDetermines if the area is shown on the map.
-
TraceResultExtend
TraceResultExtend Object
-
TraceResultExtend organizes the results based on the trace configuration and the trace results.
- Properties
-
TraceItem TraceItem
TraceItem extends the named trace configuration and adds a property to manage the selection on the view.
TraceResult TraceResultThe collection of results returned from the trace.
selectionEnabled BooleanReturns true if selection is enabled.
graphicEnabled BooleanReturns true if graphic is enabled.
graphicColor GraphicColorThe color for the graphic of the trace results in the graphics layer.
status StringThe current status of the trace to return errors from the server.