Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
You're not clearly communicating what you need here based on the answers you've gotten so far -- you're adding a custom toolbar in SERVER? Does this mean you're somehow putting a toolbar on a web control in a browser, or does it mean you want to look for Server layers in the TOC in ArcMap? ArcGIS server in and of itself doesn't HAVE a UI to display a TOC control or a toolbar in. – Jason Scheirer Dec 1 '10 at 1:46
Done, take a look please. – eiefai Dec 1 '10 at 21:17
up vote 2 down vote accepted

I've used this 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()

' 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


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.

share|improve this answer
Are you using arcgis Server? – eiefai Nov 30 '10 at 23:38
I see I may have misunderstood your request. This is an ArcObjects solution for iterating through the TOC in ArcMap. Are you instead looking for a solution using one of the web APIs or .Net ADF? – Brenner256 Dec 1 '10 at 1:53
Yeah, I need something with .NET adf, I tried looking into the Map Functionality class without luck. Thanks Brenner. – eiefai Dec 1 '10 at 21:06

IMap:Layers and IEnumLayer

share|improve this answer
not very helpful, but thans for the effor – eiefai Nov 30 '10 at 21:15
If you follow the above link you will find a VB6 example showing how to iterate trough the layers. This can easily be updated to VB .net. You can alter is slightly to examine iLayer::Visible property. – Jakub Nov 30 '10 at 21:30
I mean, this is for arcobjects 9.1, besides, the Layers property doesn't exist in the map component in Arcgis Server 9.3... maybe I'm missing something but it's not as simpe as in the website example code. Thanks again. – eiefai Nov 30 '10 at 23:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.