ESRI.ArcGIS.ADF.IMS
Remove Method
See Also  Example Send Feedback
ESRI.ArcGIS.ADF.IMS.Carto.Layer Namespace > LayerCollection Class : Remove Method




layer
The layer to remove.
Removes a layer from the collection.

Syntax

Visual Basic (Declaration) 
Public Sub Remove( _
   ByVal layer As Layer _
) 
Visual Basic (Usage)Copy Code
Dim instance As LayerCollection
Dim layer As Layer
 
instance.Remove(layer)
C# 
public void Remove( 
   Layer layer
)

Parameters

layer
The layer to remove.

Example

The following example removes a layer from the map's layer collection using a reference to the layer. The code assumes an existing MapView object.
C#Copy Code
// Get the layer collection from a MapView
ESRI.ArcGIS.ADF.IMS.Carto.Layer.LayerCollection mapLayers
mapLayers = mapView.Layers;
 
// Get a reference to the layer to remove
ESRI.ArcGIS.ADF.IMS.Carto.Layer.Layer layerX = mapLayers.FindByName("Countries");
 
// Remove the first (bottom) layer from the map
mapLayers.Remove(layerX);
Visual BasicCopy Code
' Get the layer collection from a MapView
Dim mapLayers As ESRI.ArcGIS.ADF.IMS.Carto.Layer.LayerCollection
mapLayers = mapView.Layers
 
' Get a reference To the layer To remove
Dim layerX As ESRI.ArcGIS.ADF.IMS.Carto.Layer.Layer = mapLayers.FindByName("Countries")
 
' Remove the first (bottom) layer from the map
mapLayers.Remove(layerX)

Remarks

This method removes a layer completely from the layer collection of the MapView orDataFrame. Both dynamic and static layers may be removed. After removal, the layer is not recoverable in the current MapView, unless a reference is maintained to the deleted layer and it is re-added (or unless a new MapView is generated from the MapService).

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2011 All Rights Reserved.