You can display and share a complete utility network
You can also create a map programmatically, making use of subtype feature layers
You can use display filters to show and hide features
Access a utility network
Utility networks are implemented as network controller datasets. These datasets contain a network's feature tables
You can display and share a complete utility network with a user via a web map
A UtilityNetwork object in Native Maps SDKs can be created from an online or an offline
These sources provide access to the topological network in the utility network. For example, you can provide a map that contains a subset of the feature layers
Utility Network version 2 and later is supported. This is provided from ArcGIS Pro
Access a utility network from an online source
Online sources include a URL to a feature service
When using either a URL to a feature service or a portal item
val serviceGeodatabase = ServiceGeodatabase(featureServiceUrl)
coroutineScope.launch {
serviceGeodatabase.load().getOrElse {
return@launch showError("Error loading service geodatabase: ${it.message}")
}
map = ArcGISMap(BasemapStyle.ArcGISNavigationNight)
val serviceFeatureTable = serviceGeodatabase.getTable(layerId = 0)
?: return@launch showError("No feature table found.")
val featureLayer = FeatureLayer.createWithFeatureTable(serviceFeatureTable)
map.operationalLayers.add(featureLayer)
utilityNetwork = UtilityNetwork(serviceGeodatabase)
When using a web map portal item
map = ArcGISMap(uri = webMapURL)
map.load()
utilityNetwork = map.utilityNetworks.firstOrNull() ?: return showError("Web map contains no utility networks.")
Branch-versioning
When a utility network is based on a ServiceGeodatabase that points to an ArcGIS Enterprise
A service geodatabase
val serviceGeodatabase = ServiceGeodatabase(url = featureServiceUrl, sessionType = FeatureServiceSessionType.Persistent)
To create and switch to the new version ...
val versionParameters = ServiceVersionParameters()
versionParameters.access = VersionAccess.Private
versionParameters.name = "MyVersionName"
val serviceGeodatabase = utilityNetwork.serviceGeodatabase ?: return showError("Failed to get service geodatabase from the utility network.")
val serviceVersionInfo = serviceGeodatabase.createVersion(versionParameters).getOrElse { error ->
return showError("Failed to create a geodatabase branch version: $error.")
}
val versionName = serviceVersionInfo.name
serviceGeodatabase.switchVersion(versionName = versionName)
To get versions accessible to the logged-in user and switch to a specific version ...
val serviceGeodatabase = utilityNetwork.serviceGeodatabase ?: return showError("Failed to get service geodatabase from the utility network.")
val versionInfos = serviceGeodatabase.fetchVersions().getOrElse { error ->
return showError("Failed to fetch versions for service geodatabase.")
}
val foundVersionInfo = versionInfos.find { serviceVersionInfo ->
serviceVersionInfo.name == "userName.MyVersionName"
} ?: return showError("Could not find service version info.")
serviceGeodatabase.switchVersion(versionName = foundVersionInfo.name)
Access a utility network from an offline source
Offline*.geodatabase extension or a web map containing a UtilityNetwork that has been taken offline.
A mobile geodatabase source can be one of the following:
-
a stand-alone mobile geodatabase
A mobile geodatabase (.geodatabase) is a spatial data storage format in a single file on disk that can store, query, and manage spatial and nonspatial data. In applications built with the ArcGIS Maps SDKs for Native Apps, mobile geodatabases can be used in offline workflows when taking maps and features offline from services or in desktop-based scenarios as standalone mobile geodatabases from ArcGIS Pro. that is exported from ArcGIS ProArcGIS Pro is a professional desktop GIS application that can explore, visualize, analyze, and manage 2D and 3D data. 2.7 or higher -
a sync-enabled mobile geodatabase that is generated from ArcGIS Enterprise
ArcGIS Enterprise is a GIS mapping, analytics, data hosting, and content management product that can be hosted on-premise or in a cloud infrastructure. It includes software, applications, tools, APIs, and services for users and developers. Feature Service 10.9 or higher using aGeodatabaseSyncTaskorOfflineMapSyncTask.
When using a mobile geodatabase, create and load a geodatabase
val geodatabase = Geodatabase(path = pathToGeodatabase)
val map = ArcGISMap(BasemapStyle.ArcGISStreetsNight)
val featureTable = geodatabase.getFeatureTable(serviceLayerId = 0) ?: return showError("Failed to create a feature layer from the feature table.")
val featureLayer = FeatureLayer.createWithFeatureTable(featureTable)
map.operationalLayers.add(featureLayer)
val utilityNetwork = geodatabase.utilityNetworks.firstOrNull() ?: return showError("Geodatabase contains no utility networks.")
map.utilityNetworks.add(utilityNetwork)
Load the utility network
The utility network follows the loadable
Loading the utility network loads the entire utility network schema (information about the datasets that participate in the network). Once loaded, your app can navigate this network schema to discover the domain networks
utilityNetwork.load().onFailure { return showError("Failed to load the utility network.") }
val utilityNetworkDefinition = utilityNetwork.definition ?: return showError("Failed to get the definition of the utility network.")
if (utilityNetworkDefinition.capabilities.supportsTrace) {
val traceResults = utilityNetwork.trace(utilityTraceParameters).getOrElse { error ->
return showError("Failed to get utility trace elements: $error")
}
}
if (utilityNetworkDefinition.capabilities.supportsQueryAssociations) {
val associations = utilityNetwork.getAssociations(utilityElement).getOrElse { error ->
return showError("Failed to get associations for the utility element: $error")
}
}