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

GIS编程

开发平台:

ASP/ASPX

  1. // aimsDHTML.js
  2. /*
  3. *  JavaScript template file for ArcIMS HTML Viewer
  4. * dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js,
  5. * aimsLayers.js
  6. */
  7. aimsDHTMLPresent=true;
  8. /*
  9. ***************************************************************************************
  10. DHTML layer functions
  11. ***************************************************************************************
  12. */
  13. // Create a DHTML layer
  14. function createLayer(name, inleft, intop, width, height, visible, content) {
  15.   var layer;
  16.     document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + inleft + 'px; top:' + intop + 'px; width:' + width + 'px; height:' + height + 'px;' + '; z-index:1; visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
  17.     document.writeln(content);
  18.     document.writeln('</div>');
  19. }
  20. // get the layer object called "name"
  21. function getLayer(name) {
  22. var theObj = document.getElementById(name);
  23. if (theObj!=null) {
  24. return theObj.style
  25.  }  else {
  26.     return(null);
  27.  }
  28. }
  29. // get the layer object called "name" if in OverviewFrame
  30. function getOVLayer(name) {
  31. if (parent.OverviewFrame!=null) {
  32. var theObj = parent.OverviewFrame.document.getElementById(name);
  33. if (theObj!=null) {
  34. return theObj.style
  35.  }  else {
  36.     return(null);
  37. }
  38. } else
  39. return getLayer(name);
  40. }
  41. function isVisible(name) {
  42.   var layer = getLayer(name);
  43.   if (isNav && layer.visibility == "show")
  44.     return(true);
  45.   if (isIE && layer.visibility == "visible")
  46.     return(true);
  47.   return(false);
  48. }
  49. // move layer to x,y
  50. function moveLayer(name, x, y) {
  51.    var layer = getLayer(name);
  52.     layer.left = x + "px";
  53.     layer.top  = y + "px";
  54. }
  55. // set layer background color
  56. function setLayerBackgroundColor(name, color) {
  57.    var layer = getLayer(name);
  58. layer.backgroundColor = color;
  59. }
  60. // toggle layer to invisible
  61. function hideLayer(name) {
  62.    var layer = getLayer(name);
  63.    layer.visibility = "hidden";
  64. }
  65. // toggle layer to visible
  66. function showLayer(name) {
  67.    var layer = getLayer(name);
  68.    layer.visibility = "visible";
  69. }
  70. // toggle Overview layer to visible - if in OverviewFrame
  71. function showOVLayer(name) {
  72.    var layer = getOVLayer(name);
  73.    layer.visibility = "visible";
  74. }
  75. // toggle Overview layer to invisible - if in OverviewFrame
  76. function hideOVLayer(name) {
  77.    var layer = getOVLayer(name);
  78.    layer.visibility = "hidden";
  79. }
  80. // clip layer display to clipleft, cliptip, clipright, clipbottom
  81. // Not working with Mozilla Milestone 12 (Nav5)
  82. function clipLayer2(name, clipleft, cliptop, clipright, clipbottom) {
  83.   var layer = getLayer(name);
  84.   layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
  85. }
  86. function clipLayer(name, clipleft, cliptop, clipright, clipbottom) {
  87.   var layer = getLayer(name);
  88.   var newWidth = clipright - clipleft;
  89. var newHeight = clipbottom - cliptop;
  90. layer.height = newHeight;
  91. layer.width = newWidth;
  92. layer.top = cliptop  + "px";
  93. layer.left = clipleft + "px";
  94. }
  95. // clip layer in OverviewFrame
  96. function clipOVLayer(name, clipleft, cliptop, clipright, clipbottom) {
  97. var layer = getLayer(name);
  98. if (parent.OverviewFrame!=null) layer = getOVLayer(name);
  99. if ((clipright.isNaN) || (clipleft.isNaN) || (cliptop.isNaN) || (clipbottom.isNaN)) {
  100. layer.visibility = "hidden";
  101. } else {
  102. var newWidth = clipright - clipleft;
  103. var newHeight = clipbottom - cliptop;
  104. if ((newWidth<=0) || (newHeight<=0)) {
  105. layer.visibility = "hidden";
  106. } else {
  107. layer.height = newHeight;
  108. layer.width = newWidth;
  109. layer.top = cliptop  + "px";
  110. layer.left = clipleft + "px";
  111. layer.visibility = "visible";
  112. }
  113. }
  114. }
  115. // replace layer's content with new content
  116. // not working with Mozilla Milestone 12 (Nav5)
  117. function replaceLayerContent(name, content) {
  118. var theObj = document.getElementById(name);
  119. if (theObj!=null) {   
  120. theObj.innerHTML = content;
  121. }
  122. }
  123. // toggle Overview Map display
  124. function toggleOVMap() {
  125. if (imsURL!="") {
  126. ovIsVisible = !ovIsVisible;
  127. if (ovIsVisible) {
  128. putExtentOnOVMap();
  129. showLayer("ovLayer");
  130. showLayer("ovShadow");
  131. } else {
  132. hideLayer("ovLayer");
  133. hideLayer("ovShadow");
  134. hideLayer("zoomOVBoxTop");
  135. hideLayer("zoomOVBoxLeft");
  136. hideLayer("zoomOVBoxRight");
  137. hideLayer("zoomOVBoxBottom");
  138. }
  139. var layer = getLayer("theTop");
  140. if (layer!=null) layer.cursor = theCursor;
  141. } else {
  142. alert(msgList[45]);
  143. }
  144. }
  145. // plot extent box on overview map - only for Overview if in OverviewFrame
  146. function putExtentOnOVMap() {
  147. var ovXincre = fullOVWidth / i2Width;
  148. var ovYincre = fullOVHeight / i2Height;
  149. var vleft = (eLeft - fullOVLeft) / ovXincre + ovBorderWidth;
  150. var vright = (eRight - fullOVLeft) / ovXincre + ovBorderWidth;
  151. var vtop = (fullOVTop - eTop) / ovYincre + ovBorderWidth;
  152. var vbottom = (fullOVTop - eBottom) / ovYincre + ovBorderWidth;
  153. if (vright>i2Width+ovBorderWidth) vright = i2Width;
  154. if (vbottom>i2Height+ovBorderWidth) vbottom = i2Height;
  155. //if (!isNav4) {
  156. vleft = vleft + ovHspc;
  157. vright = vright + ovHspc;
  158. vtop = vtop + ovVspc;
  159. vbottom = vbottom + ovVspc;
  160. //}
  161. if (eTop>fullOVBottom) {
  162. clipOVLayer("zoomOVBoxTop",vleft,vtop-ovExtentBoxSize,vright+1,vtop);
  163. showOVLayer("zoomOVBoxTop");
  164. } else {
  165. hideOVLayer("zoomOVBoxTop");
  166. }
  167. if (eLeft<fullOVRight) {
  168. clipOVLayer("zoomOVBoxLeft",vleft-ovExtentBoxSize,vtop-ovExtentBoxSize,vleft,vbottom);
  169. showOVLayer("zoomOVBoxLeft");
  170. } else {
  171. hideOVLayer("zoomOVBoxLeft");
  172. }
  173. if (eRight>fullOVLeft) {
  174. clipOVLayer("zoomOVBoxRight",vright,vtop-ovExtentBoxSize,vright+ovExtentBoxSize,vbottom);
  175. showOVLayer("zoomOVBoxRight");
  176. } else {
  177. hideOVLayer("zoomOVBoxRight");
  178. if (eBottom<fullOVTop) {
  179. clipOVLayer("zoomOVBoxBottom",vleft,vbottom-ovExtentBoxSize,vright+1,vbottom);
  180. showOVLayer("zoomOVBoxBottom");
  181. } else {
  182. hideOVLayer("zoomOVBoxBottom");
  183. }
  184. }
  185. function boxIt(theLeft,theTop,theRight,theBottom) {
  186. //if (!isNav4) {
  187. theTop = theTop + vspc;
  188. theBottom = theBottom + vspc;
  189. theLeft = theLeft + hspc;
  190. theRight = theRight + hspc;
  191. //}
  192. clipLayer("zoomBoxTop",theLeft,theTop,theRight,theTop+ovBoxSize);
  193. clipLayer("zoomBoxLeft",theLeft,theTop,theLeft+ovBoxSize,theBottom);
  194. clipLayer("zoomBoxRight",theRight-ovBoxSize,theTop,theRight,theBottom);
  195. clipLayer("zoomBoxBottom",theLeft,theBottom-ovBoxSize,theRight,theBottom);
  196. showLayer("zoomBoxTop");
  197. showLayer("zoomBoxLeft");
  198. showLayer("zoomBoxRight");
  199. showLayer("zoomBoxBottom");
  200. }