12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649 |
- var layer,layeryx,locationLayer,gkvectorLayer,gqvectorLayer,zyqvectorLayer,mdvectorLayer,markersLayer,jyrvectorLayer,boatLayer,modifyvectorLayer;
- var modifyFeature,nowModifyFeature;
- var uflldLayerMap;
- var gis = gis || {};
- gis.script = function() {
- };
- //gis.script.url="http://localhost:8090/iserver/services/map-world/rest/maps/World";
- gis.script.phase={init:"init",refresh:"refresh",cbrefresh:"cbrefresh"};
- gis.script.layerloadover=false;
- gis.script.controlLayer=false;
- gis.script.subLayers = new Array();
- //gis.script.iserverUrl=iserverUrl||"http://"+serverName+":8090/iserver/services";
- //gis.script.url=gis.script.iserverUrl+"/map-gk/rest/maps/gist";
- //gis.script.yxurl=gis.script.iserverUrl+"/map-gk/rest/maps/gist";
- gis.script.url=gisConfigBean.config.sldt.url;
- gis.script.yxurl=gisConfigBean.config.yxdt.url;
- gis.script.markerAttr={};
- gis.script.yxslqh=false;
- gis.script.markersLayers={};
- gis.script.markersLayersInfo={};
- gis.script.selectallLayers={};
- gis.script.tckztreeloadover=false;
- gis.script.layersInitconfig=[];
- gis.script.layersInitconfigObject={};
- /*
- * 读取配置信息,动态加载图层
- */
- gis.script.initlayersconfig = function() {
- //{"gkvectorLayer":{"id":"gkvectorLayer","Model":{"ty":{"id":"ty","isshow":"true"},"cbdt":{"id":"cbdt","isshow":"false"}},"label":"港口图层"}}
- gis.script.layersInitconfig=[];
- gis.script.layersInitconfigObject={};
- if(gis.script.isBlank(treeType)){
- treeType="ty";
- }
- if(layerConfig){
- for(var n in layerConfig){
- var data=layerConfig[n];
- if(data&&data.Model&&data.Model[treeType]){
- var modeldata=jQuery.extend(true, {}, data.Model[treeType]);
- modeldata.layerName=n;
- gis.script.layersInitconfig.push(modeldata);
-
- gis.script.setlayersInitconfigObject(data.name||data.id,modeldata);
- }
- }
- }
- //根据orderby排序,以便按层次加载图层
- gis.script.layersInitconfig.sort(function(a,b){
- if(gis.script.isNum(a.orderby)&&gis.script.isNum(b.orderby)){
- //console.log("CCC1:",parseFloat(a.orderby));
- return parseFloat(a.orderby)<parseFloat(b.orderby)?-1:1;
- }
- return 0;
- });
- //console.log("CCC1:",gis.script.layersInitconfig);
- //console.log("CCC2:",gis.script.layersInitconfigObject);
- }
- /*
- * 配置信息存入layersInitconfigObject,方便读取图层配置信息
- */
- gis.script.setlayersInitconfigObject = function(key,obj) {
- //alert(key);
- var info=gis.script.layersInitconfigObject[key];
- if(!info){
- gis.script.layersInitconfigObject[key]=[];
- info=gis.script.layersInitconfigObject[key];
- }
- info.push(obj);
- }
- /*
- * 控制图层信息,可以通过设置动态显示图层。
- */
- gis.script.settrendsLayer=function (key,isshow){
- var info=gis.script.layersInitconfigObject[key];
- if(info&&info.length){
- for(var kk=0;kk<info.length;kk++){
- var obj=info[kk];
- if(obj){
- obj.isshow=isshow;
- }
- }
- }
- //console.log("CCC1-1:",gis.script.layersInitconfig);
- }
- /*
- * 地图可显示的比例尺
- */
- gis.script.scales=[2060000,1180000,640000, 320000, 160000, 80000, 40000, 20000, 10000, 5000, 2500,1250];
- /*
- gis.script.scales=[0.0000008234577570,0.000001180591620,0.0000020811127177082523,0.0000041622254354165045,0.000008324450870833009,0.000016648901741666018,
- 0.000033297803483332036,0.00006659560696666407,0.00013319121393332814,0.0002663824278666563,0.0005327648557333126,
- 0.0010655297114666252,0.0021310594229332503,0.004262118845866501,0.008524237691733001,0.017048475383466002];
- */
- /*
- * 初始化,加载SuperMap以及地图影像,根据分辨率动态设置按钮位置
- */
- gis.script.init = function() {
- var bgrounddiv=$("#bgrounddiv");
- bgrounddiv.css("width",bgrounddiv.width()-235);
-
- //alert(bgrounddiv.offset().left);
- $("#yxslqh").css("top",bgrounddiv.offset().top+10);
- //$("#yxslqh").css("left",bgrounddiv.offset().left+23);
- $("#yxslqh").css("right",25);
- $("#yxslqh img").attr("src",contextPath+'/theme/images/gis/satellite.png');
- $("#yxslqh img").bind("click",function(e){
- if(gis.script.layerloadover&&layer&&layeryx){
- if(gis.script.yxslqh){
- layer.setVisibility(true);
- layeryx.setVisibility(false);
- map.setBaseLayer(layer);
-
- $(this).attr("src",contextPath+'/theme/images/gis/satellite.png');
- }else{
- layer.setVisibility(false);
- layeryx.setVisibility(true);
- map.setBaseLayer(layeryx);
-
- $(this).attr("src",contextPath+'/theme/images/gis/map.png');
- }
- gis.script.yxslqh=!gis.script.yxslqh;
- }
- //gis.script[this.id](this);
- });
-
- annarray=['tckz','cbss','txbj'];
- for(var ii=0;ii<annarray.length;ii++){
- var annobj=$("#"+annarray[ii]);
- if(annobj&&annobj.length){
- annobj.css("top",bgrounddiv.offset().top+10);
- annobj.css("right",32+52*(ii+1));
-
- annobj.bind("mousedown",function(){
- $(this).css("border","1px solid transparent");
- });
- annobj.bind("mouseup",function(){
- $(this).css("border","0px solid transparent");
- });
- annobj.bind("mouseout",function(){
- $(this).css("border","0px solid #A5AAB4");
- });
- /*
- annobj.bind("click",function(e){
- $("#"+this.id+"list").show("slow");
- });
- */
- annobj.bind("click",function(e){
- /*
- var lobj=$("#"+this.id+"list");
- if(lobj.is(':hidden')){
- for(var ik=0;ik<annarray.length;ik++){
- $("#"+annarray[ik]+"list").hide("slow");
- }
- lobj.show("slow");
- }else{
- lobj.hide("slow");
- }
- //lobj.show("slow");
- */
-
- gis.script.buttonclickFun(this.id);
- });
- }
- }
-
- $("#tckz_close").bind("click",function(e){
- $("#tckzlist").hide("slow");
- gis.script.buttonimgObjRestore('tckz');
- });
- /*
- $("#tckz").css("top",bgrounddiv.offset().top+10);
- //$("#yxslqh").css("left",bgrounddiv.offset().left+23);
- $("#tckz").css("right",85);
- $("#tckz img").bind("click",function(e){
- $("#tckzlist").show("slow");
- });
- $("#tckz_close").bind("click",function(e){
- $("#tckzlist").hide("slow");
- });
-
- $("#tckz").bind("mousedown",function(){
- $("#tckz").css("border","1px solid transparent");
- });
- $("#tckz").bind("mouseup",function(){
- $("#tckz").css("border","0px solid transparent");
- });
-
- $("#tckz").bind("mouseover",function(){
- //border:0px solid #A5AAB4;
- //$("#tckz").css("border","1px solid transparent");
- });
- $("#tckz").bind("mouseout",function(){
- //border:0px solid #A5AAB4;
- $("#tckz").css("border","0px solid #A5AAB4");
- });
- */
-
- $('#banner').mousedown(function(event) {
- var isMove = true;
- var abs_x = event.pageX - $('div.moveBar').offset().left;
- var abs_y = event.pageY - $('div.moveBar').offset().top;
- $(document).mousemove(function(event) {
- if (isMove) {
- var obj = $('div.moveBar');
- obj.css({
- 'left' : event.pageX - abs_x,
- 'top' : event.pageY - abs_y
- });
- }
- }).mouseup(function() {
- isMove = false;
- });
- });
-
- /*
- $.each(uiaccordion.find('a').parent(), function(i,val){
- var ua=$(val);
- alert(i+">>"+val.id);
- });
- */
-
- /*
- var footer=parent.window.document.getElementById("footer");
- if(footer){
- //alert($(parent.window.document.getElementById("footer")).height());
- bgrounddiv.css("height",bgrounddiv.height()-$(footer).height());
- }
- */
- //map = new SuperMap.Map("bgrounddiv");//,{allOverlays: true}
- map = new SuperMap.Map("bgrounddiv",{allOverlays: true,controls: [
- new SuperMap.Control.Navigation({
- dragPanOptions: {
- enableKinetic: true
- }
- })]
- });
- //scales:[1 / 147914677, 1 / 73957338, 1 / 36978669, 1 / 18489334, 1 / 9244667, 1 / 4622333, 1 / 2311166, 1 / 1000000]
- map.addControl(new SuperMap.Control.ScaleLine());
- //map.addControl(new SuperMap.Control.ScaleLine(),new SuperMap.Pixel(bgrounddiv.width()-120,bgrounddiv.height()-60));
-
- //初始化复杂缩放控件类
- panzoombar=new SuperMap.Control.PanZoomBar();
- // 是否固定缩放级别为[0,16]之间的整数,默认为false
- panzoombar.forceFixedZoomLevel=true;
- //是否显示滑动条,默认值为false
- panzoombar.showSlider=true;
- /*点击箭头移动地图时,所移动的距离占总距离(上下移动的总距离为高度,左右移动的总距离为宽度)
- 的百分比,默认为null。 例如:如果slideRatio 设为0.5, 则垂直上移地图半个地图高度.*/
- panzoombar.slideRatio=0.5;
- //设置缩放条滑块的高度,默认为11
- panzoombar.zoomStopHeight=5;
- //设置缩放条滑块的宽度,默认为13
- panzoombar.zoomStopWidth=9;
- //map.addControl(panzoombar);
- map.addControl(panzoombar,new SuperMap.Pixel(bgrounddiv.width()-90,60));
- //map.addControl(new SuperMap.Control.LayerSwitcher());
-
- map.events.register("addlayer",null,function(e) {
- //alert(e.layer.CLASS_NAME);
- });
-
- map.events.on({"zoomend":gis.script.eventsZoomend});
-
- /*
- layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", gis.script.url, null,{maxResolution:"auto"});
- //layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", gis.script.url,{transparent: true}, {useCanvas: true, maxResolution: "auto"});
- layer.events.on({"layerInitialized": gis.script.addLayer});
- */
- /*
- if(gis.script.controlLayer){
- gis.script.initLayersInfo();
- }else{
- }
- */
-
- //1:1214391.3776 ,scales: [1/1214391.3776] ,scales:gis.script.scales
- layer = new SuperMap.Layer.TiledDynamicRESTLayer("sldtLayer", gis.script.url, null,{maxResolution:"auto",scales:gis.script.scales});
- //layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", gis.script.url,{transparent: true}, {useCanvas: true, maxResolution: "auto"});
- layer.visibility=true;
- layer.events.on({"layerInitialized": gis.script.addmoreLayer});
- //gis.script.initOthenLayer();
-
-
- //gis.script.initVectorLayer();
- //gis.script.initMarkersLayer();
- }
- /*
- * 删除map上的弹出框
- */
- gis.script.removeAllPopup = function() {
- map.removeAllPopup();
- }
- /*
- * 地图比例改变时触发事件
- */
- gis.script.eventsZoomend = function(e) {
- /*
- if(markersLayer){
- if(e.object&&e.object.zoom==0){
- var l=map.getLayer(markersLayer.id);
- if(!l){
- map.addLayer(markersLayer);
- }
- }else{
- var l=map.getLayer(markersLayer.id);
-
- if(l){
- map.removeLayer(l);
- }
- }
- }
- */
-
- gis.script.removeAllPopup();
-
- /*
- for(var vv in gis.script.markersLayersInfo){
-
- var objinfo=gis.script.markersLayersInfo[vv];
-
- if(!gis.script.isBlank(objinfo.marktypename)&&
- gis.script.isNum(objinfo.showMinzoom)&&gis.script.isNum(objinfo.showMaxzoom)){
- if(e.object){
- //alert((!gis.script.isNum(objinfo.showMinzoom)||objinfo.showMinzoom<=e.object.zoom)&&(!gis.script.isNum(objinfo.showMaxzoom)||objinfo.showMaxzoom>=e.object.zoom));
- if((!gis.script.isNum(objinfo.showMinzoom)||objinfo.showMinzoom<=e.object.zoom)&&(!gis.script.isNum(objinfo.showMaxzoom)||objinfo.showMaxzoom>=e.object.zoom)){
- var l=gis.script.getmapinLayer(objinfo.marktypename);
- if(!l&&gis.script.markersLayers[objinfo.marktypename]){
- map.addLayer(gis.script.markersLayers[objinfo.marktypename]);
- }
- }else{
- var l=gis.script.getmapinLayer(objinfo.marktypename);
- if(l){
- map.removeLayer(l);
- }
- }
- }
- }
- }
-
- var boatvectorLayers=gis.script.addboatvectorLayer([]);
- gis.script.removeLayer([labelLayer,gqvectorLayer,jyrvectorLayer,mtvectorLayer,bwvectorLayer,boatLayer]);
- gis.script.removeLayer(boatvectorLayers);
- //gis.script.removeLayer(gis.script.addboatvectorLayer([]));
- if(labelLayer){
- if(e.object&&(e.object.zoom>5)){
- var l=map.getLayer(labelLayer.id);
- if(!l){
- map.addLayer(labelLayer);
- }
- }
- }
-
- if(gqvectorLayer){
- if(e.object&&(e.object.zoom>5&&e.object.zoom<7)){
- var l=map.getLayer(gqvectorLayer.id);
- if(!l){
- map.addLayer(gqvectorLayer);
- }
- }
- }
-
- //jyrvectorLayer
- if(jyrvectorLayer){
- if(e.object&&e.object.zoom>5){
- var l=map.getLayer(jyrvectorLayer.id);
- if(!l){
- map.addLayer(jyrvectorLayer);
- }
- }
- }
-
- if(mtvectorLayer){
- if(e.object&&e.object.zoom>8){
- var l=map.getLayer(mtvectorLayer.id);
- if(!l){
- map.addLayer(mtvectorLayer);
- }
- }
- }
-
- if(bwvectorLayer){
- if(e.object&&e.object.zoom>8){
- var l=map.getLayer(bwvectorLayer.id);
- if(!l){
- map.addLayer(bwvectorLayer);
- }
- }
- }
-
- if(boatvectorLayers.length>0){
- if(gis.script.markersLayers&&gis.script.pitchonMarkers&&gis.script.markersLayers[gis.script.pitchonMarkers]){
- gis.script.markersLayers[gis.script.pitchonMarkers].clearMarkers();
- }
-
- if(boatLayer){
- if(e.object&&e.object.zoom>8){
- var l=map.getLayer(boatLayer.id);
- if(!l){
- map.addLayer(boatLayer);
- }
- }
- }
-
-
- for(var ik=0;ik<boatvectorLayers.length;ik++){
- var blayer=boatvectorLayers[ik];
- if(blayer){
- if(e.object&&e.object.zoom>8){
- var l=map.getLayer(blayer.id);
- if(!l){
- map.addLayer(blayer);
- }
- }
- }
- }
- }
- */
- gis.script.switchtoLayer();
- }
- /*
- * 根据地图比例以及图层配置动态设置显示图层以及图层层次设置
- */
- gis.script.switchtoLayer = function(){
- //alert(gis.script.locationLayerRunRemoveAllFeatures);
- /*
- if(gis.script.locationLayerRunRemoveAllFeatures){
- locationLayer.removeAllFeatures();
- }
- gis.script.locationLayerRunRemoveAllFeatures=true;
- */
-
- //alert(gis.script.locationLayerRunRemoveAllFeatures);
- //locationLayer.removeAllFeatures();
- //gis.script.removeLayer([gis.script.markersLayers.markersgkLayer,gis.script.markersLayers.markersQskLayer]);
- //gis.script.removeLayer([gis.script.markersLayers.gzkMarkersLayer]);
- if(gis.script.markersLayers){
- for(var nl in gis.script.markersLayers){
- gis.script.removeLayer([gis.script.markersLayers[nl]]);
- }
- }
- /*
- if(gis.script.selectallLayers){
- for(var nl in gis.script.selectallLayers){
- gis.script.removeLayer([gis.script.selectallLayers[nl]]);
- }
- }
- */
- gis.script.removeLayer([labelLayer,jyrlabelLayer,gqvectorLayer,zyqvectorLayer,mdvectorLayer,jyrvectorLayer,mtvectorLayer,bwvectorLayer,boatLayer]);
- gis.script.removeLayer(gis.script.addboatvectorLayer([]));
- //map.addLayer(eval("("+"gis.script.markersLayers.markersgkLayer"+")"));
- if(gis.script.layersInitconfig&&gis.script.layersInitconfig.length){
- for(var i=0;i<gis.script.layersInitconfig.length;i++){
- var objinfo=gis.script.layersInitconfig[i];
- //alert(data.layerName);
- //map.addLayer(eval("("+data.layerName+")"));
- /*
- if(objinfo.layerName=="gis.script.boatonLayer.boatdanger1"){
- alert(objinfo.isshow&&objinfo.isshow==='true');
- }
- */
- if(objinfo.isshow&&objinfo.isshow==='true'){
- if((!gis.script.isNum(objinfo.showMinzoom)||objinfo.showMinzoom<=map.zoom)&&(!gis.script.isNum(objinfo.showMaxzoom)||objinfo.showMaxzoom>=map.zoom)){
-
- //alert(objinfo.layerName);
- if(eval("("+objinfo.layerName+")")){
- if(!gis.script.isBlank(objinfo.clear)){
- eval("("+objinfo.layerName+"."+objinfo.clear+"())")
- }
-
- map.addLayer(eval("("+objinfo.layerName+")"));
- }
-
- }
- }
- }
- }
-
- if(modifyvectorLayer){
- var mvLayer=map.getLayer(modifyvectorLayer.id);
- if(mvLayer){
- gis.script.removeLayer([modifyvectorLayer]);
- map.addLayer(modifyvectorLayer);
- }
- }
- }
- /*
- * 根据id获取markersLayer
- */
- gis.script.getmapinLayer = function(id) {
- if(gis.script.markersLayers[id]){
- var vid=gis.script.markersLayers[id].id
- return map.getLayer(vid);
- }
- return;
- }
- /*
- * 删除图层
- */
- gis.script.removeLayer = function(ar) {
- if(ar&&ar.length){
- for(var i=0;i<ar.length;i++){
- var templayer=ar[i];
- if(templayer){
- var l=map.getLayer(templayer.id);
- if(l){
- map.removeLayer(l);
- }
- }
- }
- }
- }
- /*
- * 加载矢量地图,以及添加layerInitialized监听事件,根据treeType切换树展示
- */
- gis.script.addmoreLayer = function() {
- layeryx = new SuperMap.Layer.TiledDynamicRESTLayer("yxdtLayer", gis.script.yxurl, null,{maxResolution:"auto",scales:gis.script.scales});
- layeryx.visibility=false;
- layeryx.events.on({"layerInitialized":function() {
- map.addLayers([layer,layeryx]);
- //出图,map.setCenter函数显示地图
- //var lonlat = layer.maxExtent.getCenterLonLat();
- lon =119.66;
- lat =32.57;
- //定位地图中心
- map.setCenter(new SuperMap.LonLat(lon, lat), 0);
- //map.setCenter(new SuperMap.LonLat(0, 0), 1);
- //map.zoomToScale(1.0/1020090.0,true);
- //gis.script.layerloadover=true;
-
- gis.script.initOthenLayer();
- gis.script.initModifyFeature();
- //gis.script.loadboatLayer(boatLayer,[{id:'1',lon:119.66,lat:32.57},{id:'2',lon:119.56,lat:32.47}]);
-
- /*
- if(gis.script.loadcbdataService&&!document.getElementById("treecbdtdiviframe")){
- gis.script.loadcbdataService(gis.script.phase.init);
- }
- */
- //alert(treeType);
- //gis.script.initlayersconfig();
- //gis.script.switchtoLayer();
-
- //根据treeType切换树展示
- gis.script.switchTree(treeType);
-
- gis.script.openiframetree();
-
-
- }});
- }
- /*
- * 加载船舶动态的树页面
- */
- gis.script.openiframetree = function() {
- //treecbdtdiviframe
- if(document.getElementById("treecbdtdiviframe")){
- document.getElementById("treecbdtdiviframe").src=contextPath+"/zygl/treeiframe.html?model=cbdtTree";
- }
- if(document.getElementById("treeaqjgdiviframe")){
- //document.getElementById("treeaqjgdiviframe").src=contextPath+"/zygl/treeiframe.html?model=aqjgTree";
- }
- }
- /*
- * 地图按钮控制事件
- */
- gis.script.buttonclickFun = function(id) {
- var imgObj=$("#"+id).find("img");
- if(imgObj&&imgObj.length){
- $.each(imgObj, function(i,val){
- var tua=$(val);
- var attrSrc=tua.attr('src');
- if(attrSrc&&attrSrc.indexOf("_no.png")<0){
- tua.attr('src',attrSrc.replace(".png","_no.png"));
- }else{
- tua.attr('src',attrSrc.replace("_no.png",".png"));
- }
-
- });
- }
-
- if(id=='tckz'||id=='cbss'){
- //gis.script.loadcbdataService_client(gis.script.phase.init);return;
- var lobj=$("#"+id+"list");
- if(lobj.is(':hidden')){
- for(var ik=0;ik<annarray.length;ik++){
- if(id!=annarray[ik]){
-
- $("#"+annarray[ik]+"list").hide("slow");
- var imgo=$("#"+annarray[ik]).find("img");
- $.each(imgo, function(i,val){
-
- var tua=$(val);
- var attrSrc=tua.attr('src');
- //alert(id+"--"+annarray[ik]+"--"+val.id);
- if(attrSrc&&attrSrc.indexOf("_no.png")>0){
- tua.attr('src',attrSrc.replace("_no.png",".png"));
- }
- });
- }
- }
- lobj.show("slow");
- }else{
- lobj.hide("slow");
- }
- }else if(id=='txbj'){
- if(nowModifyFeature&&modifyFeature){
-
- gis.script.removeAllPopup();
- //如果是编辑状态就终止编辑
- if(modifyvectorLayer){
- var mvLayer=map.getLayer(modifyvectorLayer.id);
- if(mvLayer){
- gis.script.clearAllDeactivate();
- gis.script.toastmessage({text:'退出地物编辑状态。'});
- return;
- }
- }
-
- //编辑地物前地图定位到地物中心
- try{
- if(nowModifyFeature.attributes&&nowModifyFeature.attributes.editinfoobj){
- //console.log("1.nowModifyFeature",nowModifyFeature.attributes.editinfoobj);
- var editinfoobj=nowModifyFeature.attributes.editinfoobj;
- map.setCenter(new SuperMap.LonLat(editinfoobj.lon,editinfoobj.lat));
- }
- }catch(e){
-
- }
-
- //进入编辑地物状态
- gis.script.clearAllDeactivate();
- //gis.script.removeLayer([modifyvectorLayer]);
- map.addLayer(modifyvectorLayer);
- modifyFeature.activate();
- gis.script.toastmessage({text:'点击编辑区域后进入编辑状态。'});
- }else{
- gis.script.toastmessage({text:'请先选择可编辑区域。'});
- gis.script.buttonimgObjRestore(id);
- }
- }
- }
- gis.script.buttonimgObjRestore = function(id) {
- var imgObj=$("#"+id).find("img");
- if(imgObj&&imgObj.length){
- $.each(imgObj, function(i,val){
- var tua=$(val);
- var attrSrc=tua.attr('src');
- if(attrSrc&&attrSrc.indexOf("_no.png")>0){
- tua.attr('src',attrSrc.replace("_no.png",".png"));
- }
-
- });
- }
- }
- /*
- * 信息提示
- */
- gis.script.toastmessage = function(obj) {
- var newObject = jQuery.extend(true,{
- sticky : false,
- position : 'top-right',
- type : 'notice',//type:notice,type:success
- closeText: '',
- stayTime : 2000,
- position : 'top-center'},obj);
- $().toastmessage('showToast',newObject);
-
- //console.log("...",newObject);
- }
- /*
- *清除编辑的feature
- */
- gis.script.clearAllDeactivate = function() {
- if(modifyFeature){
- if(modifyvectorLayer){
- gis.script.removeLayer([modifyvectorLayer]);
- }
-
- modifyFeature.deactivate();
- }
- }
- /*
- * 创建可编辑图层
- */
- gis.script.initModifyFeature = function() {
- if(layerUserControl&&typeof(layerUserControl)!='undefined'){
-
- if(typeof(layerUserControl.modifyFeature)!='undefined'){
- if(layerUserControl.modifyFeature==false){
- return;
- }
- }
- }
- //alert(layerUserControl.modifyFeature);
- modifyFeature = new SuperMap.Control.ModifyFeature(modifyvectorLayer);
- map.addControl(modifyFeature);
- }
- /*
- * 图层编辑完成后的触发函数
- */
- gis.script.editFeatureCompleted = function(event) {
- //alert($.confirm)
- $.confirm({
- title : '确认框',
- content : '确认保存编辑区域吗',
- confirm : function() {
- if(event){
- var feature = event.feature;
- gis.script.editgisFeatureService(feature);
- }
- }
- });
-
-
- gis.script.buttonimgObjRestore('txbj');
- gis.script.clearAllDeactivate();
- }
- /*
- * 编辑信息写入
- */
- gis.script.editgisFeatureService = function(feature) {
-
- if(feature&&feature.attributes
- &&feature.attributes.gisEditLayerinfoKey
- &&gis.script.isNum(feature.attributes.featureidval)){
- if(dataServices){
- gis.script.consolelog('dataServices',dataServices);
- for(var n in dataServices){
- var data=gisConfigBean.dataconfig[n];
- if(data&&feature.attributes.gisEditLayerinfoKey==data.gisLayerinfoKey){
- data=jQuery.extend(true, {}, data);
- data.datasetNames=data.datasetNames.split(",");
- data.fields=data.fields.split(",");
- data.url=data.url||defdataUrl;
- //console.log("data",data);
-
- if(data.fields&&data.fields.length){
- var attributes = feature.attributes;
- var attrNames = data.fields;
- var attrValues = [];
- for(var i=0;i<attrNames.length;i++){
- //alert(attrNames[i]);
- attrValues.push(attributes[attrNames[i]]);
- }
- var features = {
- fieldNames:attrNames,
- fieldValues:attrValues,
- geometry:feature.geometry
- };
- //console.log("features",features);
- //alert(features.geometry.id+"--"+feature.attributes.featureidval)
- features.geometry.id = feature.attributes.featureidval;
- var editFeatureParameter = new SuperMap.REST.EditFeaturesParameters({
- features: [features],
- editType: SuperMap.REST.EditType.UPDATE
- });
-
-
- if(data.url&&data.datasetNames&&data.datasetNames.length==1){
- var dnames=data.datasetNames[0].split(":");
- if(dnames&&dnames.length==2){
- //console.log("dnames",dnames);
- var url=data.url+"/datasources/"+dnames[0]+"/datasets/"+dnames[1];
- //alert("http://127.0.0.1:8090/iserver/services/data-ST/rest/data/datasources/gkzyYS/datasets/L_GQ_PY"+"\n"+url);
- var editFeatureService = new SuperMap.REST.EditFeaturesService(url, {
- eventListeners: {
- "processCompleted": function(editFeaturesEventArgs) {
- gis.script.updateFeaturesProcessCompleted(editFeaturesEventArgs,feature);
- },
- "processFailed": gis.script.sqlProcessFailed
- }
- });
- editFeatureService.processAsync(editFeatureParameter);
- }
- }
-
- }
-
- break;
- }
- }
- }
- }
-
- }
- /*
- * 提示用户地物编辑是否保存成功,并且刷新图层
- */
- gis.script.updateFeaturesProcessCompleted = function(editFeaturesEventArgs,feature) {
- if(editFeaturesEventArgs&&editFeaturesEventArgs.result.resourceInfo.succeed) {
- //alert("更新地物成功");
- gis.script.toastmessage({text:'更新地物成功。',type:'success'});
- gis.script.updateFeaturesloadLayerdata(editFeaturesEventArgs,feature);
- }else{
- gis.script.toastmessage({text:'更新地物失败。',type:'warning'});
- }
- }
- //var uflldMap={"GK_BASIC_JSJY_GK_GQ":gqvectorLayer,"GK_BASIC_JSJY_JYR":jyrvectorLayer,"GK_BASIC_JSJY_JYR_MT":mtvectorLayer,"GK_BASIC_JSJY_JYR_BW":bwvectorLayer,"GK_BASIC_JSJY_GK_ZYQ":zyqvectorLayer};
- gis.script.updateFeaturesloadLayerdata = function(editFeaturesEventArgs,feature) {
- if(feature&&feature.attributes
- &&feature.attributes.gisEditLayerinfoKey){
- //console.log("feature",feature);//uflldLayerMap
- if(uflldLayerMap&&uflldLayerMap[feature.attributes.gisEditLayerinfoKey]){
- var tlayer=uflldLayerMap[feature.attributes.gisEditLayerinfoKey];
- if(dataServices){
- for(var n in dataServices){
- var data=gisConfigBean.dataconfig[n];
- if(data&&feature.attributes.gisEditLayerinfoKey==data.gisLayerinfoKey){
- data=jQuery.extend(true, {}, data);
-
- if(data.gisLayerinfoAttrKey&&feature.attributes[data.gisLayerinfoAttrKey]){
- /*
- var param={};
- param[data.gisLayerinfoAttrKey]=feature.attributes[data.gisLayerinfoAttrKey];
- */
- var fba=tlayer.getFeaturesByAttribute(data.gisLayerinfoAttrKey,feature.attributes[data.gisLayerinfoAttrKey]);
- if(fba&&fba.length==1){
- if(locationLayer){
- locationLayer.removeAllFeatures();
-
- var cloneFeature=feature.clone();
- var fillColor="#a4a5a7";//"#ffff00"
- var fillOpacity=0.5;
- cloneFeature.style = {
- fill:true,
- stroke:true,
- strokeColor: "#ffff00",
- strokeWidth: 3,
- //pointerEvents: "visiblePainted",
- //fillColor: "#a4a5a7",
- strokeDashstyle:"solid",
- fillColor: fillColor,
- fillOpacity: fillOpacity
- };
- locationLayer.addFeatures(cloneFeature);
- }
- tlayer.removeFeatures(fba);
-
- if(data.Model&&data.Model[gis.script.modelid]){
- var model=data.Model[gis.script.modelid];
- data.datasetNames=data.datasetNames.split(",");
- data.fields=data.fields.split(",");
- data.cachedata=model.cachedata||data.cachedata;
- data.zoom=model.zoom||data.zoom;
- data.processCompleted=model.processCompleted;
- data.onSelectOpenPopkey=model.onSelectOpenPopkey;
- data.modelObj=model;
- data.url=data.url||defdataUrl;
- data.attributeFilter=data.gisLayerinfoAttrKey+"="+feature.attributes[data.gisLayerinfoAttrKey];
- //console.log("data",data);
-
- gis.script.loadLayerFeaturesBySqls(data);
- }
-
-
- }
- }
- }
- }
- }
- }
- }
- }
- /*
- * 创建地图中的所有所需的图层
- */
- gis.script.initOthenLayer = function() {
-
- gkvectorLayer = new SuperMap.Layer.Vector("gkvectorLayer");
- gqvectorLayer = new SuperMap.Layer.Vector("gqvectorLayer");
- zyqvectorLayer = new SuperMap.Layer.Vector("zyqvectorLayer");
- mdvectorLayer = new SuperMap.Layer.Vector("mdvectorLayer");
- jyrvectorLayer = new SuperMap.Layer.Vector("jyrvectorLayer");
- locationLayer = new SuperMap.Layer.Vector("locationLayer");
- mtvectorLayer = new SuperMap.Layer.Vector("mtvectorLayer");
- bwvectorLayer = new SuperMap.Layer.Vector("bwvectorLayer");
- vectorLayer = new SuperMap.Layer.Vector("vector");
- boatLayer = new SuperMap.Layer.Vector("boatLayer");
- markersLayer = new SuperMap.Layer.Markers("Markers");
- //modifyvectorLayer = new SuperMap.Layer.Vector("modifyvectorLayer", {renderers: ["Canvas2"]});
- modifyvectorLayer = new SuperMap.Layer.Vector("modifyvectorLayer");
- modifyvectorLayer.events.on({"afterfeaturemodified": gis.script.editFeatureCompleted});
- uflldLayerMap={"GK_BASIC_JSJY_GK_GQ":gqvectorLayer,"GK_BASIC_JSJY_JYR":jyrvectorLayer,"GK_BASIC_JSJY_JYR_MT":mtvectorLayer,"GK_BASIC_JSJY_JYR_BW":bwvectorLayer,"GK_BASIC_JSJY_GK_ZYQ":zyqvectorLayer,"GK_BASIC_JSJY_GK_MD":mdvectorLayer};
- //uflldLayerMap={"GK_BASIC_JSJY_GK_GQ":gqvectorLayer,"GK_BASIC_JSJY_JYR":jyrvectorLayer,"GK_BASIC_JSJY_JYR_MT":mtvectorLayer,"GK_BASIC_JSJY_JYR_BW":bwvectorLayer,"GK_BASIC_JSJY_GK_ZYQ":zyqvectorLayer};
-
- gis.script.markersLayers.markersgkLayer=new SuperMap.Layer.Markers("markersgkLayer");
- gis.script.markersLayers.gzkMarkersLayer=new SuperMap.Layer.Markers("gzkMarkersLayer");
- gis.script.markersLayers.markersQskLayer=new SuperMap.Layer.Markers("markersQskLayer");
-
- //gis.script.selectallLayers.bwSelectvectorLayer=new SuperMap.Layer.Vector("bwSelectvectorLayer");
-
- if(gis.script.initboatonLayer){
- gis.script.initboatonLayer();
- }
-
- boatLayer.styleMap = new SuperMap.StyleMap({
- "default":new SuperMap.Style({
- fillColor:"#000000",
- strokeColor:"#000000",
- fillOpacity: 0.6,
- graphicZIndex:1
- })
- });
-
- gqvectorLayer.styleMap=new SuperMap.StyleMap({
- "default":new SuperMap.Style({
- fill:true,
- fillColor:"#ffffff",
- strokeColor:"#ff0000",
- strokeDashstyle:"longdashdot",
- fillOpacity: 0.1,
- graphicZIndex:1
- }),
- "select":{
- strokeColor: "#ffff00",
- strokeWidth: 2,
- strokeDashstyle:"solid",
- fillColor: "#a4a5a7",
- fillOpacity: 0.5,
- graphicZIndex:2
- }
- });
-
- zyqvectorLayer.styleMap=new SuperMap.StyleMap({
- "default":new SuperMap.Style({
- fill:true,
- fillColor:"#ffffff",
- strokeColor:"#ff0000",
- strokeDashstyle:"longdashdot",
- fillOpacity: 0.1,
- graphicZIndex:1
- }),
- "select":{
- strokeColor: "#ffff00",
- strokeWidth: 2,
- strokeDashstyle:"solid",
- fillColor: "#a4a5a7",
- fillOpacity: 0.5,
- graphicZIndex:2
- }
- });
-
- mdvectorLayer.styleMap=new SuperMap.StyleMap({
- "default":new SuperMap.Style({
- fill:true,
- fillColor:"#ffffff",
- strokeColor:"#ff0000",
- strokeDashstyle:"longdashdot",
- fillOpacity: 0.1,
- graphicZIndex:1
- }),
- "select":{
- strokeColor: "#ffff00",
- strokeWidth: 2,
- strokeDashstyle:"solid",
- fillColor: "#a4a5a7",
- fillOpacity: 0.5,
- graphicZIndex:2
- }
- });
-
- jyrvectorLayer.styleMap=new SuperMap.StyleMap({
- "default":new SuperMap.Style({
- fill:true,
- fillColor:"#ffffff",
- strokeColor:"#e36c09",
- strokeDashstyle:"dash",
- fillOpacity: 0.1,
- graphicZIndex:1
- }),
- "select":{
- strokeColor: "#ffff00",
- strokeWidth: 2,
- strokeDashstyle:"solid",
- fillColor: "#a4a5a7",
- fillOpacity: 0.5,
- graphicZIndex:2
- }
- });
- mtvectorLayer.styleMap=new SuperMap.StyleMap({
- "default":new SuperMap.Style({
- fill:true,
- fillColor:"#e4deea",
- strokeColor:"#a9a297",
- strokeDashstyle:"solid",
- strokeOpacity:0.8,
- strokeWidth:1,
- fillOpacity: 0.5,
- graphicZIndex:1
- }),
- "select":{
- strokeColor: "#ffff00",
- strokeWidth: 2,
- strokeDashstyle:"solid",
- fillColor: "#a4a5a7",
- fillOpacity: 0.5,
- graphicZIndex:2
- }
- });
- bwvectorLayer.styleMap=new SuperMap.StyleMap({
- "default":new SuperMap.Style({
- fill:true,
- fillColor:"#77a4dc",
- strokeColor:"#303030",
- strokeDashstyle:"solid",
- strokeOpacity:0.8,
- strokeWidth:1,
- fillOpacity: 0.1,
- graphicZIndex:1
- }),
- "select":{
- strokeColor: "#ffff00",
- strokeWidth: 2,
- strokeDashstyle:"solid",
- //strokeOpacity:0.8,
- fillColor: "#a4a5a7",
- fillOpacity: 0.5,
- graphicZIndex:2
- }
- });
-
- var strategy = new SuperMap.Strategy.GeoText();
- strategy.style = {
- //fontColor:"#FF7F00",
- fontColor:"#000000",
- fontWeight:"bolder",
- fontSize:"14px",
- fill: false,
- fillColor: "#FFFFFF",
- fillOpacity: 1,
- stroke: false,
- strokeColor:"#8B7B8B"
- };
- labelLayer = new SuperMap.Layer.Vector("Label",{strategies: [strategy]});
-
- var jyrstrategy = new SuperMap.Strategy.GeoText();
- jyrstrategy.style = {
- //fontColor:"#FF7F00",
- fontColor:"#000000",
- fontWeight:"bolder",
- fontSize:"14px",
- fill: false,
- fillColor: "#FFFFFF",
- fillOpacity: 1,
- stroke: false,
- strokeColor:"#8B7B8B"
- };
- jyrlabelLayer = new SuperMap.Layer.Vector("jyrlabelLayer",{strategies: [jyrstrategy]});
-
- //gis.script.layerSelectFeature([gkvectorLayer,gqvectorLayer,jyrvectorLayer,bwvectorLayer,vectorLayer]);
- //gis.script.layerSelectFeature([gkvectorLayer,gqvectorLayer,jyrvectorLayer,vectorLayer,boatLayer]);
- gis.script.layerSelectFeature(gis.script.addboatvectorLayer([gkvectorLayer,gqvectorLayer,zyqvectorLayer,mdvectorLayer,jyrvectorLayer,mtvectorLayer,bwvectorLayer,vectorLayer]));
- gis.script.loadLayerdata();
-
- //map.addLayers([gkvectorLayer,gqvectorLayer,vectorLayer,markersLayer]);
- map.addLayers([labelLayer,locationLayer,gkvectorLayer,vectorLayer,markersLayer]);
-
- /*
- var geoText = new SuperMap.Geometry.GeoText(119.66, 32.57,"中华人民共和国");
- var geotextFeature = new SuperMap.Feature.Vector(geoText);
- labelLayer.addFeatures([geotextFeature]);
- */
- gis.script.layerloadover=true;
- }
- gis.script.addboatvectorLayer = function(objs) {
- if(gis.script.loadcbdataService&&gis.script.boatonLayer&&objs){
- //console.log("CCC:",gis.script.boatonLayer);
- for(var n in gis.script.boatonLayer){
- objs.push(gis.script.boatonLayer[n]);
- }
- //console.log("CCC:",objs);
- }
- return objs
- }
- gis.script.initMarkersLayer = function() {
- markersLayer = new SuperMap.Layer.Markers("Markers");
- layer.events.on({"layerInitialized":function() {
- map.addLayer(markersLayer);
- if(gis.script.loadMarkersLayerdata){
- gis.script.loadMarkersLayerdata();
- }
- }});
- }
- gis.script.initVectorLayer = function() {
- vectorLayer = new SuperMap.Layer.Vector("vector");
-
- layer.events.on({"layerInitialized": function() {
- map.addLayer(vectorLayer);
- gis.script.selectFeature();
-
- }
- });
- }
- gis.script.addLayer = function() {
- map.addLayer(layer);
- //出图,map.setCenter函数显示地图
- var lonlat = layer.maxExtent.getCenterLonLat();
- lon = lonlat.lon;
- lat = lonlat.lat;
- map.setCenter(new SuperMap.LonLat(lon, lat), 0);
- //map.setCenter(new SuperMap.LonLat(0, 0), 1);
- //map.zoomToScale(1.0/1020090.0,true);
- gis.script.layerloadover=true;
- }
- /*
- * 给Feature添加点击事件,Feature包括港区、经营人、码头、泊位、船舶
- */
- gis.script.layerSelectFeature = function(vlist){
- if(vlist&&vlist.length){
-
- var selectFeature= new SuperMap.Control.SelectFeature(vlist, {
- //是否重复触发地物选择事件,只在单选非toggle模式下有效。默认为false,表示处于 选中状态的地物不在触发选择事件。
-
- //repeat:true,
- hover:true,
- callbacks:{
- click: function(feature){
- //for(var cf in currentFeature){alert(cf);}
- //alert(event.clientX+"--"+event.clientY);
- //var lonlat=map.getLonLatFromPixel(new SuperMap.Pixel(event.clientX,event.clientY));
- //alert(lonlat.lon.toFixed(5));
-
- var eve=window.event;
- gis.script.featurecallbacksclick(feature,eve);
- if(feature){
- var fillColor="#a4a5a7";//"#ffff00"
- var fillOpacity=0.5;
-
- var cloneFeature=feature.clone();
- cloneFeature.style = {
- fill:true,
- stroke:true,
- strokeColor: "#ffff00",
- strokeWidth: 3,
- //pointerEvents: "visiblePainted",
- //fillColor: "#a4a5a7",
- strokeDashstyle:"solid",
- fillColor: fillColor,
- fillOpacity: fillOpacity
- };
- locationLayer.addFeatures(cloneFeature);
-
- nowModifyFeature=feature.clone();
-
- /*
- var mapCenter=map.getCenter();
- if(mapCenter){
- nowModifyFeature.attributes.editinfoobj={lon:mapCenter.lon,lat:mapCenter.lat,zoom:map.zoom};
- //console.log("1.getCenter",map.getCenter());
- //console.log("1.nowModifyFeature.attributes.editinfoobj",nowModifyFeature.attributes.editinfoobj);
- }
- */
- var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
- if(centerLonLat){
- nowModifyFeature.attributes.editinfoobj={lon:centerLonLat.lon,lat:centerLonLat.lat,zoom:map.zoom};
- //console.log("2.nowModifyFeature.attributes.editinfoobj",nowModifyFeature.attributes.editinfoobj);
- }
-
- modifyvectorLayer.removeAllFeatures();
- modifyvectorLayer.addFeatures(nowModifyFeature);
- }
- }
- },
- onSelect: function(feature) {
- //gis.script.featurecallbacksclick(feature);
- }
-
- });
- map.addControl(selectFeature);
- selectFeature.activate();
-
- }
-
- }
- gis.script.featurecallbacksclick = function(feature,e){
- //alert(feature.attributes.onSelectOpenPopkey);
- if(locationLayer){
- locationLayer.removeAllFeatures();
- }
- var chicken=$('#chicken');
- chicken.remove();
-
- if(feature.attributes&&feature.attributes.onSelectOpenPopkey&&gis.script[feature.attributes.onSelectOpenPopkey]){
- //alert(feature.attributes.onSelectOpenPopkey);
- gis.script[feature.attributes.onSelectOpenPopkey](feature,e);
- }
- /*
- if(gis.script.gisidTo&&feature.attributes&&feature.attributes.gisidToKey){
- var sinfo=gis.script.gisidTo[feature.attributes.gisidToKey];
- var tempSize={width:320,height:155};
- if(sinfo&&sinfo.ID){
- //alert(sinfo.ID);
- gis.script.jsonAjax({url:contextPath+"/zygl/queryGK.html",async:true,data:{id:sinfo.ID}},
- function(data){
- //alert(JSON.stringify(data));
- if(data&&data.message){
- //alert(data.message);
- //alert(gis.script.popSize[feature.attributes.gisLayerinfoKey]);
- var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),gis.script.popSize[feature.attributes.gisLayerinfoKey]||tempSize,data.message);
- gis.anchored.addPopup(map,popup);
- }
- });
- }else{
- var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),tempSize,
- gis.anchored.tohtml(gis.anchored.nvlinfo({poptitle:" ",portName:feature.attributes.NAME||feature.attributes.name||""})));
- gis.anchored.addPopup(map,popup);
- }
- }
- */
- }
- gis.script.selectFeature = function(){
- /*
- var callbacks={
- click: function(currentFeature){
- //for(var cf in currentFeature){alert(cf);}
- alert(cf.data);
- }
- };
-
- var selectFeature = new SuperMap.Control.SelectFeature(vectorLayer,
- {
- callbacks: callbacks
- });
- */
- var selectFeature= new SuperMap.Control.SelectFeature(vectorLayer, {
- //是否重复触发地物选择事件,只在单选非toggle模式下有效。默认为false,表示处于 选中状态的地物不在触发选择事件。
- repeat:true,
- onSelect: function(feature) {
- /*
- selecedtBus = feature;
- popup = new SuperMap.Popup("chicken",
- selecedtBus.geometry.getBounds().getCenterLonLat(),
- new SuperMap.Size(300,42),
- "", null, true);
- selecedtBus.popup = popup;
- map.addPopup(popup);
- */
- //console.log('feature:',feature);
- //alert(feature.id);
-
- var popup = gis.anchored.popup(feature.geometry.getBounds().getCenterLonLat(),{});
- gis.anchored.addPopup(map,popup);
-
- }
-
- }
-
- );
- map.addControl(selectFeature);
- selectFeature.activate();
- /*
- var selectFeature= new SuperMap.Control.SelectFeature(vectorLayer, {
- onSelect: function(feature) {
-
- selecedtBus = feature;
- popup = new SuperMap.Popup("chicken",
- selecedtBus.geometry.getBounds().getCenterLonLat(),
- new SuperMap.Size(300,42),
- "dddddddddddd", null, true);
- selecedtBus.popup = popup;
- map.addPopup(popup);
-
- //var popup = gis.anchored.popup(feature.geometry.getBounds().getCenterLonLat(),{});
- //gis.anchored.addPopup(map,popup);
- },
- //onUnselect: function() {alert(2)}
- }
- );
- map.addControl(selectFeature);
- selectFeature.activate();
- */
-
- }
- /*
- * 给Marker添加点击事件,Marker包括港口
- */
- gis.script.addMarker = function(obj){
- var size;
- var offset;
- var mattr=gis.script.markerAttr[obj.type];
-
- if(!mattr){
- size= new SuperMap.Size(obj.w,obj.h);
- offset=new SuperMap.Pixel(-(size.w/2), -(size.h/2));
-
- gis.script.markerAttr[obj.type]={};
- gis.script.markerAttr[obj.type].size=size;
- gis.script.markerAttr[obj.type].offset=offset;
- }else{
- size=gis.script.markerAttr[obj.type].size;
- offset=gis.script.markerAttr[obj.type].offset
- }
- if(size&&offset){
- //alert(size);
- var icon = new SuperMap.Icon(obj.src, size, offset);
- var marker = new SuperMap.Marker(new SuperMap.LonLat(obj.lon,obj.lat),icon);
- //添加覆盖物到标记图层
- //markersLayer.addMarker(marker);
-
- gis.script.addMarkerLayer(obj,marker);
-
- //eval("(showMarkerInfo())")
- if(!gis.script.isBlank(obj.functionName)){
- marker.events.on({"click":function(e) {
- //alert(e);alert(event);
- //alert(this);alert(event);
- var eve=window.event||e;
- obj.events=this;
- //gis.script[obj.functionName](obj.feature,event);
- gis.script[obj.functionName](obj.feature,eve);
- }});
- }
- }
- }
- gis.script.addMarkerLayer = function(obj,marker){
- if(!gis.script.isBlank(obj.marktypename)){
- //alert(obj.marktypename);
- //gis.script.markersLayers
- /*
- if(!gis.script.markersLayers[obj.marktypename]){
- gis.script.markersLayers[obj.marktypename] = new SuperMap.Layer.Markers(obj.marktypename);
-
- if(obj.defshow&&obj.defshow=="true"){
- map.addLayer(gis.script.markersLayers[obj.marktypename]);
- }
-
- gis.script.markersLayersInfo[obj.marktypename]=obj;
- }
- */
- //alert(gis.script.markersLayers[obj.marktypename]);
- //alert(obj.marktypename);
- //console.log('obj.marktypename:',obj.marktypename);
- gis.script.markersLayers[obj.marktypename].addMarker(marker);
- }
- }
- gis.script.showMarkerInfo = function(obj){
- //alert(JSON.stringify(obj));
- //var popup = gis.anchored.popup(obj.events.getLonLat(),{});
-
- var popup = gis.anchored.popupHtml(obj.events.getLonLat(),{width:320,height:155},
- gis.anchored.tohtml(gis.anchored.portinfo({portName:obj.name,portNumber:2,anchorageNumber:2,chanceNumber:16})));
- gis.anchored.addPopup(map,popup);
- }
- gis.script.getLayersInfo = function(){
- var getLayersInfoService = new SuperMap.REST.GetLayersInfoService(gis.script.url);
- getLayersInfoService.events.on({ "processCompleted": gis.script.processCompletedlayers});
- getLayersInfoService.processAsync();
- }
- gis.script.processCompletedlayers = function(e){
-
- //gis.script.consolelog('e:',e);
- if(e&&e.result&&e.result.subLayers){
- var layers=e.result.subLayers.layers;
- for (var j = 0; j <layers.length; j++) {
- gis.script.subLayers.push(layers[j])
- //alert(layers[j]);
- //alert("<input type='checkbox' checked="+layers[j].visible+"/><span>"+layers[j].name+"</span>");
- $("<input type='checkbox' class='checkboxSel' value='"+layers[j].name+"' "+(layers[j].visible?"checked=true":"")+"/><span>"+layers[j].name+"</span>").addClass("popupSpan").appendTo($("#layers"));
- //break;
- }
- }
- //alert("-->"+$("#layers .checkboxSel").length)
- var cb=$("#layers .checkboxSel");
-
- cb.click(function () {
- alert(layer.params.layersID)
- var str=new Array();
- str.push("[");
- $.each(cb, function(i, item){
- if(eval(item.checked) == true){
- str.push(args);
- }
- });
- str.push(",]");
- alert(str.length+"-->"+str.join("").replace(",]","]"));
- //layer.redraw();
- });
-
-
- //样式为BootStrap框架设置
- /*
- cb.hover(function () {
- $(this).addClass("label-success");
- }, function () {
- $(this).removeClass("label-success");
- });
- */
- gis.script.createTempLayer();
- }
- gis.script.createTempLayer = function(){
-
- var cb=$("#layers .checkboxSel");
- var layerStatusParameters = new SuperMap.REST.SetLayerStatusParameters();
- layerStatusParameters = (function(parameters) {
- //alert(parameters);
- $.each(cb, function(i, item){
- var layerStatus = new SuperMap.REST.LayerStatus();
- layerStatus.layerName = item.value;
- layerStatus.isVisible = eval(item.checked);
- //alert(layerStatus.layerName+"--"+layerStatus.isVisible)
- parameters.layerStatusList.push(layerStatus);
- });
- //设置资源在服务端保存的时间,单位为分钟,默认为10
- parameters.holdTime = 30;
- return parameters;
- })(layerStatusParameters);
-
- var setLayerStatusService = new SuperMap.REST.SetLayerStatusService(gis.script.url);
- setLayerStatusService.events.on({ "processCompleted": function(createTempLayerEventArgs){
- tempLayerID = createTempLayerEventArgs.result.newResourceID;
- //创建 TiledDynamicRESTLayer
- //layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", gis.script.url, {transparent: true, cacheEnabled: false, redirect: true, layersID: tempLayerID}, {maxResolution: "auto", bufferImgCount: 0});
- //layer.bufferImgCount = 0;
- //layer.events.on({"layerInitialized": gis.script.addLayer});
- layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", gis.script.url, {transparent: true, cacheEnabled: false, redirect: true, layersID: tempLayerID},{maxResolution:"auto", bufferImgCount: 0});
- layer.bufferImgCount = 0;
- layer.events.on({"layerInitialized": gis.script.addLayer});
- }});
- setLayerStatusService.processAsync(layerStatusParameters);
- }
- gis.script.initLayersInfo = function() {
- gis.script.getLayersInfo();
- }
- gis.script.setMapCenter = function(info){
- //alert(info.zoomSize);
- if(info&&typeof(info.lon)!="undefined"&&typeof(info.lat)!="undefined"){
-
- map.setCenter(new SuperMap.LonLat(info.lon, info.lat),info.zoomSize);
- issetCenter=true;
- }
- }
- gis.script.setMaplocationLayer = function(feature,o){
- locationLayer.removeAllFeatures();
- if(feature){
- locationLayer.addFeatures(feature);
-
-
-
- try{
- if(o.labelfield&&feature.attributes[o.labelfield]){
- labelLayer.removeAllFeatures();
- var geoText = new SuperMap.Geometry.GeoText(centerLonLat.lon, centerLonLat.lat,feature.attributes[o.labelfield]);
- var geotextFeature = new SuperMap.Feature.Vector(geoText);
- labelLayer.addFeatures([geotextFeature]);
- }
- }catch(e){
-
- }
-
- }
-
- }
- var switchto=false;
- gis.script.testSwitchto = function(){
- var uri;
- if(switchto){
- uri="/znjg/zygl/treeiframe.html?model=gis&treeType=ty"
- }else{
- uri="/znjg/zygl/treeiframe.html?model=gis&treeType=cbdt"
- }
- //alert(gis.script.queryString(uri,"treeType"));
- var o={menuurl:uri}
- gis.script.switchto(o);
- switchto=!switchto;
- }
- /*
- * 切换专辑图
- */
- gis.script.switchto = function(o){
- if(o&&o.menuurl){
- if(!gis.script.layerloadover){
- window.location.href=o.menuurl;
- return;
- }
-
- var ttype=gis.script.queryString(o.menuurl,"treeType");
- gis.script.switchTree(ttype);
- }
- //alert($(".treedivClass").length);
- }
- gis.script.switchTree = function(ttype){
- treeType=ttype;
- if(treeType){
- //alert(treeType);
- $.each($(".treedivClass"), function(i,val){
- var ua=$(val);
- ua.css("display","none");
- });
- $("#tree"+treeType+"div").css("display","");
- }
-
- gis.script.initlayersconfig();
- //gis.script.settrendsLayer("gkMarkLayer","false");
- //gis.script.settrendsLayer("gqvectorLayer","false");
- //gis.script.settrendsLayer("boatonLayers",'true');
- gis.script.switchtoLayer();
- gis.script.switchtckzTree();
-
- gis.script.switchcbsslist(ttype);
- }
- gis.script.switchcbsslist = function(ttype){
- if(ttype=='cbdt'){
- $("#cbss").css("display","");
- }else{
- $("#cbss").css("display","none");
- $("#cbsslist").css("display","none");
- }
- //$("#txbj").css("display","");
- if(layerUserControl&&typeof(layerUserControl)!='undefined'){
-
- if(typeof(layerUserControl.modifyFeature)!='undefined'){
- if(layerUserControl.modifyFeature==true){
- $("#txbj").css("display","");
- }
- }
- }
-
- var kk=0;
- for(var ii=0;ii<annarray.length;ii++){
- var annobj=$("#"+annarray[ii]);
- if(annobj&&annobj.length){
- //annobj.css("top",bgrounddiv.offset().top+10);
- //annobj.css("right",32+52*(ii+1));
- //alert(annobj.css('display'));
- if(annobj.css('display')&&annobj.css('display')!='none'){
- annobj.css("right",32+52*(kk+1));
- kk=kk+1;
- }
- }
- }
-
- }
- gis.script.switchtckzTree = function(){
- var iframepage=document.getElementById("treetckzdiviframe");
- if(iframepage){
- if(!gis.script.tckztreeloadover){
- iframepage.src=contextPath+"/zygl/treeiframe.html?model=tckzTree";
- }else{
- if(iframepage.contentWindow){
- iframepage.contentWindow.gis.tree.inittreeCheck("tree");
- }
- }
- }
- }
- /*
- * 获取参数
- */
- gis.script.queryString = function (uri,val){
- //var uri = window.location.search;
- var re = new RegExp("" +val+ "=([^\&\?]*)", "ig");
- return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);
- }
- $(document).ready(function() {
- if(document.getElementById("treetydiviframe")){
- //${contextPath}/zygl/gisiframe.html?model=commonTree
- document.getElementById("treetydiviframe").src=contextPath+"/zygl/treeiframe.html?model=commonTree";
- }
-
- gis.script.init();
-
-
- });
|