English

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

Summary

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.

Procedure

Note:
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:

    Code:
    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:

    Code:
    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 :" & layerInfo.name)
    Response.Write("<br>)Visibility :" & layerInfo.visibility)
    Next

  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:

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


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