View on GitHub Sample viewer app

Create graphics for utility associations in a utility network.

Image of display utility associations

Use case

Visualizing utility associations can help you to better understand trace results and the topology of your utility network. For example, connectivity associations allow you to model connectivity between two junctions that don’t have geometric coincidence (are not in the same location); structural attachment associations allow you to model equipment that may be attached to structures; and containment associations allow you to model features contained within other features.

How to use the sample

Pan and zoom around the map. Observe graphics that show utility associations between junctions.

How it works

  1. Create an UtilityNetwork with a feature service URL, add it to the ArcGISMap’s utility networks list, then load it.
  2. Add a FeatureLayer to the map for every UtilityNetworkSource of type EDGE or JUNCTION.
  3. Create a GraphicsOverlay for the utility associations.
  4. Add a NavigationChangedListener to listen for NavigationChangedEvents.
  5. When the sample starts and every time the viewpoint changes:
    • Get the geometry of the map view’s extent.
    • Get the associations that are within the current extent using getAssociationsAsync(extent).
    • Get the UtilityAssociationType for each association.
    • Create a Graphic using the Geometry property of the association and a preferred symbol.
    • Add the graphic to the graphics overlay.

Relevant API

  • GraphicsOverlay
  • UtilityAssociation
  • UtilityAssociationType
  • UtilityNetwork

About the data

The Naperville electrical network feature service, hosted on ArcGIS Online, contains a utility network used to display the utility associations in this sample.

Additional information

Using utility network on ArcGIS Enterprise 10.8 requires an ArcGIS Enterprise member account licensed with the Utility Network user type extension. Please refer to the utility network services documentation.

Tags

associating, association, attachment, connectivity, containment, relationships

Sample Code

module-info.java module-info.java DisplayUtilityAssociationsSample.java
/*
* Copyright 2022 Esri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module com.esri.samples.display_utility_associations {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
exports com.esri.samples.display_utility_associations;
}