ESRI.ArcGIS.ADF.IMS
Remove Method
See Also  Example
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).

See Also

© 2010 All Rights Reserved.