ESRI Network Layer CoClass.
| Interfaces | Description |
|---|---|
| IConnectionPointContainer | Supports connection points for connectable objects. |
| IDataLayer | Provides access to members that control the data source properties of a layer. |
| IDataLayer2 | Provides access to additional members that control the data source properties of a layer. |
| IDataset (esriGeoDatabase) | Provides access to members that supply dataset information. |
| IDisplayAdmin (esriDisplay) | Provides access to members that control display administration. |
| IDisplayFilterManager (esriDisplay) | Provides access to members that control display filter management. |
| IGeoDataset (esriGeoDatabase) | Provides access to members that provide information about a Geographic Dataset. |
| IIdentify | Provides access to members that identify features. |
| IIdentify2 | Provides access to members that set the current scale of the display. |
| ILayer | Provides access to members that work with all layers. |
| ILayer2 | Provides access to additional members that work with all layers. |
| ILayerDrawingProperties | Provides access to members that control layer drawing properties. |
| ILayerEffects | Provides access to members that control layer effects. |
| ILayerExtensions | Provides access to the extensions of a layer. |
| ILayerGeneralProperties | Provides access to layer general properties. |
| ILayerInfo | Provides access to members that return layer images. |
| ILayerPosition | Provides access to members that control a layer's default position in the map interface. |
| ILegendInfo | Provides access to members that control legend information provided by a renderer. |
| IMapLevel (esriDisplay) | Provides access to memebers that control the map level. |
| INetworkLayer | Provides access to members that control a network layer. |
| INetworkRendererCollection | Provides access to members that manage the collection of network renderers. |
| IPersistStream (esriSystem) | |
| IPropertySupport (esriSystem) | Provides access to members that set a default property on an object. |
| IPublishLayer | Provides access to a layer's capability for being published with the ArcGIS Publisher extension. |
| ITemporaryLayer | Provides access to temporary layer properties. |
| Interfaces | Description |
|---|---|
| ILayerEvents (default) | Provides access to events that occur when layer visibility changes. |
The NetworkLayer is a type of Layer in the Map that holds a reference to a NetworkDataset. You can open its network dataset by calling INetworkLayer::NetworkDataset.
The following code shows how to open a shapefile network dataset, then add it to a Map using a NetworkLayer:
void AddNetworkLayer(string shapefilePath, string networkDatasetName, IMap map)
{
IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass() as IWorkspaceFactory;
IWorkspace workspace = workspaceFactory.OpenFromFile(sShapefilePath, 0);
IWorkspaceExtensionManager wsExtMgr = workspace as IWorkspaceExtensionManager;
UID myUID = New UIDClass();
myUID.Value = "esriGeoDatabase.NetworkDatasetWorkspaceExtension";
IWorkspaceExtension wsExt = wsExtMgr.FindExtension(myUID);
IDatasetContainer2 dsCont = wsExt as IDatasetContainer2;
IDataset dataset = dsCont.DatasetByName(esriDTNetworkDataset, networkDatasetName)
INetworkDataset networkDataset = dataset as INetworkDataset;
INetworkLayer networkLayer = New NetworkLayerClass();
networkLayer.NetworkDataset = networkDataset;
map.AddLayer(networkLayer);
}
The following code shows how to open a shapefile network dataset, then add it to a Map using a NetworkLayer:
Sub AddNetworkLayer(sShapefilePath As String, sNetworkDatasetName As String, pMap As IMap)
Dim pWorkspaceFactory As IWorkspaceFactory
Dim pWorkspace As IWorkspace
Dim pWSExtMgr As IWorkspaceExtensionManager
Dim pUID As New UID
Dim pWSExt As IWorkspaceExtension
Dim pDSCont As IDatasetContainer2
Dim pDataset As IDataset
Dim pNetworkDataset As INetworkDataset
Dim pNetworkLayer As INetworkLayer
Set pWorkspaceFactory = New ShapefileWorkspaceFactory
Set pWorkspace = pWorkspaceFactory.OpenFromFile(sShapefilePath, 0)
Set pWSExtMgr = pWorkspace
pUID.Value = "esriGeoDatabase.NetworkDatasetWorkspaceExtension"
Set pWSExt = pWSExtMgr.FindExtension(pUID)
Set pDSCont = pWSExt
Set pDataset = pDSCont.DatasetByName(esriDTNetworkDataset, sNetworkDatasetName)
Set pNetworkDataset = pDataset
Set pNetworkLayer = New NetworkLayer
Set pNetworkLayer.NetworkDataset = pNetworkDataset
pMap.AddLayer pNetworkLayer
End Sub
The following code shows how to open a shapefile network dataset, then add it to a Map using a NetworkLayer:
Sub AddNetworkLayer(shapefilePath As String, networkDatasetName As String, map As IMap)
Dim workspaceFactory As IWorkspaceFactory = New ShapefileWorkspaceFactory
Dim workspace As IWorkspace = workspaceFactory.OpenFromFile(sShapefilePath, 0)
Dim wsExtMgr As IWorkspaceExtensionManager = CType(workspace, IWorkspaceExtensionManager)
Dim myUID As New UID
myUID.Value = "esriGeoDatabase.NetworkDatasetWorkspaceExtension"
Dim wsExt As IWorkspaceExtension = wsExtMgr.FindExtension(myUID)
Dim dsCont As IDatasetContainer2 = CType(wsExt, IDatasetContainer2)
Dim dataset As IDataset = dsCont.DatasetByName(esriDTNetworkDataset, networkDatasetName)
Dim networkDataset As INetworkDataset = CType(dataset, INetworkDataset)
Dim networkLayer As INetworkLayer = New NetworkLayer
networkLayer.NetworkDataset = networkDataset
map.AddLayer(networkLayer)
End Sub
When working with NetworkLayer's default outbound interface in Visual Basic 6 declare variables as follows: Private WithEvents pNetworkLayer as NetworkLayer