View in MAUI WPF WinUI UWP View on GitHub

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 and load a Map with a web map item URL that contains a UtilityNetwork.
  2. Get and load the first UtilityNetwork from the web map.
  3. Create a GraphicsOverlay for the utility associations.
  4. Add an event handler for the ViewpointChanged event of the MapView.
  5. When the sample starts and every time the viewpoint changes, do the following steps.
  6. Get the geometry of the mapview’s extent using GetCurrentViewpoint(ViewpointType.BoundingGeometry)?.TargetGeometry?.Extent.
  7. Get the associations that are within the current extent using GetAssociationsAsync(extent).
  8. Get the UtilityAssociationType for each association.
  9. Create a Graphic using the Geometry property of the association and a preferred symbol.
  10. Add the graphic to the graphics overlay.

Relevant API

  • GraphicsOverlay
  • UtilityAssociation
  • UtilityAssociationType
  • UtilityNetwork

About the data

The Naperville Electric Map web map contains a utility network used to run the subnetwork-based trace in this sample. Authentication is required and handled within the sample code.

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

DisplayUtilityAssociations.xaml DisplayUtilityAssociations.xaml DisplayUtilityAssociations.xaml.cs
<UserControl x:Class="ArcGIS.WPF.Samples.DisplayUtilityAssociations.DisplayUtilityAssociations"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<UserControl.Resources>
<DataTemplate x:Key="AssociationLegendItemTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Width="25"
Height="25"
Source="{Binding Value}" />
<TextBlock Grid.Column="1" Text="{Binding Key}" />
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid>
<esri:MapView x:Name="MyMapView" NavigationCompleted="OnNavigationCompleted" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<Label Margin="5" Content="Utility association types" />
<ListView x:Name="AssociationLegend"
Margin="5"
IsHitTestVisible="False"
ItemTemplate="{StaticResource AssociationLegendItemTemplate}" />
</StackPanel>
</Border>
</Grid>
</UserControl>