PROBLEM

Web Mapping Application only turns on the first 10 layers in the Table of Contents control for WMS services

Last Published: April 25, 2020

Description

Web Mapping Applications built with ArcGIS Server for the Microsoft .Net Framework or ArcGIS Server for the Java Platform only turn on the first 10 layers in the Table of Contents control for WMS services. This is analogous to the behavior in Desktop, where only the first 10 layers of a WMS service are turned on initially, by default.

Cause

The main reason that this limit is set for WMS services in Web Mapping Applications is to improve the performance and usability. More times than not, a WMS service has hundreds of layers available in its capabilities file, and turning them on all together usually causes a long delay or even a timeout during the Web Mapping Application's initialization.

Solution or Workaround

This default behavior can be overridden and the number of layers in the Table of Content control that will be turned initially in the Web Mapping Application can be set. The following steps describe how to change a .Net Web Mapping Application.

  1. Go to the folder of the Web Mapping Application and locate the file named 'Default.aspx.cs'.
  2. Edit the 'Default.aspx.cs' file in a text editor and locate the method:
    Code:
    protected void Page_Init(object sender, EventArgs e)
    {
    ...
    }

  3. Set the number of layers to be turned on initially by setting the variable wmsMapResource.MaxInitialSelectedLayers:
    Code:
    protected void Page_Init(object sender, EventArgs e)
    {

    IMapResource mapResource = MapResourceManager1.GetResource("MapResourceItem0");

    if (mapResource != null)
    {

    ESRI.ArcGIS.ADF.Web.DataSources.OGCWMSService.MapResource wmsMapResource =

    mapResource as ESRI.ArcGIS.ADF.Web.DataSources.OGCWMSService.MapResource;
    if (wmsMapResource != null)
    {
    wmsMapResource.MaxInitialSelectedLayers = 25; //Example of turning on the first 25 layers by default
    }
    }

    }

  4. Save the changes and restart the Web Mapping Application.

Article ID:000009862

Software:
  • ArcGIS Server

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic