aimsXML.js
上传用户:gzuoyue
上传日期:2022-07-08
资源大小:177k
文件大小:35k
源码类别:

GIS编程

开发平台:

ASP/ASPX

  1. // aimsXML.js
  2. /*
  3. *  JavaScript template file for ArcIMS HTML Viewer
  4. * dependent on ArcIMSparam.js, aimsCommon.js, aimsMap.js,
  5. */
  6. aimsXMLPresent=true;
  7. // client version
  8. var cVersion = "&ClientVersion=4.0"; 
  9. /*
  10. ***************************************************************************************
  11. Functions for sending XML requests and XML reponses
  12. ***************************************************************************************
  13. */
  14. // global variables
  15. // change these in aimsCustom.js to send XML response to custom function.
  16. // use numbers >= 1000
  17. var selectXMLMode = 6;
  18. var identifyXMLMode = 7;
  19. var queryXMLMode = 8;
  20. var findXMLMode = 14;
  21. var hyperlinkXMLMode = 15;
  22. // encoding for XML header
  23. var charEncoding = "UTF-8";
  24. var localeEncoding = 'encoding="' + charEncoding + '" ';
  25. // charset for dynamic HTML pages - static pages must be changed manually
  26. var charSet = "GB2312"
  27. var formColor = "#000000";
  28. // common dynamic variables
  29. var XMLMode = 1;
  30. var okToSend = true;
  31. var xHalf = xDistance/2;
  32. var yHalf = yDistance/2;
  33. // ending position to start parse scan of XML string
  34. var xmlEndPos = 0;
  35. var lastXMLResponse = "";
  36. //var theImageType = "PNG";
  37. var drawOVExtentBox=false;
  38. // force a request for Overview map image with each map request?
  39. var forceNewOVMap = false;
  40. // the base servlet connector URL
  41. var connectorURL = "http://" + hostName + "/servlet/com.esri.esrimap.Esrimap?ServiceName=redirect";
  42. var requestMethod = "Servlet";
  43. if (parent.connectorType!="") requestMethod = parent.connectorType;
  44. // index of current active MapService - default is zero - multiples in MultiService sample
  45. var activeMapServiceIndex = 0;
  46. // array for determining if extent coordinates should have comma instead of point for decimals
  47. var forceCommaInRequest = new Array();
  48. forceCommaInRequest[activeMapServiceIndex] = false;
  49. var forceCommaInOV = false;
  50. var pastStart=false;
  51. if (hasOVMap != true) pastStart = true;
  52. // adjust limit extent to match image proportions?
  53. var adjustLimit=true;
  54. // dynamic flag for setting focus on external attribute display
  55. var focusOnData = false;
  56. var extWin;
  57. /// send in XML request and get XML response - 
  58. function sendToServer(URLString,XMLRequest,theType) {
  59. if (parent.PostFrame.document.forms[0]!=null) {
  60. if (okToSend) {
  61. XMLMode = theType;
  62. if (XMLMode==1) showRetrieveMap();
  63. if (debugOn>2) alert(msgList[8] + URLString + msgList[9] + XMLRequest);
  64. okToSend = false;
  65. if (requestMethod.toUpperCase()=="JSP") {
  66. // uses JSP Connector - must be installed and class path to arcims_jsp.jar set
  67. jspSendToServer(URLString,XMLRequest,theType);
  68. } else {
  69. // default Servlet Connector
  70. htmlSendToServer(URLString,XMLRequest,theType);
  71. }
  72. } else {
  73. alert(msgList[10]);
  74. hideRetrieveMap();
  75. hideRetrieveData();
  76. }
  77. } else {
  78. alert(msgList[11]);
  79. hideRetrieveMap();
  80. hideRetrieveData();
  81. }
  82. }
  83. function htmlSendToServer(URLString,XMLRequest,theType) {
  84. // uses default Servlet Connector - requestMethod="Servlet";
  85. var cVersion = "&ClientVersion=4.0";
  86. var thePostForm = parent.PostFrame.document.forms[0];
  87. URLString = URLString + cVersion;
  88. var requestURL = URLString;
  89. if (thePostForm.RedirectURL!=null) {
  90. if (isNotSameHostInURL(URLString, hostName)) {
  91. requestURL = connectorURL;
  92. thePostForm.RedirectURL.value = URLString;
  93. } else {
  94. thePostForm.RedirectURL.value = "";
  95. }
  96. }
  97. thePostForm.action = requestURL + "&Form=True&Encode=False";
  98. var xmlHeader = '<?xml version="1.0" ' + localeEncoding + '?>';
  99. thePostForm.ArcXMLRequest.value = xmlHeader + XMLRequest;
  100. //thePostForm.JavaScriptFunction.value = "parent.MapFrame.processXML";
  101. if (thePostForm.FormCharset!=null) thePostForm.FormCharset.value = charSet;
  102. if (thePostForm.BgColor!=null) thePostForm.BgColor.value = "#000000";
  103. thePostForm.submit();
  104. }
  105. function jspSendToServer(URLString,XMLRequest,theType) {
  106. // uses JSP Connector - must be installed
  107. // class path to arcims_jsp.jar must be set
  108. var cVersion = "&ClientVersion=4.0";
  109. var theService = getService(URLString);
  110. var theHost = getHost(URLString);
  111. theService += cVersion;
  112. // get the Post Form and set values, then submit to server
  113. var thePostForm = parent.PostFrame.document.forms[0];
  114. // set parameters for the AppServerLink
  115. var xmlHeader = '<?xml version="1.0" ' + localeEncoding + '?>n';
  116. thePostForm.ArcXMLRequest.value=xmlHeader + XMLRequest;
  117. thePostForm.ServerName.value=theHost;
  118. thePostForm.ServiceName.value=theService;
  119. // submit to Application Server
  120. thePostForm.submit();
  121. }
  122. function getHost(theURL) {
  123. var thisHost = "";
  124. var startpos = theURL.indexOf("//");
  125. if (startpos==-1) {
  126. startpos = 0;
  127. } else {
  128. startpos = startpos + 2;
  129. }
  130. var endpos = theURL.indexOf("/",startpos);
  131. if (endpos==-1) endpos = theURL.length;
  132. thisHost = theURL.substring(startpos,endpos);
  133. return thisHost;
  134. }
  135. function getService(theURL) {
  136. var theService = "";
  137. var startpos = theURL.indexOf("ServiceName=");
  138. if (startpos!=-1) {
  139. startpos +=12;
  140. theService = theURL.substring(startpos);
  141. }
  142. return theService;
  143. }
  144. // send custom XML request. . . set up custom response handler
  145. function sendCustomToServer(XMLRequest, theFunction, theType) {
  146. var theForm = parent.PostFrame.document.forms[0];
  147. theForm.JavaScriptFunction.value = theFunction;
  148. sendToServer(imsQueryURL,XMLRequest,theType)
  149. }
  150. // send the created xml request to map server
  151. function sendMapXML() {
  152. // ask for the Main map
  153. //window.onerror=clearError;
  154. beforeMapRefresh();
  155. //window.onerror=resetError;
  156. showRetrieveMap();
  157. var theText = writeXML();
  158. if (debugOn==2) alert(msgList[12] + theText);
  159. sendToServer(imsURL,theText,1);
  160. }
  161. // process the response xml
  162. function processXML(theReplyIn) {
  163. //alert(XMLMode);
  164. if (doURLencode) {
  165. theReplyIn = replacePlus(theReplyIn);
  166. var theReply = unescape(theReplyIn);
  167. } else {
  168. var theReply = theReplyIn;
  169. }
  170. lastXMLResponse = theReply;
  171. okToSend = true;
  172. if (debugOn>2) alert(msgList[13] + theReply);
  173. var theError = getXMLErrorMessage(theReply);
  174. switch(XMLMode) {
  175. case 1:
  176. //alert ("Received:nn" + theReply);
  177. var theURL = "";
  178. theURL = getURL(theReply);
  179. //alert(theURL);
  180. if (theURL != "") {
  181. getXYs(theReply);
  182. document.theImage.src = theURL;
  183. afterMapRefresh();
  184. }
  185. else {
  186. if (debugOn>0) {
  187. alert(msgList[14] + "n" + theReply);
  188. } else {
  189. alert(msgList[14] + theError);
  190. }
  191. }
  192. if (toolMode==20) {
  193. updateMeasureBox();
  194. }
  195. if (legendVisible) {
  196. showLegend();
  197. }
  198. if (hasOVMap) {
  199. if (ovIsVisible) {
  200. // ask for the overview
  201. if ((!pastStart) || (forceNewOVMap)) {
  202. theText = writeOVXML();
  203. //pastStart=true;
  204. sendToServer(imsOVURL,theText,2);
  205. } else {
  206. putExtentOnOVMap();
  207. hideRetrieveMap();
  208. }
  209. } else {
  210. if ((!pastStart) || (forceNewOVMap)) {
  211. theText = writeOVXML();
  212. sendToServer(imsOVURL,theText,2);
  213. } else {
  214. hideRetrieveMap();
  215. }
  216. }
  217. } else {
  218. hideRetrieveMap();
  219. }
  220. if (aimsBufferPresent) {
  221. if (getBufferedData) {
  222. var buffString = writeGetBufferedData();
  223. if (buffString!="") {
  224. sendToServer(imsQueryURL,buffString,11);
  225. } else {
  226. alert(msgList[15]);
  227. }
  228. getBufferedData=false;
  229. }
  230. if ((focusOnData) && (!useTextFrame)) {
  231.   if(extWin && extWin.open && !extWin.closed){
  232.     extWin.focus();
  233.     focusOnData = false;
  234.     extWin = null;
  235.    }
  236. }
  237. break;
  238. case 2:
  239. // just put up an overview map
  240. var theURL = "";
  241. theURL = getURL(theReply);
  242. if (!pastStart) {
  243. getOVXYs(theReply);
  244. pastStart=true;
  245. }
  246. //alert(theURL);
  247. if (theURL != "") {
  248. ovImageVar.src = theURL; 
  249. }
  250. else {
  251. if (debugOn>0) {
  252. alert(msgList[16] + "n" + theReply);
  253. } else {
  254. alert(msgList[16] + theError);
  255. }
  256. }
  257. if (ovIsVisible) putExtentOnOVMap();
  258. hideRetrieveMap();
  259. break;
  260. case 3:
  261. //  just get full extent - service info
  262. //alert("processXML()[3]n" + theReply);
  263. if (getLimitExtent) {
  264. var pos = theReply.indexOf("<PROPERTIES");
  265. var theXYs =  getEnvelopeXYs(theReply, pos)
  266. limitLeft = theXYs[0];
  267. limitBottom = theXYs[1];
  268. limitRight = theXYs[2];
  269. limitTop = theXYs[3];
  270. }
  271. if (adjustLimit) {
  272. //adjust limit to proportions of defined image size
  273. //alert("Limits: " + limitLeft + ", " + limitBottom + ", " + limitRight + ", " + limitTop);
  274. var imgW2HRatio = iWidth / iHeight;
  275. var imgH2WRatio = iHeight / iWidth;
  276. var itWidth = limitRight - limitLeft;
  277. var itHeight = limitTop - limitBottom;
  278. var mapRatio = itHeight / itWidth;
  279. var ix = limitLeft + (itWidth/2);
  280. var iy = limitBottom + (itHeight/2);
  281. var iSize = itWidth/2;
  282. if (iWidth>=iHeight) {
  283. //alert("Image wider than tall");
  284. if (imgH2WRatio<mapRatio) {
  285. //alert("Map ratio greater than Image" );
  286. iSize = (itHeight * imgW2HRatio) / 2;
  287. limitRight = ix + iSize;
  288. limitLeft = ix - iSize;
  289. } else {
  290. //alert("Limit wider than tall");
  291. iSize = (itWidth * imgH2WRatio) / 2;
  292. limitTop = iy + iSize;
  293. limitBottom = iy - iSize;
  294. }
  295. } else {
  296. //alert("Image taller than wide");
  297. if (imgH2WRatio<mapRatio) {
  298. //alert("Map ratio greater than Image");
  299. iSize = (itHeight * imgH2WRatio) / 2;
  300. limitRight = ix + iSize;
  301. limitLeft = ix - iSize;
  302. } else {
  303. //alert("Map ratio smaller than Image");
  304. iSize = (itWidth * imgH2WRatio) / 2;
  305. limitTop = iy + iSize;
  306. limitBottom = iy - iSize;
  307. }
  308. }
  309. //alert("Adjusted Limits: " + limitLeft + ", " + limitBottom + ", " + limitRight + ", " + limitTop);
  310. }
  311. imageLimitLeft=limitLeft;
  312. imageLimitRight=limitRight;
  313. imageLimitTop=limitTop
  314. imageLimitBottom=limitBottom;
  315. fullLeft = limitLeft;
  316. fullRight = limitRight;
  317. fullTop = limitTop;
  318. fullBottom = limitBottom;
  319. fullWidth = Math.abs(fullRight - fullLeft);
  320. fullHeight = Math.abs(fullTop - fullBottom);
  321. fullOVWidth = Math.abs(fullOVRight - fullOVLeft);
  322. fullOVHeight = Math.abs(fullOVTop - fullOVBottom);
  323. // get service info - extent, layers
  324. //alert("processXML()[4]n" + theReply);
  325. forceCommaInRequest[activeMapServiceIndex] = false;
  326. processStartExtent(theReply);
  327. //alert('ok')
  328. break;
  329. case 5:
  330. // get a list of ImageServices
  331. //alert("processXML()[5]n" + theReply);
  332. processCatalog(theReply);
  333. break;
  334. case 6:
  335. // get select response
  336. displayAttributeData(theReply);
  337. break;
  338. case 7:
  339. // get identify response
  340. //alert(theReply);
  341. displayAttributeData(theReply);
  342. break;
  343. case 8:
  344. // get query response
  345. //alert("processXML()[8]nQuery XML Response:n" + theReply);
  346. displayAttributeData(theReply);
  347. break;
  348. case 9:
  349. // get geocode response
  350. processGeocode(theReply);
  351. break;
  352. case 10:
  353. // get identifyall response
  354. doIdentifyAll(theReply);
  355. break;
  356. case 11:
  357. // get buffer response
  358. getBufferAttributeData(theReply)
  359. break;
  360. /*
  361. case 13:
  362. // get route response
  363. processRoute(theReply);
  364. break;
  365. */
  366. case 14:
  367. // get find response
  368. //alert(theReply);
  369. displayAttributeData(theReply);
  370. break;
  371. case 15:
  372. // get hyperlink response
  373. parseHyperLink(theReply);
  374. break;
  375. case 16:
  376. // get hyperlinkAny response
  377. parseHyperLinkAny(theReply);
  378. break;
  379. case 20:
  380. // process startup query
  381. parseStartQuery(theReply);
  382. break;
  383. case 25:
  384. // get geocoding layers
  385. parseGeocodeLayers(theReply);
  386. // continue startup
  387. if ((aimsQueryPresent) && (highlightedOne!="") && (queryZoom)) {
  388. setStartQuery();
  389. } else {
  390. sendMapXML();
  391. }
  392. break;
  393. case 26:
  394. // get geocoding layers
  395. if (parseGeocodeParams(theReply,GCLayers[GCActiveLayer])) {
  396. var theAddressForm = appDir + "addmatch.htm";
  397. if ((useExternalWindow) || (!useTextFrame)) {
  398. var Win1 = window.open(theAddressForm,"GeocodeWindow","width=575,height=150,scrollbars=yes,resizable=yes");
  399. } else {
  400. parent.TextFrame.document.location= theAddressForm;
  401. }
  402. } else {
  403. if (debugOn>0) {
  404. alert(msgList[17] + "n" + theReply);
  405. if (parent.TextFrame!=null) parent.TextFrame.document.location= appDir + "blank.htm";
  406. } else {
  407. alert(msgList[17]);
  408. if (parent.TextFrame!=null) parent.TextFrame.document.location= appDir + "blank.htm";
  409. }
  410. }
  411. break;
  412. case 27:
  413. // get geocoding results
  414. parseGeocodeResults(theReply);
  415. break;
  416. case 40:
  417. // get list of sample field values
  418. parseFieldSamples(theReply);
  419. writeQueryForm();
  420. break;
  421. case 55:
  422. // get layer storedqueries
  423. //alert("55n" + theReply);
  424. parseStoredQueries(theReply);
  425. break;
  426. case 70:
  427. // get layer field for submission to external db
  428. parseIDFieldData(theReply);
  429. break;
  430. case 98:
  431. // just put up a map with legend
  432. var theURL = "";
  433. theURL = getURL(theReply);
  434. if (theURL != "") {
  435. document.theImage.src = theURL;
  436. }
  437. if (legendVisible) {
  438. showLegend();
  439. drawLegendOnly=false;
  440. }
  441. hideRetrieveMap();
  442. break;
  443. case 99:
  444. // just put up a map
  445. var theURL = "";
  446. legendVisible=legendTemp;
  447. theURL = getURL(theReply);
  448. if (theURL != "") {
  449. document.theImage.src = theURL;
  450. }
  451. else {
  452. alert(msgList[14] + theReply);
  453. }
  454. hideRetrieveMap();
  455. break;
  456. case 101:
  457. // print - get Map image
  458. printMapURL = getURL(theReply);
  459. printLegURL = getLegendURL(theReply);
  460. if (hasOVMap) {
  461. getPrintOV();
  462. } else {
  463. //writePrintPage();
  464. getPrintLegend();
  465. }
  466. break;
  467. case 102:
  468. // print - get OV image
  469. printOVURL = getURL(theReply);
  470. legendImage = printLegURL
  471. getPrintLegend();
  472. break;
  473. case 103:
  474. // print - get Legend image
  475. hideRetrieveMap();
  476. writePrintPage();
  477. break;
  478. case 900:
  479. // just make a map
  480. var theURL = "";
  481. theURL = getURL(theReply);
  482. if (theURL != "") {
  483. getXYs(theReply);
  484. document.theImage.src = theURL;
  485. }
  486. break;
  487. case 902:
  488. // just put up an overview map
  489. var theURL = "";
  490. theURL = getURL(theReply);
  491. if (theURL != "") {
  492. ovImageVar.src = theURL; 
  493. }
  494. var tempLeft = fullLeft;
  495. var tempRight = fullRight;
  496. var tempTop = fullTop;
  497. var tempBottom = fullBottom;
  498. getOVXYs(theReply);
  499. pastStart = true;
  500. fullLeft = tempLeft;
  501. fullRight = tempRight;
  502. fullTop = tempTop;
  503. fullBottom = tempBottom;
  504. var theString = '<ARCXML version="1.1">n<REQUEST>n<GET_SERVICE_INFO renderer="false" extensions="true" ';
  505. if (aimsLayersPresent) {
  506. if (LayerID.length>0) {
  507. theString += 'fields="false" ';
  508. } else {
  509. theString += 'fields="true" ';
  510. }
  511. } else {
  512. theString += 'fields="false" ';
  513. }
  514. theString += '/>n</REQUEST>n</ARCXML>';
  515. sendToServer(imsURL,theString,3);
  516. break;
  517. default:
  518. // send any responses to custom requests off to the custom handler
  519. // XMLMode >= 1000 are reserved for custom requests/responses
  520. if (XMLMode >= 1000) {
  521. useCustomFunction(theReply);
  522. } else {
  523. alert(theReply + msgList[19]);
  524. }
  525. }
  526. }
  527. // prepare the request in xml format for Main Map
  528. function writeXML() {
  529. var theString = '<ARCXML version="1.1">n<REQUEST>n<GET_IMAGE>n<PROPERTIES>n<ENVELOPE minx="' + forceComma(eLeft) + '" miny="' + forceComma(eBottom) + '" maxx="' + forceComma(eRight) + '" maxy="' + forceComma(eTop) + '" />n';
  530. theString += '<IMAGESIZE height="' + iHeight + '" width="' + iWidth + '" />n';
  531. var visString = "";
  532. if (aimsLayersPresent) {
  533. // tell the server which layers are to be visible
  534. if (toggleVisible) {
  535. theString += '<LAYERLIST >n';
  536. if (mCustomLayer.bCustomLayer){
  537. if (CustonmsLayerName.length!=0){
  538. //加载原有
  539. for (var i=0;i<serverLayerCount;i++) {
  540. if (LayerVisible[i]==1) {
  541. theString += '<LAYERDEF id="' + LayerID[i] + '" visible="true" ';
  542. if (aimsClassRenderPresent) {
  543. theString += addSpecialRenderToMap(i);
  544. } else {
  545. theString += '/>n';
  546. }
  547. }
  548. else {
  549. theString += '<LAYERDEF id="' + LayerID[i] + '" visible="false" />n';
  550. }
  551. }
  552. }else{
  553. for (var i=0;i<serverLayerCount;i++) {
  554. if (LayerVisible[i]==1) {
  555. theString += '<LAYERDEF id="' + LayerID[i] + '" visible="true" ';
  556. if (aimsClassRenderPresent) {
  557. theString += addSpecialRenderToMap(i);
  558. } else {
  559. theString += '/>n';
  560. }
  561. }else {
  562. theString += '<LAYERDEF id="' + LayerID[i] + '" visible="false" />n';
  563. }
  564. }
  565. var _CusStr = '';
  566. for (var i=mCustomLayer.CustonmsStartId;i<LayerVisible.length;i++){
  567. if (LayerVisible[i]==1){
  568. _CusStr += 'true,';
  569. }else{
  570. _CusStr += 'false,';
  571. }
  572. }
  573. mCustomLayer.setLayerVisible(_CusStr);
  574. }
  575. }else{
  576. for (var i=0;i<serverLayerCount;i++) {
  577. if (LayerVisible[i]==1) {
  578. theString += '<LAYERDEF id="' + LayerID[i] + '" visible="true" ';
  579. if (aimsClassRenderPresent) {
  580. theString += addSpecialRenderToMap(i);
  581. } else {
  582. theString += '/>n';
  583. }
  584. }
  585. else {
  586. theString += '<LAYERDEF id="' + LayerID[i] + '" visible="false" />n';
  587. }
  588. }
  589. }
  590. theString += '</LAYERLIST>n';
  591. }
  592. }
  593. // map background color
  594. if (mapTransparent) {
  595. theString += '<BACKGROUND color="255,255,254" transcolor="255,255,254" />n';
  596. } else {
  597. if (mapBackColor!="") {
  598. theString += '<BACKGROUND color="' + mapBackColor + '" />nn';
  599. }
  600. }
  601. if (aimsLegendPresent) {
  602. // create a legend image
  603. if (legendVisible) theString += addLegendToMap();
  604. }
  605. theString += '</PROPERTIES>n';
  606. //提前的函数
  607. // any custom stuff to fit here
  608. if (aimsCustomPresent) theString += addCustomToMap1();
  609. // buffer
  610. if (aimsBufferPresent) {
  611. if (showBuffer) theString += addBufferToMap();
  612. }
  613. // select
  614. if (aimsSelectPresent) {
  615. theString += addSelectToMap();
  616. }
  617. if (aimsClickPresent){
  618. // clickpoints 
  619. if (clickCount>0) {
  620. // draw click points and lines between them on map
  621. var clickColor = selectColor;
  622. if (clickType==1) clickColor = clickMarkerColor;
  623. theString += '<LAYER type="acetate" name="allTheClicks">n';
  624. if (clickCount>1) {
  625. theString += '<OBJECT units="database">n<LINE coords="' + forceComma(clickPointX[0]) + coordsDelimiter + forceComma(clickPointY[0]);
  626. for (var i=1;i<clickCount;i++) {
  627. theString += pairsDelimiter  + forceComma(clickPointX[i]) + coordsDelimiter + forceComma(clickPointY[i]); 
  628. }
  629. theString += '" >n';
  630. theString += '<SIMPLELINESYMBOL type="solid" color="' + clickMarkerColor;
  631. theString += '" width="3" />n</LINE>n</OBJECT>n'; 
  632. theString += '<OBJECT units="database">n<LINE coords="' + forceComma(clickPointX[0]) + coordsDelimiter + forceComma(clickPointY[0]);
  633. for (var i=1;i<clickCount;i++) {
  634. theString += pairsDelimiter  + forceComma(clickPointX[i]) + coordsDelimiter + forceComma(clickPointY[i]); 
  635. }
  636. theString += '" >n';
  637. theString += '<SIMPLELINESYMBOL type="solid" color="255,255,255" width="1" />n</LINE>n</OBJECT>n'; 
  638.   }
  639. for (var i=0;i<clickCount;i++) {
  640. theString += '<OBJECT units="database">n<POINT coords="' + forceComma(clickPointX[i]) + coordsDelimiter + forceComma(clickPointY[i]) + '">n';
  641. theString += '<SIMPLEMARKERSYMBOL  type="' + clickMarkerType + '"';
  642. theString += ' color="' + clickMarkerColor + '" width="' + clickMarkerSize + '" />n</POINT>n</OBJECT>n';
  643. }
  644. theString += '</LAYER>n';
  645. }
  646. }
  647. // route display - requires RouteServer extension
  648. if (aimsRoutePresent) {
  649. if (geocodeAppMode=="route") theString += addRouteToMapXML("");
  650. }
  651. // geocoding or point with label
  652. if (showGeocode) {
  653. // draw the point . . . also used to display any point with a label on map
  654. theString += '<LAYER type="acetate" name="GeoCode1">n';
  655. theString += '<OBJECT units="database">n<POINT coords="' + forceComma(geocodeX) + coordsDelimiter + forceComma(geocodeY) + '">n';
  656. theString += '<SIMPLEMARKERSYMBOL  type="circle"  color="' + geocodePointColor + '" width="' + geocodePointSize +'" overlap="false" />n</POINT></OBJECT>n';
  657. if (geocodeLabel!="") {
  658. theString += '<OBJECT units="database">n<TEXT coords="' + forceComma(geocodeX) + coordsDelimiter + forceComma(geocodeY) + '" label="' + geocodeLabel + '">n';
  659. theString += '<TEXTMARKERSYMBOL fontcolor="' + geocodePointColor + '" fontsize="12" shadow="64,64,64" glowing="255,255,0" halignment="right" valignment="top" overlap="false" /></TEXT></OBJECT>n';
  660. }
  661. theString += '</LAYER>n';
  662. }
  663. // any custom stuff to fit here
  664. if (aimsCustomPresent) theString += addCustomToMap2();
  665. if (drawBottomBar) {
  666. theString += '<LAYER type="acetate" name="theBottomBar">n';
  667. theString += '<OBJECT units="pixel">n<POLYGON ';
  668. theString += 'coords="0' + coordsDelimiter + '1' + pairsDelimiter;
  669. theString += '1' + coordsDelimiter + bottomBarHeight + pairsDelimiter;
  670. theString += (iWidth-1) + coordsDelimiter + bottomBarHeight + pairsDelimiter;
  671. theString += (iWidth-1) + coordsDelimiter + '1' + pairsDelimiter;
  672. theString += '0' + coordsDelimiter + '1">n';
  673. theString += '<SIMPLEPOLYGONSYMBOL fillcolor="' + bottomBarColor + '" boundary="true" boundarycolor="' + bottomBarOutline + '" overlap="false" />n';
  674. theString += '</POLYGON>n</OBJECT>n';
  675. theString += '</LAYER>n';
  676. }
  677. if (drawCopyright) {
  678. // draw text on the map
  679. theString += '<LAYER type="acetate" name="theCopyright">n';
  680. theString += '<OBJECT units="pixel">n<TEXT coords="' + CopyrightCoords + '" label="' + CopyrightText + '">n';
  681. theString += '<TEXTMARKERSYMBOL fontstyle="' + CopyrightStyle + '" fontsize="' + CopyrightSize + '" ';
  682. if (CopyrightFont!="") theString += 'font="' + CopyrightFont + '" ';
  683. theString += 'fontcolor="' + CopyrightColor + '" antialiasing="True" ';
  684. //if (CopyrightBackground.toUpperCase()=="TRUE") theString += 'background="' + CopyrightBackground + '" backcolor="' + CopyrightBGColor + '" ';
  685. if (CopyrightBackground.toUpperCase()=="TRUE") theString += 'blockout="' + CopyrightBGColor + '" ';
  686. if (CopyrightShadow.toUpperCase()=="TRUE") theString += 'shadow="' + CopyrightShadowColor + '" ';
  687. theString += 'overlap="false" ';
  688. if (CopyrightGlow.toUpperCase()=="TRUE") theString += ' glowing="' + CopyrightGlowColor + '" ';
  689. theString += '/>n</TEXT>n</OBJECT>n';
  690. theString += '</LAYER>n';
  691. }
  692. if (drawNorthArrow) {
  693. // draw a north arrow
  694. theString += '<LAYER type="acetate" name="theNorthArrow">n';
  695. theString += '<OBJECT units="pixel">n<NORTHARROW type="' + NorthArrowType + '" size="' + NorthArrowSize + '" coords="' + NorthArrowCoords + '" shadow="32,32,32" ';
  696. theString += 'angle="' + NorthArrowAngle + '" antialiasing="True" overlap="False" />n</OBJECT>n';
  697. theString += '</LAYER>n';
  698. }
  699. if (drawScaleBar) {
  700. // draw a scale bar
  701. //ScaleBarPrecision = numDecimals;
  702. theString += '<LAYER type="acetate" name="theScaleBar">n';
  703. xDistance = eRight - eLeft;
  704. theString += '<OBJECT units="pixel">n';
  705. theString += '<SCALEBAR ';
  706. if (drawScaleBar2) {
  707. theString += 'screenlength="' + parseInt(iWidth * (1/10)) + '" coords="' + (iWidth-((parseInt(iWidth * (4/10)))+20)) + coordsDelimiter + '3" ';
  708. } else {
  709. theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" coords="' + parseInt(iWidth * (6/10)) + coordsDelimiter + '3" ';
  710. }
  711. if (MapUnits=="DEGREES") theString += 'mode="geodesic" ';
  712. if (ScaleBarFont!="") theString += 'font="' + ScaleBarFont + '" ';
  713. theString += 'fontcolor="' + ScaleBarFontColor + '" fontstyle="' + ScaleBarStyle + '" barcolor="' + ScaleBarColor + '" ';
  714. if (MapUnits!="DEGREES") {
  715. theString += 'mapunits="' + MapUnits.toLowerCase() + '" ';
  716. }
  717. theString += 'scaleunits="' + ScaleBarUnits.toLowerCase() + '" antialiasing="True" ';
  718. var sDistance = getScaleBarDistance();
  719. if (MapUnits=="DEGREES") {
  720. if (xDistance<1/10){
  721. theString += 'precision="' + ScaleBarPrecision + '" ';
  722. }
  723. } else if (sDistance<5) {
  724. theString += 'precision="' + ScaleBarPrecision + '" ';
  725. }
  726. //theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" ';
  727. theString += 'fontsize="' + ScaleBarSize + '" barwidth="' + ScaleBarWidth + '" overlap="False"  ';
  728. //*/
  729. theString += '/>n</OBJECT>n';
  730. theString += '</LAYER>n';
  731. }
  732. if (drawScaleBar2) {
  733. // draw a scale bar
  734. //ScaleBarPrecision = numDecimals;
  735. theString += '<LAYER type="acetate" name="theScaleBar2">n';
  736. xDistance = eRight - eLeft;
  737. theString += '<OBJECT units="pixel">n';
  738. theString += '<SCALEBAR ';
  739. if (drawScaleBar) {
  740. theString += 'screenlength="' + parseInt(iWidth * (1/10)) + '" coords="' + (iWidth-((parseInt(iWidth * (2/10)))+10)) + coordsDelimiter + '3" ';
  741. } else {
  742. theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" coords="' + parseInt(iWidth * (6/10)) + coordsDelimiter + '3" ';
  743. }
  744. if (MapUnits=="DEGREES") theString += 'mode="geodesic" ';
  745. if (ScaleBar2Font!="") theString += 'font="' + ScaleBar2Font + '" ';
  746. theString += 'fontcolor="' + ScaleBar2FontColor + '" fontstyle="' + ScaleBar2Style + '" barcolor="' + ScaleBar2Color + '" ';
  747. if (MapUnits!="DEGREES") {
  748. theString += 'mapunits="' + MapUnits.toLowerCase() + '" ';
  749. }
  750. theString += 'scaleunits="' + ScaleBar2Units.toLowerCase() + '" antialiasing="True" ';
  751. var sDistance = getScaleBarDistance();
  752. if (MapUnits=="DEGREES") {
  753. if (xDistance<1/10){
  754. theString += 'precision="' + ScaleBar2Precision + '" ';
  755. }
  756. } else if (sDistance<5) {
  757. theString += 'precision="' + ScaleBar2Precision + '" ';
  758. }
  759. //theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" ';
  760. theString += 'fontsize="' + ScaleBar2Size + '" barwidth="' + ScaleBar2Width + '" overlap="False"  ';
  761. //*/
  762. theString += '/>n</OBJECT>n';
  763. theString += '</LAYER>n';
  764. }
  765. // any custom stuff to fit here
  766. if (aimsCustomPresent) theString += addCustomToMap3();
  767. // any custom stuff to be drawn on top of everything
  768. if (aimsCustomPresent) theString += addCustomToMap4();
  769. theString += '</GET_IMAGE>n</REQUEST>n</ARCXML>';
  770. //alert(theString);
  771. return theString;
  772. }
  773. // prepare the request in xml format for overview map
  774. function writeOVXML() {
  775. var extentRatio = xDistance/fullWidth;
  776. var midX = eLeft + xHalf;
  777. var midY = eBottom + yHalf;
  778. var theString = '<ARCXML version="1.1">n<REQUEST>n<GET_IMAGE><PROPERTIES>n';
  779. theString += '<ENVELOPE minx="' + forceOVComma(fullOVLeft) + '" miny="' + forceOVComma(fullOVBottom) + '" maxx="' + forceOVComma(fullOVRight) + '" maxy="' + forceOVComma(fullOVTop) + '" />n';
  780. theString += '<IMAGESIZE height="' + i2Height + '" width="' + i2Width + '" />n';
  781. if ((toggleOVVisible) && (imsURL==imsOVURL)) {
  782. theString += '<LAYERLIST >n';
  783. for (var i=0;i<layerCount;i++) {
  784. if (LayerVisible[i]==1) {
  785. visString = "true";
  786. }
  787. else {
  788. visString = "false";
  789. }
  790. theString += '<LAYERDEF name="' + LayerName[i] + '" visible="' + visString + '" />n';
  791. }
  792. theString += '</LAYERLIST>n';
  793. }
  794. if (mapBackColor!="") {
  795. theString += '<BACKGROUND color="' + mapBackColor + '" />n';
  796. }
  797. theString += '</PROPERTIES>n';
  798. if (drawOVExtentBox) {
  799. theString += '<LAYER type="acetate" name="ACETATE">n';
  800. if (extentRatio<(1/100)) {
  801. theString += '<OBJECT units="database">n<POINT coords="' + forceOVComma(midX) + coordsDelimiter + forceOVComma(midY) + '">n';
  802. theString += '<SIMPLEMARKERSYMBOL  type="Square" color="' + convertHexToDec(ovBoxColor) + '" width="4" />n</POINT></OBJECT>n';
  803. } else {
  804. theString += '<OBJECT units="database">n<LINE coords="' + forceOVComma(eLeft) + coordsDelimiter + forceOVComma(eBottom) + pairsDelimiter + forceOVComma(eLeft) + coordsDelimiter + forceOVComma(eTop) + pairsDelimiter;
  805. theString += forceOVComma(eRight) + coordsDelimiter + forceOVComma(eTop) + pairsDelimiter + forceOVComma(eRight) + coordsDelimiter + forceOVComma(eBottom) + pairsDelimiter + forceOVComma(eLeft) + coordsDelimiter + forceOVComma(eBottom) + '">n';
  806. theString += '<SIMPLELINESYMBOL type="solid" color="' + convertHexToDec(ovBoxColor) + '" width="1" />n</LINE></OBJECT>n';
  807. }
  808. theString += '</LAYER>n';
  809. }
  810. theString += '</GET_IMAGE>n</REQUEST>n</ARCXML>';
  811. //alert(theString);
  812. return theString;
  813. }
  814. // get the map extents from xml reply
  815. function getXYs(theString) {
  816. var tempStr = "";
  817. var smallStr = "";
  818. var startpos = 0;
  819. var endpos = 0;
  820. var theReply = theString
  821. var theXYs =  getEnvelopeXYs(theString, 0)
  822. eLeft = theXYs[0];
  823. eBottom = theXYs[1];
  824. eRight = theXYs[2];
  825. eTop = theXYs[3];
  826. xDistance = Math.abs(eRight-eLeft);
  827. yDistance = Math.abs(eTop-eBottom);
  828. xHalf = xDistance / 2;
  829. yHalf = yDistance / 2;
  830. panX = xDistance * panFactor;
  831. panY = yDistance * panFactor;
  832. var sFactor = xDistance / iWidth
  833.     var aspectRatio = iWidth / iHeight;
  834.     var extentRatio = (eRight-eLeft) / (eTop-eBottom);
  835.     if (extentRatio < aspectRatio) sFactor = (eTop-eBottom) / iHeight;
  836. if (aimsLayersPresent) {
  837. if (sFactor!=mapScaleFactor) {
  838. mapScaleFactor = sFactor;
  839. if ((hasTOC) && (!legendVisible)) parent.TOCFrame.document.location = appDir + "toc.htm";
  840. if (aimsLayersPresent) {
  841. if (LayerListOpen) writeLayerListForm();
  842. }
  843. }
  844. }
  845. // get the map extents from xml reply
  846. function getOVXYs(theString) {
  847. var tempStr = "";
  848. var smallStr = "";
  849. var startpos = 0;
  850. var endpos = 0;
  851. var tempComma = forceCommaInRequest[activeMapServiceIndex];
  852. var theXYs =  getEnvelopeXYs(theString, 0)
  853. forceCommaInOV = forceCommaInRequest[activeMapServiceIndex];
  854. forceCommaInRequest[activeMapServiceIndex] = tempComma;
  855. fullOVLeft = theXYs[0];
  856. fullOVBottom = theXYs[1];
  857. fullOVRight = theXYs[2];
  858. fullOVTop = theXYs[3];
  859. fullOVWidth = Math.abs(fullOVRight - fullOVLeft);
  860. fullOVHeight = Math.abs(fullOVTop - fullOVBottom);
  861. //alert("Left:" + fullLeft + "nTop:" + fullTop + "nRight:" + fullRight + "nBottom:" + fullBottom);
  862. }
  863. // get URL
  864. function getURL(theReply) {
  865. var theURL = "";
  866. var startpos = 0;
  867. var endpos = 0;
  868. var pos = theReply.indexOf("OUTPUT");
  869. if (pos != -1) {
  870. theURL = getInsideString(theReply,'url="',dQuote,pos,0,false);
  871. }
  872. legendImage = getLegendURL(theReply);
  873. return theURL;
  874. }
  875. // getLegendURL
  876. function getLegendURL(theReply) {
  877. var theURL = "";
  878. var startpos = 0;
  879. var endpos = 0;
  880. var pos = theReply.indexOf("LEGEND");
  881. //alert(pos);
  882. if (pos != -1) {
  883. theURL = getInsideString(theReply,'url="',dQuote,pos,0,false);
  884. }
  885. //alert("Legend:" + theURL);
  886. return theURL;
  887. }
  888. // just make a map with URL and  extent
  889. function justGetMap(theURL, extentLeft, extentTop, extentRight, extentBottom, getOVMap) {
  890. var mode = 900;
  891. if (getOVMap) mode = 1;
  892. if (extentLeft!="") eLeft = extentLeft;
  893. if (extentTop!="") eTop = extentTop
  894. if (extentRight!="") eRight = extentRight;
  895. if (extentBottom!="") eBottom = extentBottom;
  896. var theText = writeXML();
  897. if (debugOn==2) alert(msgList[12] + theText);
  898. sendToServer(theURL,theText,mode);
  899. }
  900. // get min and max x,y's from xml stream . . . return an array with values
  901. function getEnvelopeXYs(theString, startpos) {
  902. var theEnvelope = new Array();
  903. //forceCommaInRequest[activeMapServiceIndex] = false;
  904. theString = theString.toUpperCase();
  905. var tempString = "";
  906. var pos = theString.indexOf("ENVELOPE",startpos);
  907. if (pos!=-1) {
  908. pos = pos + 8;
  909. startpos = theString.indexOf("MINX=",pos);
  910. startpos += 6;
  911. var endpos = theString.indexOf(dQuote,startpos);
  912. tempString = theString.substring(startpos,endpos);
  913. theEnvelope[0] = parseFloat(setDecimalString(tempString)); 
  914. startpos = theString.indexOf("MINY=",pos);
  915. startpos += 6;
  916. endpos = theString.indexOf(dQuote,startpos);
  917. tempString = theString.substring(startpos,endpos);
  918. theEnvelope[1] = parseFloat(setDecimalString(tempString)); 
  919. startpos = theString.indexOf("MAXX=",pos);
  920. startpos += 6;
  921. endpos = theString.indexOf(dQuote,startpos);
  922. tempString = theString.substring(startpos,endpos);
  923. theEnvelope[2] = parseFloat(setDecimalString(tempString)); 
  924. startpos = theString.indexOf("MAXY=",pos);
  925. startpos += 6;
  926. endpos = theString.indexOf(dQuote,startpos);
  927. tempString = theString.substring(startpos,endpos);
  928. theEnvelope[3] = parseFloat(setDecimalString(tempString)); 
  929. xmlEndPos = endpos;
  930. }
  931. return theEnvelope;
  932. }
  933. // set number string to have decimal character to match browser language type - point or comma
  934. function setDecimalString(numberString) {
  935. if (numberString.indexOf(",")!=-1) forceCommaInRequest[activeMapServiceIndex] = true;
  936. if (decimalChar==".") {
  937. numberString = numberString.replace(/,/g, ".");
  938. } else {
  939. numberString = numberString.replace(/./g, ",");
  940. }
  941. return numberString;
  942. }
  943. function forceComma(theNumber) {
  944. var comma = ",";
  945. var dot = ".";
  946. var charOut = comma;
  947. var charIn = dot;
  948. var numberString = new String(theNumber);
  949. if (forceCommaInRequest[activeMapServiceIndex]) {
  950. charOut = dot;
  951. charIn = comma;
  952. }
  953. var pos = numberString.indexOf(charOut);
  954. if (pos!=-1) {
  955. var begin = numberString.substring(0,pos);
  956. var ending = numberString.substring(pos+1, numberString.length);
  957. numberString = begin + charIn + ending;
  958. }
  959. return numberString;
  960. }
  961. function forceOVComma(theNumber) {
  962. var comma = ",";
  963. var dot = ".";
  964. var charOut = comma;
  965. var charIn = dot;
  966. var numberString = new String(theNumber);
  967. if (forceCommaInOV) {
  968. charOut = dot;
  969. charIn = comma;
  970. }
  971. var pos = numberString.indexOf(charOut);
  972. if (pos!=-1) {
  973. var begin = numberString.substring(0,pos);
  974. var ending = numberString.substring(pos+1, numberString.length);
  975. numberString = begin + charIn + ending;
  976. }
  977. return numberString;
  978. }
  979. // check if there is an error message in the response
  980. function getXMLErrorMessage(theString) {
  981. var pos1 = 0;
  982. var pos2 = 0;
  983. var pos3 = 0;
  984. var theError = "";
  985. pos3 = theString.indexOf("<ERROR");
  986. if (pos3!=-1) {
  987. pos1 = theString.indexOf(">",pos3);
  988. pos1 += 1;
  989. pos2 = theString.indexOf("</ERROR");
  990. theError = theString.substring(pos1,pos2)
  991. }
  992. return theError;
  993. }
  994. // check if theURL has different host from theHost
  995. function isNotSameHostInURL(theURL, theHost) {
  996. var startpos = theURL.indexOf("//");
  997. if (startpos==-1) {
  998. startpos = 0;
  999. } else {
  1000. startpos = startpos + 2;
  1001. }
  1002. var endpos = theURL.indexOf("/",startpos);
  1003. if (endpos==-1) endpos = theURL.length;
  1004. var thisHost = theURL.substring(startpos,endpos);
  1005. if (thisHost==theHost) {
  1006. return false;
  1007. } else {
  1008. return true;
  1009. }
  1010. }
  1011. // reposition map image after a pan
  1012. function resetPanImage(){
  1013. if (toolMode==3) {
  1014. moveLayer("theMap",hspc,vspc);
  1015. clipLayer2("theMap",0,0,iWidth,iHeight);
  1016. window.setTimeout('showLayer("theMap");',1000);
  1017. if (hasLayer("theMapClicks")) {
  1018. moveLayer("theMapClicks",hspc,vspc);
  1019. clipLayer2("theMapClicks",0,0,iWidth,iHeight);
  1020. }
  1021. }
  1022. document.theImage.onload = null;
  1023. }