English

How To: Zoom to selected features when using the Buffer tool

Summary

When using the buffer tool in the HTML Viewer, the extent of the resulting map will be the same as its previous extent. Instructions provided describe how to change the extent of the resulting map to the selected features.

Procedure

The steps below require editing aimsBuffer.js, aimsXML.js and aimsCustom.js files usually located under:
On Windows: <Drive:\>\ArcIMS\website\<website_name>\javascript.
On UNIX: $AIMSHOME/website/<website_name>/javascript.
Keep a copy of these files as backup, before editing the files.

Note:
The edited files are available for download in the Related Section below. Use these files in the Web site and skip the steps given below, if desired.

  1. Open aimsBuffer.js file in a text editor and find the bufferIt function. Change this function as shown below:

    Code:

    // buffer around selected features
    function bufferIt() {
    hideLayer("measureBox");
    //alert("Function not yet enabled.");
    showBuffer=true;

    /* code changed to zoom to the buffer results
    *
    */

    // sendMapXML();

    var buffString1 = writeGetBufferedData();
    if (buffString1!="") {
    sendToServer(imsQueryURL,buffString1,1001);
    } else {
    alert(msgList[15]);
    }

    //end new code
    }

  2. In the same aimsBuffer.js file, find GET_FEATURES string and set globalenvelope="true" attribute for this element as shown below:

    Code:

    var theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_FEATURES globalenvelope="true"
    outputmode="xml" envelope="false" geometry="false" checkesc ="true"';


    Note:
    The above changes must be made in three places in this file.

  3. Open aimsXML.js file and search for this block of code:

    Code:
    function processXML(theReplyIn) {

    Within this function, find this line:

    Code:
    if (aimsBufferPresent) {

    Comment out the following section of code as shown below:

    Code:

    /* if (aimsBufferPresent) {
    if (getBufferedData) {
    var buffString = writeGetBufferedData();
    if (buffString!="") {
    sendToServer(imsQueryURL,buffString,11);
    } else {
    alert(msgList[15]);
    }
    getBufferedData=false;
    }
    } */

  4. Open aimsCustom.js file in a text editor and find the function useCustomFunction. Change it as shown below:

    Code:

    function useCustomFunction(theReply) {
    if (XMLMode==1001) {
    // insert code here

    /* new code inserted here for zoom to buffer result
    *
    */
    if (getBufferedData) {
    getBufferAttributeData(theReply);
    }
    var theXYs = getEnvelopeXYs(theReply, 0);
    if (theXYs.length>0){
    eLeft = theXYs[0];
    eBottom = theXYs[1];
    eRight = theXYs[2];
    eTop = theXYs[3];
    sendMapXML();
    }
    else alert("No features found");

    //end of added code


    } else if (XMLMode==1002) {
    // insert code here
    } else {
    alert(msgList[55] + XMLMode + msgList[56]);
    }
    hideLayer("LoadData");
    }

    It is now possible to zoom to selected features when using the Buffer tool.

Related Information