I'm developing website with a custom tool in ArcGis Server 9.3 using Visual Studio 2008 and the ADF components, the thing is that when I click on my custom tool it calls a class, this class needs to check each layer available to see if it is enabled and visible (this properties changes when you zoom out or zoom in), does anyone knows how to accomplish this? Thanks.
I've used this VB.net code to do tasks similar to what you are asking. This is shortened from memory so bear with me.
' Create layer enumerator ' Use IHookHelper focus map (or other reference to an IMap) Dim layerEnumerator As ArcGIS.Carto.IEnumLayer layerEnumerator = HookHelper.FocusMap.Layers() layerEnumerator.Reset() ' Loop through layers Dim layer As ArcGIS.Carto.ILayer layer = layerEnumerator.Next Do While Not layer Is Nothing MsgBox("Layer: " & layer.Name) ' Check to see if layer is valid If layer.Valid Then ' Do something... End If ' Check to see if layer is visible If layer.Visible Then ' Do something... End If ' Get the next layer in the enumerator layer = layerEnumerator.Next Loop
Update: If instead you are using the .Net Web ADF you might want to take a look at the MapFunctionality class here. I've not used it but the GetLayerInfo method appears to provide the information you need.
IMap:Layers and IEnumLayer http://edndoc.esri.com/arcobjects/9.1/componenthelp/esricarto/IMap_Layers.htm