📄 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=4.0";
/*
***************************************************************************************
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 lastXMLResponse = "";
//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";
var requestMethod = "Servlet";
if (parent.connectorType!="") requestMethod = parent.connectorType;
// 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;
// adjust limit extent to match image proportions?
var adjustLimit=true;
// dynamic flag for setting focus on external attribute display
var focusOnData = false;
var extWin;
/// send in XML request and get XML response -
function sendToServer(URLString,XMLRequest,theType) {
if (parent.PostFrame.document.forms[0]!=null) {
if (okToSend) {
XMLMode = theType;
if (XMLMode==1) showRetrieveMap();
if (debugOn>2) alert(msgList[8] + URLString + msgList[9] + XMLRequest);
okToSend = false;
if (requestMethod.toUpperCase()=="JSP") {
// uses JSP Connector - must be installed and class path to arcims_jsp.jar set
jspSendToServer(URLString,XMLRequest,theType);
} else {
// default Servlet Connector
htmlSendToServer(URLString,XMLRequest,theType);
}
} else {
alert(msgList[10]);
hideRetrieveMap();
hideRetrieveData();
}
} else {
alert(msgList[11]);
hideRetrieveMap();
hideRetrieveData();
}
}
function htmlSendToServer(URLString,XMLRequest,theType) {
// uses default Servlet Connector - requestMethod="Servlet";
var cVersion = "&ClientVersion=4.0";
var thePostForm = parent.PostFrame.document.forms[0];
URLString = URLString + cVersion;
var requestURL = URLString;
if (thePostForm.RedirectURL!=null) {
if (isNotSameHostInURL(URLString, hostName)) {
requestURL = connectorURL;
thePostForm.RedirectURL.value = URLString;
} else {
thePostForm.RedirectURL.value = "";
}
}
thePostForm.action = requestURL + "&Form=True&Encode=False";
var xmlHeader = '<?xml version="1.0" ' + localeEncoding + '?>';
thePostForm.ArcXMLRequest.value = xmlHeader + XMLRequest;
//thePostForm.JavaScriptFunction.value = "parent.MapFrame.processXML";
if (thePostForm.FormCharset!=null) thePostForm.FormCharset.value = charSet;
if (thePostForm.BgColor!=null) thePostForm.BgColor.value = "#000000";
thePostForm.submit();
}
function jspSendToServer(URLString,XMLRequest,theType) {
// uses JSP Connector - must be installed
// class path to arcims_jsp.jar must be set
var cVersion = "&ClientVersion=4.0";
var theService = getService(URLString);
var theHost = getHost(URLString);
theService += cVersion;
// get the Post Form and set values, then submit to server
var thePostForm = parent.PostFrame.document.forms[0];
// set parameters for the AppServerLink
var xmlHeader = '<?xml version="1.0" ' + localeEncoding + '?>\n';
thePostForm.ArcXMLRequest.value=xmlHeader + XMLRequest;
thePostForm.ServerName.value=theHost;
thePostForm.ServiceName.value=theService;
// submit to Application Server
thePostForm.submit();
}
function getHost(theURL) {
var thisHost = "";
var startpos = theURL.indexOf("//");
if (startpos==-1) {
startpos = 0;
} else {
startpos = startpos + 2;
}
var endpos = theURL.indexOf("/",startpos);
if (endpos==-1) endpos = theURL.length;
thisHost = theURL.substring(startpos,endpos);
return thisHost;
}
function getService(theURL) {
var theService = "";
var startpos = theURL.indexOf("ServiceName=");
if (startpos!=-1) {
startpos +=12;
theService = theURL.substring(startpos);
}
return theService;
}
// 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;
}
lastXMLResponse = theReply;
okToSend = true;
if (debugOn>2) alert(msgList[13] + theReply);
var theError = getXMLErrorMessage(theReply);
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();
}
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;
}
}
if ((focusOnData) && (!useTextFrame)) {
if(extWin && extWin.open && !extWin.closed){
extWin.focus();
focusOnData = false;
extWin = null;
}
}
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) {
var pos = theReply.indexOf("<PROPERTIES");
var theXYs = getEnvelopeXYs(theReply, pos)
limitLeft = theXYs[0];
limitBottom = theXYs[1];
limitRight = theXYs[2];
limitTop = theXYs[3];
}
if (adjustLimit) {
//adjust limit to proportions of defined image size
//alert("Limits: " + limitLeft + ", " + limitBottom + ", " + limitRight + ", " + limitTop);
var imgW2HRatio = iWidth / iHeight;
var imgH2WRatio = iHeight / iWidth;
var itWidth = limitRight - limitLeft;
var itHeight = limitTop - limitBottom;
var mapRatio = itHeight / itWidth;
var ix = limitLeft + (itWidth/2);
var iy = limitBottom + (itHeight/2);
var iSize = itWidth/2;
if (iWidth>=iHeight) {
//alert("Image wider than tall");
if (imgH2WRatio<mapRatio) {
//alert("Map ratio greater than Image" );
iSize = (itHeight * imgW2HRatio) / 2;
limitRight = ix + iSize;
limitLeft = ix - iSize;
} else {
//alert("Limit wider than tall");
iSize = (itWidth * imgH2WRatio) / 2;
limitTop = iy + iSize;
limitBottom = iy - iSize;
}
} else {
//alert("Image taller than wide");
if (imgH2WRatio<mapRatio) {
//alert("Map ratio greater than Image");
iSize = (itHeight * imgH2WRatio) / 2;
limitRight = ix + iSize;
limitLeft = ix - iSize;
} else {
//alert("Map ratio smaller than Image");
iSize = (itWidth * imgH2WRatio) / 2;
limitTop = iy + iSize;
limitBottom = iy - iSize;
}
}
//alert("Adjusted Limits: " + limitLeft + ", " + limitBottom + ", " + limitRight + ", " + limitTop);
}
imageLimitLeft=limitLeft;
imageLimitRight=limitRight;
imageLimitTop=limitTop
imageLimitBottom=limitBottom;
fullLeft = limitLeft;
fullRight = limitRight;
fullTop = limitTop;
fullBottom = limitBottom;
fullWidth = Math.abs(fullRight - fullLeft);
fullHeight = Math.abs(fullTop - fullBottom);
fullOVWidth = Math.abs(fullOVRight - fullOVLeft);
fullOVHeight = Math.abs(fullOVTop - fullOVBottom);
// get service info - extent, layers
//alert("processXML()[4]\n" + theReply);
forceCommaInRequest[activeMapServiceIndex] = false;
processStartExtent(theReply);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -