Alter an HTML Viewer Web site to display a static legend

Last Published: April 25, 2020


In default HTML Viewer Web sites, the legend is dynamically generated and updated as a user zooms in or out.

In some circumstances, you may prefer a different legend than that generated by the default viewer.

As a basic solution, you can create your desired legend as a static image and edit the viewer to load it into the viewer's "TOCFrame" permanently. Edits are also required to prevent the static image from being overwritten by the default viewer's refresh functions.


  1. Create a legend image. For example, create a temporary Image service or ArcMap Image service that produces the desired legend display. Then send it a GET_IMAGE request, such as:

    <ARCXML version="1.1">
    <LEGEND title="Legend" font="Arial" autoextend="true" columns="1" width="170" height="300" backgroundcolor="255,255,255" >
    <DRAW map="false"/>

    Save the resulting legend image as theLegend.gif in the \images folder of the Web site.
  2. Create an HTML document called staticLegend.htm to display theLegend.gif:

    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <IMG SRC="images/theLegend.gif"/>

  3. Edit the following line in viewer.htm to load staticLegend.htm page

    document.writeln('<FRAME NAME="TOCFrame" SRC="StaticLegend.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="Auto" FRAMEBORDER="Yes" RESIZE="YES">');

  4. In ArcIMSparam.js, set ...

    var showTOC=false;

  5. The remaining files to be edited are all located in the \javascript folder of the web site. First, delete or rename aimsLegend.js.

  6. In aimsMap.js, set �

    var legendVisible=true;

  7. In aimsXML.js, edit the following:

    a. In the switchmode() function, under case 1, comment-out the showLegend function call:

    switch(XMLMode) {
    case 1:
    . �
    if (toolMode==20) {
    // if (legendVisible) {
    // showLegend();
    // }

    b. Do the same for case 98:

    case 98:
    // just put up a map with legend
    var theURL = "";
    theURL = getURL(theReply);
    if (theURL != "") {
    document.theImage.src = theURL;
    //else {
    // alert(theReply + "\nUnable to display Map image");

    //if (legendVisible) {
    // showLegend();
    // drawLegendOnly=false;

    c. Comment out cases 101, 102 and 103. You can use /* ...<code>... */ to enclose the necessary lines of code and thereby comment them out.
    d. In function writeXML(), comment out these lines:

    // if (aimsLegendPresent) {
    // // create a legend image
    // if (legendVisible) theString += addLegendToMap();
    // }

    e. In function getXYs(theString), comment out the long bolded line:

    if (aimsLayersPresent) {
    if (sFactor!=mapScaleFactor) {
    mapScaleFactor = sFactor;
    // if ((hasTOC) && (!legendVisible)) parent.TOCFrame.document.location = appDir + "toc.htm";
    if (aimsLayersPresent) {
    if (LayerListOpen) writeLayerListForm();


    f. In function getURL(theReply), comment out the bold line:

    theURL = getInsideString(theReply,'url="',dQuote,pos,0,false);
    //legendImage = getLegendURL(theReply);
    return theURL;


    g. Comment out function getLegendURL.

  8. In aimsClick.js, comment out the two occurances of the getLegend() function calls, e.g.,


Article ID:000007065

  • Legacy Products

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options