ArcObjects Library Reference (NetworkAnalyst)  

NALayer CoClass

The layer for defining, solving, and viewing network analysis results.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server. Requires Network Analyst Extension.

Extended Error Information

Use the ISupportErrorInfo method InterfaceSupportsErrorInfo to determine if the object supports extended error information. If the object supports extended error info, VC++ developers should use the OLE/COM IErrorInfo interface to access the ErrorInfo object. Visual Basic developers should use the global error object Err to retrieve this extended error information.

Interfaces

Interfaces Description
ICompositeLayer (esriCarto) Provides access to members that work with a collection of layers that behaves like a single layer.
ICompositeLayer2 (esriCarto) Provides access to members that control whether a layer is expanded in the TOC.
IConnectionPointContainer Supports connection points for connectable objects.
IDataLayer (esriCarto) Provides access to members that control the data source properties of a layer.
IDataLayer2 (esriCarto) Provides access to additional members that control the data source properties of a layer.
IDisplayAdmin (esriDisplay) Provides access to members that control display administration.
IDisplayAdmin2 (esriDisplay) Provides access to members that control display administration.
IGeoDataset (esriGeoDatabase) Provides access to members that provide information about a Geographic Dataset.
IIdentify (esriCarto) Provides access to members that identify features.
IIdentify2 (esriCarto) Provides access to members that set the current scale of the display.
IIdentifyGroup (esriCarto) Indicator interface identifying a layer as a top-level group for identify.
ILayer (esriCarto) Provides access to members that work with all layers.
ILayer2 (esriCarto) Provides access to additional members that work with all layers.
ILayerDrawingProperties (esriCarto) Provides access to members that control layer drawing properties.
ILayerExtensions (esriCarto) Provides access to the extensions of a layer.
ILayerGeneralProperties (esriCarto) Provides access to layer general properties.
ILayerInfo (esriCarto) Provides access to members that return layer images.
ILayerPosition (esriCarto) Provides access to members that control a layer's default position in the map interface.
ILayerSymbologyExtents (esriCarto) Provides access to layer extents based on the symbology.
IMapLevel (esriDisplay) Provides access to members that control the map level.
INALayer Provides access to the network analysis layer.
INALayer2 Provides access to the network analysis layer.
INALayer3 Provides access to the network analysis layer.
IPersist Defines the single method GetClassID, which is designed to supply the CLSID of an object that can be stored persistently in the system. IPersist is the base interface for three other interfaces: IPersistStorage, IPersistStream, and IPersistFile.
IPersistStream (esriSystem)
IPublishLayer (esriCarto) Provides access to a layer's capability for being published with the ArcGIS Publisher extension.
IStandaloneTableCollection (esriCarto) Provides access to members that control the standalone table collection.
ISupportErrorInfo Indicates whether a specific interface can return Automation error objects.
ISymbolLevels (esriCarto) Provides access to members that control symbol level drawing.

Event Interfaces

Interfaces Description
ILayerEvents (default) Provides access to events that occur when layer visibility changes.
INALayerEvents Provides access to events triggered by the network analysis layer.

Remarks

NALayer is a composite layer that holds a reference to the NAContext and exposes the NAClasses within the NAContext as feature layers.

The NALayer behaves like any other composite layer within ArcGIS.  Use ICompositeLayer and ICompositeLayer2 to access these properties.

It is possible to find an NALayer in ArcMap by enumerating through the layers in the table of contents and checking to see which ones implement the interface INALayer.  Or, you can determine the NALayer currently selected in the network analyst window by asking the NAWindow for its ActiveAnalysis.

The entire NAContext, including the contents of the NAClasses, is persisted within the NALayer.  If there are a lot of NALocationFeatures in the NAContext, the size of the NALayer saved in a map document and in a layer file could be large.  The NATraversalResult is not persisted within the NALayer.

In ArcGIS Server, starting a MapServer with multiple pooled objects that contain NALayers may cause some NALayers to not bind to their internal network dataset due to contention opening the network dataset.  By default, the NALayer  retries connecting to the network dataset for 60 seconds before returning a failure.  If 60 seconds is not the appropriate amount of time for your server, create a registry key named "HKEY_LOCAL_MACHINE\Software\ESRI\ArcServer\NetworkAnalyst\OpenTimeout" of type DWORD with a decimal value between 0 and 600 which specifies the amount of time you would like to retry opening the network dataset before failing.  A value of 600 would mean keep trying to open the network analysis layer's network dataset for 10 minutes before failing.  Setting it to 0 would indicate to fail immediately if it could not connect to the network dataset on it's first attempt.  This is only applicable to ArcGIS Server MapServer objects containing NALayers.

[C#]

This C# example illustrates how you can get the active NALayer (as shown in the Network Analyst Window) programatically.

public INALayer GetActiveNetworkAnalysisLayer(IApplication app)
{
  INetworkAnalystExtension networkAnalystExtension = app.FindExtensionByName("Network Analyst") as INetworkAnalystExtension;
  return networkAnalystExtension.NAWindow.ActiveAnalysis;
}

 

[Visual Basic .NET]

This VB.NET example illustrates how you can get the active NALayer (as shown in the Network Analyst Window) programatically.

Public Function GetActiveNetworkAnalysisLayer(ByVal app As IApplication) As INALayer
  Dim networkAnalystExtension As INetworkAnalystExtension = app.FindExtensionByName("Network Analyst")
  Return networkAnalystExtension.NAWindow.ActiveAnalysis
End Function

Working with Events

[Visual Basic 6.0]

When working with NALayer's default outbound interface in Visual Basic 6 declare variables as follows:

Private WithEvents pNALayer as NALayer

When implementing INALayerEvents declare variables as follows:

Private WithEvents pNALayerEvents as NALayerEvents