English

How To: Alter an HTML Viewer Web site to display a static legend

Summary

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.

Procedure

  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:

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


    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:

    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <HTML>
    <HEAD>
    <TITLE>Untitled</TITLE>
    </HEAD>
    <IMG SRC="images/theLegend.gif"/>
    </BODY>
    </HTML>

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

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

  4. In ArcIMSparam.js, set ...

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

    Code:
    var legendVisible=true;

  7. In aimsXML.js, edit the following:

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

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



    b. Do the same for case 98:

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

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


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

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

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

    Code:
    //getLegend();