var gis = gis || {}; gis.anchored = function() { }; var framedCloud; gis.anchored.popup = function(lonlat,data){ //alert(JSON.stringify(data)); //alert(gis.anchored.tohtml(data)); /* data={popupBorder:"1px solid #A5AAB4",width:320,height:155,title:"专题", style:["width:30%","text-align:center;"], data:[['港口名称','南京港'],['港区个数','2'],['锚地个数','2'],['作业区个数','16']]}; */ var chicken=$('#chicken'); chicken.remove(); data=gis.anchored.portinfo({portName:'南京港',portNumber:2,anchorageNumber:2,chanceNumber:16}) var popup = new SuperMap.Popup.Anchored( "chicken", lonlat, new SuperMap.Size(data.width,data.height), gis.anchored.tohtml(data), null, true, null ); popup.setBorder(data.popupBorder||"0px solid #A5AAB4"); //popup.updateSize(); //chicken_contentDiv popup.extdataheight=data.height; return popup; } /* * 弹出框显示,并且控制显示位置 */ gis.anchored.popupHtml = function(lonlat,data,toHtml,e){ var chicken=$('#chicken'); chicken.remove(); var popup; if(e){ //console.log("event",e); //e.clientX,e.clientY if(gis.script.isNum(e.clientX)&&gis.script.isNum(e.clientY)){ //alert(treedivWidth); var twidth=treedivWidth||0; var clientx=e.clientX-twidth; var clienty=e.clientY; //alert((clientx+data.width+25)+"=="+$("#bgrounddiv").width()) if((clienty+data.height+25)>$("#bgrounddiv").height()){ //alert((clienty+data.height)+"--"+$("#bgrounddiv").height()) if((clientx+data.width+25)>$("#bgrounddiv").width()){ lonlat= map.getLonLatFromPixel(new SuperMap.Pixel(clientx-(data.width+32),clienty-(data.height))); toHtml=toHtml+'
'; }else{ lonlat= map.getLonLatFromPixel(new SuperMap.Pixel(clientx+20,clienty-(data.height))); toHtml=toHtml+''; } }else{ if((clientx+data.width+25)>$("#bgrounddiv").width()){ lonlat= map.getLonLatFromPixel(new SuperMap.Pixel(clientx-(data.width+32),clienty-28)); toHtml=toHtml+''; }else{ lonlat= map.getLonLatFromPixel(new SuperMap.Pixel(clientx+20,clienty-28)); toHtml=toHtml+''; } } popup = new SuperMap.Popup( "chicken", lonlat, new SuperMap.Size(data.width,data.height), toHtml, true, null ); /* lonlat= map.getLonLatFromPixel(new SuperMap.Pixel(e.clientX-twidth+20,e.clientY-28)); toHtml=toHtml+'' var popup = new SuperMap.Popup( "chicken", lonlat, new SuperMap.Size(data.width,data.height), toHtml, true, null ); */ } }/*else{ popup = new SuperMap.Popup.Anchored( "chicken", lonlat, new SuperMap.Size(data.width,data.height), toHtml, null, true, null ); }*/ if(!popup){ popup = new SuperMap.Popup.Anchored( "chicken", lonlat, new SuperMap.Size(data.width,data.height), toHtml, null, true, null ); } popup.setBorder(data.popupBorder||"1px solid #A5AAB4"); //popup.updateSize(); //chicken_contentDiv popup.extdataheight=data.height; return popup; } /* * 根据参数设置弹出框,以及显示数据的(表格)样式 */ gis.anchored.addPopup = function(map,popup,feature){ map.addPopup(popup); //$('#chicken_close').css("display","none"); var contentDiv=$('#chicken_contentDiv'); //alert($('#chicken_GroupDiv').width());//overflow:visible contentDiv.css("overflow","visible"); //contentDiv.css("position","absolute"); //contentDiv.css("border","1px solid #A5AAB4"); contentDiv.css("width",$('#chicken_GroupDiv').width());//alert(contentDiv.width()); //alert(contentDiv.width()+"**"+$('#chicken_GroupDiv').width()); var tableDiv=$('.tabledivClass'); //alert($('.titleClass').height()); //tableDiv.css("height",tableDiv.height()); tableDiv.css("height",popup.extdataheight-26); //tableDiv.css("width",contentDiv.width()); /* if($.support&&$.support.leadingWhitespace&&contentDiv.width()==$('#chicken_GroupDiv').width()){ contentDiv.css("width",$('#chicken_GroupDiv').width()-12); //tableDiv.css("height",tableDiv.height()-26); } */ $('.smPopupCloseBox').css("top",5); $('.smPopupCloseBox').css("right",5); /* $.each($(".altrowstable"), function(i,val){ gis.anchored.tableBeautify.call(this,"#fff","#F5F5F5","#FFFFCC") }); */ if(feature &&gis.script.isNotBlank(feature.attributes.labelfieldid)){ var titleName=feature.attributes[feature.attributes.labelfieldid]; var titleClassDiv=$('.titleClass'); if(titleClassDiv&&!gis.script.isBlank(titleName)){ titleClassDiv.html(gis.anchored.titleEllipsis(titleName,20)); } } /* if(feature &&gis.script.isNotBlank(feature.attributes.labelfieldid) &&gis.script.isNotBlank(feature.attributes[feature.attributes.labelfieldid])){ //console.log("feature",feature); var titleClassDiv=$('.titleClass'); titleClassDiv.html(feature.attributes[feature.attributes.labelfieldid]); } */ $.each($(".altrowstable"), function(i,val){ gis.anchored.tableBeautify2.call(this); }); } gis.anchored.titleEllipsis = function(tname,tlength){ try{ if(!gis.script.isBlank(tname)&&gis.script.isNum(tlength)&&tname.length &&tlength>0&&tname.length>tlength){ tname=tname.substring(0,tlength)+'...'; } }catch(e){} return tname; } /* * */ gis.anchored.addFramedCloud = function(lonlat,size,contentHTML){ if(framedCloud){ try{ framedCloud.hide(); framedCloud.destroy(); } catch(e){} } //初始化FramedCloud类 framedCloud = new SuperMap.Popup.FramedCloud( "chicken", lonlat, size, contentHTML, null, true, null, true ); map.addPopup(framedCloud); var contentDiv=$('#chicken_contentDiv'); //alert($('#chicken_GroupDiv').width());//overflow:visible contentDiv.css("overflow","visible"); //contentDiv.css("position","absolute"); //contentDiv.css("border","1px solid #A5AAB4"); contentDiv.css("width",$('#chicken_GroupDiv').width());//alert(contentDiv.width()); //alert(contentDiv.width()+"**"+$('#chicken_GroupDiv').width()); /* var tabledivClass=$('.tabledivClass'); tabledivClass.css("width",tabledivClass.width()-1); tabledivClass.css("height",222); */ //var tableDiv=$('.titleClass'); //tableDiv.css("width",tableDiv.width()-10); var smFramedCloudPopupContent=$('.smFramedCloudPopupContent'); smFramedCloudPopupContent.css("padding","0"); $('.smPopupCloseBox').css("top",4); $('.smPopupCloseBox').css("right",5); } /* * 显示数据的(表格)样式 */ gis.anchored.tableBeautify = function(oddColor,evenColor,ouseoverColor){ //alert(this);return; if(this){ //var tr=this.getElementsByTagName("tr"); for(var i=0;i