gis.anchored2.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. var gis = gis || {};
  2. gis.anchored = function() {
  3. };
  4. gis.anchored.popup = function(lonlat,data){
  5. //alert(JSON.stringify(data));
  6. //alert(gis.anchored.tohtml(data));
  7. /*
  8. data={popupBorder:"1px solid #A5AAB4",width:320,height:155,title:"专题",
  9. style:["width:30%","text-align:center;"],
  10. data:[['港口名称','南京港'],['港区个数','2'],['锚地个数','2'],['作业区个数','16']]};
  11. */
  12. var chicken=$('#chicken');
  13. chicken.remove();
  14. data=gis.anchored.portinfo({portName:'南京港',portNumber:2,anchorageNumber:2,chanceNumber:16})
  15. var popup = new SuperMap.Popup.Anchored(
  16. "chicken",
  17. lonlat,
  18. new SuperMap.Size(data.width,data.height),
  19. gis.anchored.tohtml(data),
  20. null,
  21. true,
  22. null
  23. );
  24. popup.setBorder(data.popupBorder||"1px solid #A5AAB4");
  25. //popup.updateSize();
  26. //chicken_contentDiv
  27. popup.extdataheight=data.height;
  28. return popup;
  29. }
  30. gis.anchored.popupHtml = function(lonlat,data,toHtml){
  31. var chicken=$('#chicken');
  32. chicken.remove();
  33. var popup = new SuperMap.Popup.Anchored(
  34. "chicken",
  35. lonlat,
  36. new SuperMap.Size(data.width,data.height),
  37. toHtml,
  38. null,
  39. true,
  40. null
  41. );
  42. popup.setBorder(data.popupBorder||"1px solid #A5AAB4");
  43. //popup.updateSize();
  44. //chicken_contentDiv
  45. popup.extdataheight=data.height;
  46. return popup;
  47. }
  48. gis.anchored.addPopup = function(map,popup){
  49. map.addPopup(popup);
  50. //$('#chicken_close').css("display","none");
  51. var contentDiv=$('#chicken_contentDiv');
  52. //alert($('#chicken_GroupDiv').width());
  53. contentDiv.css("overflow","visible");
  54. //contentDiv.css("position","absolute");
  55. //contentDiv.css("border","1px solid #A5AAB4");
  56. contentDiv.css("width",$('#chicken_GroupDiv').width());//alert(contentDiv.width());
  57. //alert(contentDiv.width()+"**"+$('#chicken_GroupDiv').width());
  58. var tableDiv=$('.tabledivClass');
  59. //alert($('.titleClass').height());
  60. //tableDiv.css("height",tableDiv.height());
  61. tableDiv.css("height",popup.extdataheight-26);
  62. //tableDiv.css("width",contentDiv.width());
  63. /*
  64. if($.support&&$.support.leadingWhitespace&&contentDiv.width()==$('#chicken_GroupDiv').width()){
  65. contentDiv.css("width",$('#chicken_GroupDiv').width()-12);
  66. //tableDiv.css("height",tableDiv.height()-26);
  67. }
  68. */
  69. $('.smPopupCloseBox').css("top",2);
  70. $('.smPopupCloseBox').css("right",3);
  71. $.each($(".altrowstable"), function(i,val){
  72. gis.anchored.tableBeautify.call(this,"#fff","#F5F5F5","#FFFFCC")
  73. });
  74. }
  75. gis.anchored.tableBeautify = function(oddColor,evenColor,ouseoverColor){
  76. //alert(this);return;
  77. if(this){
  78. //var tr=this.getElementsByTagName("tr");
  79. for(var i=0;i<this.rows.length;i++){
  80. var temptr=this.rows[i];
  81. if(i%2==0){
  82. temptr.style.backgroundColor=oddColor;
  83. /*
  84. if(i==0){
  85. continue;
  86. }
  87. */
  88. //鼠标离开
  89. temptr.onmouseout=function(){
  90. this.style.backgroundColor=oddColor;
  91. }
  92. }else{
  93. temptr.style.backgroundColor=evenColor;
  94. //鼠标离开
  95. temptr.onmouseout=function(){
  96. this.style.backgroundColor=evenColor;
  97. }
  98. }
  99. //鼠标进入
  100. temptr.onmouseover=function(){
  101. //alert(this.style.backgroundColor+"-->"+ouseoverColor);
  102. this.style.backgroundColor=ouseoverColor;
  103. }
  104. /*
  105. temptr.onclick=function(){
  106. //alert(this.sectionRowIndex);
  107. }
  108. */
  109. var tagName_td=temptr.getElementsByTagName("td");
  110. if(tagName_td){
  111. var presentColsAmount=temptr.getElementsByTagName("td").length;
  112. if(presentColsAmount&&presentColsAmount>=4){
  113. for(var cc=1;cc<presentColsAmount;cc++){
  114. //alert(tagName_td[cc]);
  115. //$(tagName_td[cc]).css("color","red");
  116. $(tagName_td[cc]).css("border-left","1px solid #A5AAB4");
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. gis.anchored.tohtml = function(data){
  124. //alert(JSON.stringify(data));
  125. //$("<div id='popupWin'></div>").addClass("popupWindow").appendTo($("#result"));
  126. var html=new Array();
  127. var nvlval='';
  128. if(data){
  129. if(data.title){
  130. html.push("<div class='titleClass'>");
  131. html.push(data.title);
  132. html.push("</div>");
  133. }
  134. if(data.data){
  135. //html.push("<div class='tableClass' style='width: 335px; height: 115px; position: relative;border:1px solid #A5AAB4;overflow:auto;'>");
  136. html.push("<div class='tabledivClass'>");
  137. //html.push(data.title);html.push("<br>");
  138. html.push("<table class='altrowstable'>");
  139. for(var i=0;i<data.data.length;i++){
  140. var o=data.data[i];
  141. html.push("<tr>");
  142. for(var j=0;j<o.length;j++){
  143. html.push("<td style='"+(data.style[j]||nvlval)+"'>");
  144. html.push(o[j]);
  145. html.push("</td>");
  146. }
  147. html.push("</tr>");
  148. }
  149. html.push("</table>");
  150. html.push("</div>");
  151. }
  152. }
  153. //alert(html.join(""));
  154. return html.join("");
  155. }
  156. gis.anchored.portinfo = function(data){
  157. var obj={popupBorder:"1px solid #A5AAB4",width:320,height:152,title:"港口信息",
  158. style:["width:30%","text-align:center;"],
  159. data:[['港口名称',data.portName],['港区个数',data.portNumber],['锚地个数',data.anchorageNumber],['作业区个数',data.chanceNumber]]};
  160. return obj;
  161. }
  162. gis.anchored.nvlinfo = function(data){
  163. var obj={popupBorder:"1px solid #A5AAB4",width:320,height:155,title:data.poptitle,
  164. style:["width:30%","text-align:center;"],
  165. data:[['名称',data.portName]]};
  166. return obj;
  167. }
  168. $(document).ready(function() {
  169. });