📄 aimsxml.js
字号:
// aimsXML.js
/*
* JavaScript template file for ArcIMS HTML Viewer
* dependent on ArcIMSparam.js, aimsCommon.js, aimsMap.js,
*/
aimsXMLPresent=true;
// client version
var cVersion = "&ClientVersion=3.1";
/*
***************************************************************************************
Functions for sending XML requests and XML reponses
***************************************************************************************
*/
// global variables
// change these in aimsCustom.js to send XML response to custom function.
// use numbers >= 1000
var selectXMLMode = 6;
var identifyXMLMode = 7;
var queryXMLMode = 8;
var findXMLMode = 14;
var hyperlinkXMLMode = 15;
// encoding for XML header
var charEncoding = "UTF-8";
var localeEncoding = 'encoding="' + charEncoding + '" ';
// charset for dynamic HTML pages - static pages must be changed manually
var charSet = "ISO-8859-1"
var formColor = "#000000";
// common dynamic variables
var XMLMode = 1;
var okToSend = true;
var xHalf = xDistance/2;
var yHalf = yDistance/2;
// ending position to start parse scan of XML string
var xmlEndPos = 0;
//var theImageType = "PNG";
var drawOVExtentBox=false;
// force a request for Overview map image with each map request?
var forceNewOVMap = false;
// the base servlet connector URL
var connectorURL = "http://" + hostName + "/servlet/com.esri.esrimap.Esrimap?ServiceName=redirect";
// index of current active MapService - default is zero - multiples in MultiService sample
var activeMapServiceIndex = 0;
// array for determining if extent coordinates should have comma instead of point for decimals
var forceCommaInRequest = new Array();
forceCommaInRequest[activeMapServiceIndex] = false;
var forceCommaInOV = false;
var pastStart=false;
if (hasOVMap != true) pastStart = true;
// send in XML request and get XML response - uses helper applet
function sendToServer(URLString,XMLRequest,theType) {
if (parent.PostFrame.document.forms[0]!=null) {
if (okToSend) {
XMLMode = theType;
if (XMLMode==1) showRetrieveMap();
//theForm = parent.AppletFrame.document.forms[0];
if (debugOn>2) alert(msgList[8] + URLString + msgList[9] + XMLRequest);
okToSend = false;
var theForm = parent.PostFrame.document.forms[0];
URLString = URLString + cVersion;
var requestURL = URLString;
if (theForm.RedirectURL!=null) {
if (isNotSameHostInURL(URLString, hostName)) {
requestURL = connectorURL;
theForm.RedirectURL.value = URLString;
} else {
theForm.RedirectURL.value = "";
}
}
//alert(URLString);
if (doURLencode) {
theForm.action = requestURL + "&Form=True&Encode=True";
} else {
theForm.action = requestURL + "&Form=True&Encode=False";
}
var xmlHeader = '<?xml version="1.0" ' + localeEncoding + '?>';
theForm.ArcXMLRequest.value = xmlHeader + XMLRequest;
//if (theForm.FormCharset!=null) theForm.FormCharset.value = charEncoding;
if (theForm.FormCharset!=null) theForm.FormCharset.value = charSet;
//alert("ServiceName: " + theForm.action + "\nXMLRequest:\n " + theForm.xmlRequest.value);
if (theForm.BgColor!=null) theForm.BgColor.value = formColor;
theForm.submit();
} else {
alert(msgList[10]);
hideRetrieveMap();
hideRetrieveData();
}
} else {
alert(msgList[11]);
hideRetrieveMap();
hideRetrieveData();
}
}
// send custom XML request. . . set up custom response handler
function sendCustomToServer(XMLRequest, theFunction, theType) {
var theForm = parent.PostFrame.document.forms[0];
theForm.JavaScriptFunction.value = theFunction;
sendToServer(imsQueryURL,XMLRequest,theType)
}
// send the created xml request to map server
function sendMapXML() {
// ask for the Main map
//window.onerror=clearError;
beforeMapRefresh();
//window.onerror=resetError;
showRetrieveMap();
var theText = writeXML();
if (debugOn==2) alert(msgList[12] + theText);
sendToServer(imsURL,theText,1);
}
// process the response xml
function processXML(theReplyIn) {
if (doURLencode) {
theReplyIn = replacePlus(theReplyIn);
var theReply = unescape(theReplyIn);
} else {
var theReply = theReplyIn;
}
okToSend = true;
if (debugOn>2) alert(msgList[13] + theReply);
var theError = getXMLErrorMessage(theReply);
//if (theError!="") {
// alert(theError);
//} else {
switch(XMLMode) {
case 1:
//alert ("Received:\n\n" + theReply);
var theURL = "";
theURL = getURL(theReply);
//alert(theURL);
if (theURL != "") {
getXYs(theReply);
document.theImage.src = theURL;
afterMapRefresh();
//window.onerror=resetError;
if (toolMode==3) {
moveLayer("theMap",hspc,vspc);
clipLayer2("theMap",0,0,iWidth,iHeight);
window.setTimeout('showLayer("theMap");',1000);
if (hasLayer("theMapClicks")) {
moveLayer("theMapClicks",hspc,vspc);
clipLayer2("theMapClicks",0,0,iWidth,iHeight);
}
}
}
else {
if (debugOn>0) {
alert(msgList[14] + "\n" + theReply);
} else {
alert(msgList[14] + theError);
}
}
if (toolMode==20) {
updateMeasureBox();
}
if (legendVisible) {
showLegend();
}
if (hasOVMap) {
if (ovIsVisible) {
// ask for the overview
if ((!pastStart) || (forceNewOVMap)) {
theText = writeOVXML();
//pastStart=true;
sendToServer(imsOVURL,theText,2);
} else {
putExtentOnOVMap();
hideRetrieveMap();
}
} else {
if ((!pastStart) || (forceNewOVMap)) {
theText = writeOVXML();
sendToServer(imsOVURL,theText,2);
} else {
hideRetrieveMap();
}
}
} else {
hideRetrieveMap();
}
if (aimsBufferPresent) {
if (getBufferedData) {
var buffString = writeGetBufferedData();
if (buffString!="") {
sendToServer(imsQueryURL,buffString,11);
} else {
alert(msgList[15]);
}
getBufferedData=false;
}
}
break
case 2:
// just put up an overview map
var theURL = "";
theURL = getURL(theReply);
if (!pastStart) {
getOVXYs(theReply);
pastStart=true;
}
//alert(theURL);
if (theURL != "") {
ovImageVar.src = theURL;
}
else {
if (debugOn>0) {
alert(msgList[16] + "\n" + theReply);
} else {
alert(msgList[16] + theError);
}
}
if (ovIsVisible) putExtentOnOVMap();
hideRetrieveMap();
break
case 3:
// just get full extent - service info
//alert("processXML()[3]\n" + theReply);
if (getLimitExtent) {
getXYs(theReply);
fullLeft = eLeft;
fullRight = eRight;
fullTop = eTop;
fullBottom = eBottom;
fullOVLeft = eLeft;
fullOVRight = eRight;
fullOVTop = eTop;
fullOVBottom = eBottom;
limitLeft = eLeft;
limitRight = eRight;
limitTop = eTop;
limitBottom = eBottom;
//if ((hasOVMap) && (imsURL!=imsOVURL)) forceCommaInOV = forceCommaInRequest[activeMapServiceIndex];
//if ((hasOVMap) && (imsURL==imsOVURL)) forceCommaInOV = true;
} else {
fullLeft = limitLeft;
fullRight = limitRight;
fullTop = limitTop;
fullBottom = limitBottom;
fullOVLeft = limitLeft;
fullOVRight = limitRight;
fullOVTop = limitTop;
fullOVBottom = limitBottom;
}
fullWidth = Math.abs(fullRight - fullLeft);
fullHeight = Math.abs(fullTop - fullBottom);
fullOVWidth = Math.abs(fullOVRight - fullOVLeft);
fullOVHeight = Math.abs(fullOVTop - fullOVBottom);
theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_SERVICE_INFO />\n';
theString += '</REQUEST>\n</ARCXML>';
// get list of geocoding layers
if((aimsGeocodePresent) && ((useGeocode) || (useReverseGeocode))) {
theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_SERVICE_INFO renderer="false" />\n';
theString += '</REQUEST>\n</ARCXML>';
sendToServer(imsGeocodeURL,theString,25);
} else {
theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_SERVICE_INFO renderer="false" extensions="true" />\n';
theString += '</REQUEST>\n</ARCXML>';
sendToServer(imsURL,theString,4);
useGeocode=false;
useReverseGeocode=false;
}
break
case 4:
// get service info - extent, layers
//alert("processXML()[4]\n" + theReply);
forceCommaInRequest[activeMapServiceIndex] = false;
processStartExtent(theReply);
break
case 5:
// get a list of ImageServices
//alert("processXML()[5]\n" + theReply);
processCatalog(theReply);
break
case 6:
// get select response
displayAttributeData(theReply);
break
case 7:
// get identify response
//alert(theReply);
displayAttributeData(theReply);
break
case 8:
// get query response
//alert("processXML()[8]\nQuery XML Response:\n" + theReply);
displayAttributeData(theReply);
break
case 9:
// get geocode response
processGeocode(theReply);
break
case 10:
// get identifyall response
doIdentifyAll(theReply);
break
case 11:
// get buffer response
getBufferAttributeData(theReply)
break
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -