HOW TO

Implement the extract function in HTML Viewer

Last Published: April 26, 2020

Summary

Instructions provided describe how to implement the extract function in HTML Viewer. Using Extract Server in ArcIMS, it is possible to extract certain features of specified layers of an Image Service into a set of shapefiles, yielding one shapefile for each layer. Data can be extracted from shapefiles and ArcSDE vector layers served on an ArcIMS Image Service.

The out-of-box HTML Viewer does not include the necessary code to perform the extract function. This article explains how to customize HTML Viewer by adding the extract tool.

Upon clicking this extract tool, the data is extracted from the active layer within the map's current extent into a ZIP file, and the user is prompted to download the ZIP file.

Note:
For more information on extract functionality of ArcIMS, see the "Using GET_EXTRACT and EXTRACT" section in ArcXML Programmer's Reference Guide.

Procedure

This procedure requires edits to the map configuration file (.axl), ArcIMSParam.js file, and aimsCustom.js file from the Web site folder.
Note:
Steps 5 through 9 outline the individual code changes to enable the extract function for the aimsCustom.js file. A complete aimsCustom.js file, with all of the necessary code changes, is listed in step 10. This code can replace the existing contents of the aimsCustom.js file.
  1. Add the Extract extension to one of the layers in the map configuration AXL file as shown below:
    <LAYER type="featureclass" name="redlands" visible="true" id="0">
    	<DATASET name="redlands" type="line" workspace="shp_ws-0" />
    	<SIMPLERENDERER>
    	  <SIMPLELINESYMBOL width="1" captype="round" color="27,227,227" />
    	</SIMPLERENDERER>
          <EXTENSION type="Extract" >
              <EXTRACTPARAMS clip="true" />
          </EXTENSION>  
    </LAYER>
    Note:
    To enable the Extract Server, an Extract extension must be included with at least one layer in the map configuration file.
  2. Create a new Image Service using the above map configuration file in ArcIMS Administrator.
  3. Create an out-of-box HTML Viewer using ArcIMS Designer.
  4. Open the ArcIMSParam.js file in a text editor from the Web site's working directory (for example, <drive>:\ArcIMS\Website\<website_name>), and find this line:
    var useExtract=false;
    And change it to:
    var useExtract=true;
  5. Open the aimsCustom.js file located in the javascript folder (for example, <drive>:\ArcIMS\Website\<website_name>\javascript) in a text editor.
  6. Create two new global variables as given below:
    var extractXMLMode=1111;
    var imsExtractURL = imsURL + '&CustomService=Extract'
  7. Find this line:
    function useCustomFunction(theReply)
    Change the function to look like the code below:
    function useCustomFunction(theReply) {
    	if (XMLMode==1001) {
    		// Insert code here.
    	} else if (XMLMode==1111) {
    		parseExtractResponse(theReply);
    	} else {
    		alert(msgList[55] + XMLMode + msgList[56]);
    	}
    	hideLayer("LoadData");
    }
  8. Find this line:
    function extractIt() {
    Change the function to look like the code below:
    // Extract layers to download.
    function extractIt() {
    	hideLayer("measureBox");
    	//alert(msgList[51]);
    
    if (checkIfActiveLayerAvailable()) {
       sendExtractRequest();
      }
    
    }
  9. Add the following lines of code to the end of the file:
    function sendExtractRequest(){
     var extractAXL="";
     //extractAXL += '<?xml version="1.0" encoding="UTF-8"?>\n';
     extractAXL += '<ARCXML version="1.1">\n';
     extractAXL += '<REQUEST>\n';
     extractAXL += ' <GET_EXTRACT>\n';
     extractAXL += '   <PROPERTIES>\n';
     extractAXL += '     <ENVELOPE minx="' + forceComma(eLeft) + '" miny="' + forceComma(eBottom) + '" maxx="' + forceComma(eRight) + '" maxy="' + forceComma(eTop) + '" />\n';
     extractAXL += '       <LAYERLIST>\n';
     extractAXL += '         <LAYERDEF id="' + ActiveLayer + '" visible="true" />\n';
     extractAXL += '       </LAYERLIST>\n';
     extractAXL += '   </PROPERTIES>\n';
     extractAXL += ' </GET_EXTRACT>\n';
     extractAXL += '</REQUEST>\n';
     extractAXL += '</ARCXML>\n';
    
    sendToServer(imsExtractURL, extractAXL ,extractXMLMode);
    }
    function parseExtractResponse(theResponse){
    
      var extractURL = getURL(theResponse);
      //alert(extractURL);
      if(extractURL!="")  var Win1 = open(extractURL);
     
    }
Save the file.
  1. If Step 5 to Step 9 are skipped, copy the code from below and paste it to an empty text file. Name this file aimsCustom.js. Create a backup copy of the original aimsCustom.js file and replace it with this new code.
    // aimsCustom.js
    /*
    * JavaScript template file for ArcIMS HTML Viewer
    * 		dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js,
    * 		aimsLayers.js, aimsDHTML.js
    * 		aimsClick.js, aimsNavigation.js,
    */
    
    // Global variables
    	aimsCustomPresent=true;
    	// Change these to send XML response to custom function.
    	// Use numbers >= 1000 and match in useCustomFunction().
    	// Defaults are defined in aimsXML.js and use standard functions.
    
    	// xml response mode for selection
    	selectXMLMode = 6;
    	// xml response mode for identify
    	identifyXMLMode = 7;
    	// xml response mode for query
    	queryXMLMode = 8;
    	// xml response mode for find
    	findXMLMode = 14;
    	// xml response mode hyperlink
    	hyperlinkXMLMode = 15;
    
    var extractXMLMode=1111;
    var imsExtractURL = imsURL + '&CustomService=Extract'
    
    // Custom function for handling clicks
    // 		flow redirected here when
    // 		toolMode set to >=1000
    function customMapTool(e) {
    			if (toolMode == 1001) {
    					// Insert code here.
    					return false;
    
    			}
    			if (toolMode == 1002) {
    					// Insert code here.
    			
    			}
    }
    
    // Send XML response to custom function
    // 		flow redirected here when
    // 		XMLMode >=1000
    function useCustomFunction(theReply) {
    	if (XMLMode==1001) {
    		// Insert code here.
    	} else if (XMLMode==1111) {
    		parseExtractResponse(theReply);
    	} else {
    		alert(msgList[55] + XMLMode + msgList[56]);
    	}
    	hideLayer("LoadData");
    }
    
    // Add custom stuff to Map XML request. . . between selection and geocode.
    function addCustomToMap1(){
    	var customString = "";
    	/*
    		customString += '<LAYER type="ACETATE" name="theMode">\n';
    		customString += '<OBJECT units="PIXEL">\n<TEXT coord="5 ' + (iHeight-10) + '" label="This is a test">\n';
    		customString += '<TEXTMARKERSYMBOL fontstyle="BOLD" fontsize="12" font="ARIAL" fontcolor="' + modeMapColor + '" ';
    		customString += 'threed="TRUE" glowing="' + modeMapGlow + '" />\n</TEXT>\n</OBJECT>';
    		customString += '\n</LAYER>\n';
    	*/
    	return customString;
    }
    
    // Add custom stuff to Map XML request. . . between clickpoints and copyright.
    function addCustomToMap2(){
    	var customString = "";
    
    	return customString;
    }
    
    // Add custom stuff to Map XML request. . . under modeOnMap.
    function addCustomToMap3(){
    	var customString = "";
    		/*
    		customString += '<LAYER type="ACETATE" name="theMode">\n';
    		customString += '<OBJECT units="PIXEL">\n<TEXT coord="5 ' + (iHeight-10) + '" label="This is a test">\n';
    		customString += '<TEXTMARKERSYMBOL fontstyle="BOLD" fontsize="12" font="ARIAL" fontcolor="' + modeMapColor + '" ';
    		customString += 'threed="TRUE" glowing="' + modeMapGlow + '" />\n</TEXT>\n</OBJECT>';
    		customString += '\n</LAYER>\n';
    		alert(customString);
    		*/
    	return customString;
    }
    
    // Add custom stuff to Map XML request. . . on top of everything.
    function addCustomToMap4(){
    	var customString = "";
    
    	return customString;
    }
    
    // Extract layers to download.
    function extractIt() {
    	hideLayer("measureBox");
    	//alert(msgList[51]);
    
    if (checkIfActiveLayerAvailable()) {
       sendExtractRequest();
      }
    
    }
    
    
    function sendExtractRequest(){
     var extractAXL="";
     //extractAXL += '<?xml version="1.0" encoding="UTF-8"?>\n';
     extractAXL += '<ARCXML version="1.1">\n';
     extractAXL += '<REQUEST>\n';
     extractAXL += ' <GET_EXTRACT>\n';
     extractAXL += '  <PROPERTIES>\n';
     extractAXL += '   <ENVELOPE minx="' + forceComma(eLeft) + '" miny="' + forceComma(eBottom) + '" maxx="' + forceComma(eRight) + '" maxy="' + forceComma(eTop) + '" />\n';
     extractAXL += '    <LAYERLIST>\n';
     extractAXL += '     <LAYERDEF id="' + ActiveLayer + '" visible="true" />\n';
     extractAXL += '    </LAYERLIST>\n';
     extractAXL += '  </PROPERTIES>\n';
     extractAXL += ' </GET_EXTRACT>\n';
     extractAXL += '</REQUEST>\n';
     extractAXL += '</ARCXML>\n';
    
    sendToServer(imsExtractURL, extractAXL ,extractXMLMode);
    }
    
    
    function parseExtractResponse(theResponse){
    
      var extractURL = getURL(theResponse);
      //alert(extractURL);
      if(extractURL!="") var Win1 = open(extractURL);
    
    }

Article ID:000006270

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic