+ Reply to Thread
Results 1 to 3 of 3

Thread: Turn off all Feature Layers

  1. #1
    DTM Consulting, Inc.
    Join Date
    May 2010
    Posts
    31
    Points
    1
    Answers Provided
    0


    0

    Default Turn off all Feature Layers

    This should be pretty simple, but I can't find an example of how to go about it.

    I have a map with around 40 FeatureLayers added. I have a request to add a Turn Off All Layers button so you can essentially clear the map of everything but the base layer. Can anyone point me in the right direction? VB.NET is preferable to C.

    Thanks!

  2. #2
    Dominique BROUX

    Join Date
    Jan 2010
    Posts
    2,409
    Points
    743
    Answers Provided
    130


    0

    Default Re: Turn off all Feature Layers

    Make a loop on yourMap.Layers, for each layer of type 'FeatureLayer' set layer.Visible to false.
    /Dominique

  3. #3
    DTM Consulting, Inc.
    Join Date
    May 2010
    Posts
    31
    Points
    1
    Answers Provided
    0


    0

    Default Re: Turn off all Feature Layers

    Thanks! Got it. That is exactly where I was headed. Here's the result. Works like a charm.

    Code:
     Dim myLayerCollection As ESRI.ArcGIS.Client.LayerCollection = MyMap.Layers
            'Dim myLayerCount As Double = myLayerCollection.Count
            'MessageBox.Show("Number of Layers in the Map:" + myLayerCount.ToString)
    
            Dim fl As FeatureLayer
    
            For Each l In myLayerCollection
                If TypeOf (l) Is FeatureLayer Then
                    fl = l
                    fl.Visible = False
                End If
            Next

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts