2

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.

2
  • 1
    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. Dec 1, 2010 at 1:46
  • Done, take a look please.
    – eiefai
    Dec 1, 2010 at 21:17

2 Answers 2

4

IMap:Layers and IEnumLayer http://edndoc.esri.com/arcobjects/9.1/componenthelp/esricarto/IMap_Layers.htm

3
  • not very helpful, but thans for the effor
    – eiefai
    Nov 30, 2010 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. Nov 30, 2010 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, 2010 at 23:30
2

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.

3
  • Are you using arcgis Server?
    – eiefai
    Nov 30, 2010 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, 2010 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, 2010 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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