Change the visibility for layers displayed on a map using ArcWeb Services v2006


Each data source contains a set of map layers that turn on and off by default at varied extents. Instructions provided describe how to override the default visibility for the map layers.


All code samples are written in VB.NET. See ArcWeb Developer's Guide for other code samples.

  1. To find the list of available layers at a given extent, make a request to getMaps with the parameter:

    mapImageOptions.returnLayers = True

  2. The Web service response contains the Layer object that shows the name and visibility for each layer. For more information on this object, see ArcWeb Developer's Guide:

    Dim myMapImageInfo As MapImageInfo = myMapImage.getBestMap(myMapImageOptions, 100, token)
    Dim myLayerInfoArray() As LayerInfo = myMapImageInfo.layers
    For Each layerInfo In myLayerInfoArray
    Response.Write("<br>Layer name :" &
    Response.Write("<br>)Visibility :" & layerInfo.visibility)

  3. In future getMaps requests, turn layers on and off using the displayLayers parameter. For each layer, set the name and the visibility. For more information on this parameter, see ArcWeb Developer's Guide:

    Dim myLayer As New MI.Layer = "U.S. States"
    myLayer.visibility = "on"
    Dim myLayerArray() As MI.Layer = {myLayer}
    myMapImageOptions.displayLayers = myLayerArray

    If a layer is not available for a given extent, it does not display on the map, and does not display an error.

Article ID:000008865

  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic