gis.map.data.js 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. gis.script.gisLayerinfo={};
  2. gis.script.gisidTo={};
  3. gis.script.featuresBySQLServiceprocessAsync=true;
  4. gis.script.locationLayerRunRemoveAllFeatures=true;
  5. gis.script.gis_gk_key="GK_BASIC_JSJY_GK_GK";
  6. gis.script.popSize={GK_BASIC_JSJY_GK_GK:{width:320,height:320}};//gh:12874
  7. /*
  8. * 用于树节点定位,根据配置信息读取空间数据信息,
  9. */
  10. gis.script.loadgisService = function(treeNode,objdata){
  11. //alert(treeNode.treeNodeType+"--"+objdata.id);
  12. var dataServices=gisConfigBean.dataconfig;
  13. if(dataServices){
  14. gis.script.consolelog('dataServices',dataServices);
  15. for(var n in dataServices){
  16. var data=gisConfigBean.dataconfig[n];
  17. if(data.gisLayerinfoKey&&treeNode.treeNodeType&&treeNode.treeNodeType==data.gisLayerinfoKey){
  18. //alert(treeNode.treeNodeType+"--"+objdata.id);
  19. var originaldata = gisConfigBean.dataconfig[n];
  20. var data=jQuery.extend(true, {}, originaldata);
  21. if(data.Model&&data.Model[gis.script.modelid]){
  22. var model=data.Model[gis.script.modelid];
  23. data.datasetNames=data.datasetNames.split(",");
  24. data.fields=data.fields.split(",");
  25. data.cachedata=model.cachedata||data.cachedata;
  26. data.zoom=model.zoom||data.zoom;
  27. data.attributeFilter=data.gisLayerinfoAttrKey+"="+objdata.id;
  28. data.treelocationHighlight=model.treelocationHighlight||"false";
  29. data.selectOpenPopfun=model.onSelectOpenPopkey;
  30. data.url=data.url||defdataUrl;
  31. //alert(data.attributeFilter);
  32. //console.log("data",data);
  33. gis.script.loadServicetreelocation(data,objdata);
  34. }
  35. break;
  36. }
  37. /*
  38. if(data.Model&&data.Model[gis.script.modelid]){
  39. var model=data.Model[gis.script.modelid];
  40. data.datasetNames=data.datasetNames.split(",");
  41. data.fields=data.fields.split(",");
  42. data.cachedata=model.cachedata||data.cachedata;
  43. data.zoom=model.zoom||data.zoom;
  44. gis.script.loadLayerFeaturesBySqls(data);
  45. }
  46. */
  47. }
  48. }
  49. }
  50. /*
  51. * 根据空间数据信息定位
  52. */
  53. gis.script.loadServicetreelocation = function(o,objdata){
  54. var featureParam = new SuperMap.REST.FilterParameter({
  55. //name: o.name,
  56. fields:o.fields,
  57. attributeFilter:o.attributeFilter
  58. });
  59. var featuresBySQLParams=new SuperMap.REST.GetFeaturesBySQLParameters({
  60. //toIndex:65536,
  61. toIndex:-1,
  62. queryParameter:featureParam,
  63. datasetNames:o.datasetNames
  64. });
  65. var featuresBySQLService = new SuperMap.REST.GetFeaturesBySQLService(o.url, {
  66. eventListeners: {
  67. "processCompleted":function(e){
  68. var result=e.result;
  69. //console.log('result>>',result);
  70. var features=result.features;
  71. if(features&&features.length){
  72. //alert(features.length);
  73. var feature = features[0];
  74. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  75. if(modifyvectorLayer){
  76. try{
  77. gis.script.clearAllDeactivate();
  78. nowModifyFeature=feature.clone();
  79. nowModifyFeature.attributes=nowModifyFeature.attributes||{}
  80. nowModifyFeature.attributes.gisEditLayerinfoKey=o.gisLayerinfoKey;
  81. nowModifyFeature.attributes.featureidval=feature.fid;
  82. nowModifyFeature.attributes.editinfoobj={lon:centerLonLat.lon,lat:centerLonLat.lat,zoom:o.zoom||6};
  83. //console.log("1.nowModifyFeature.attributes.editinfoobj",nowModifyFeature.attributes.editinfoobj);
  84. modifyvectorLayer.removeAllFeatures();
  85. modifyvectorLayer.addFeatures(nowModifyFeature);
  86. //console.log('o>>',o);
  87. }catch(e){
  88. }
  89. }
  90. if(locationLayer){
  91. locationLayer.removeAllFeatures();
  92. if(o.treelocationHighlight&&o.treelocationHighlight=="true"){
  93. var fillColor="#a4a5a7";//"#ffff00"
  94. var fillOpacity=0.5;
  95. /*
  96. if(o.gisLayerinfoKey&&(o.gisLayerinfoKey=="GK_BASIC_JSJY_JYR_MT"||o.gisLayerinfoKey=="GK_BASIC_JSJY_JYR_BW")){
  97. fillColor="#000000";
  98. fillOpacity=0.8;
  99. //alert(fillOpacity);
  100. }
  101. */
  102. feature.style = {
  103. fill:true,
  104. stroke:true,
  105. strokeColor: "#ffff00",
  106. strokeWidth: 3,
  107. //pointerEvents: "visiblePainted",
  108. //fillColor: "#a4a5a7",
  109. strokeDashstyle:"solid",
  110. fillColor: fillColor,
  111. fillOpacity: fillOpacity
  112. };
  113. //bwvectorLayer.addFeatures(feature);
  114. locationLayer.addFeatures(feature);
  115. try{
  116. labelLayer.removeAllFeatures();
  117. if(!o.gisLayerinfoKey||o.gisLayerinfoKey!="GK_BASIC_JSJY_JYR"){
  118. if(o.labelfield&&feature.attributes[o.labelfield]){
  119. var geoText = new SuperMap.Geometry.GeoText(centerLonLat.lon, centerLonLat.lat,feature.attributes[o.labelfield]);
  120. var geotextFeature = new SuperMap.Feature.Vector(geoText);
  121. labelLayer.addFeatures([geotextFeature]);
  122. }
  123. }
  124. }catch(e){
  125. }
  126. try{
  127. if(objdata&&objdata.showPop&&objdata.showPop=='true'){
  128. //console.log('o>>',o);
  129. if(o&&o.selectOpenPopfun&&gis.script[o.selectOpenPopfun]){
  130. feature.attributes.onSelectOpenPopkey=o.onSelectOpenPopkey;
  131. feature.attributes.gisLayerinfoAttr=feature.attributes[o.gisLayerinfoAttrKey];
  132. feature.attributes.infokey=o.gisLayerinfoKey+"_"+feature.attributes.gisLayerinfoAttr;
  133. gis.script[o.selectOpenPopfun](feature);
  134. }
  135. }
  136. }catch(e){
  137. }
  138. }
  139. }
  140. //gis.script.locationLayerRunRemoveAllFeatures=false;
  141. map.setCenter(new SuperMap.LonLat(centerLonLat.lon, centerLonLat.lat),o.zoom||6);
  142. }
  143. },
  144. "processFailed": gis.script.sqlProcessFailed
  145. }
  146. });
  147. featuresBySQLService.processAsync(featuresBySQLParams);
  148. //featuresBySQLService.processAsync(featuresBySQLParams);
  149. }
  150. /*
  151. * 根据配置信息读取空间数据信息,在相关图层绘制相应图层信息,包括港口、港区、经营人、码头、泊位、船舶
  152. */
  153. gis.script.loadLayerdata = function() {
  154. /*
  155. gis.script.loadLayerSql({
  156. attributeFilter:"smid>0",
  157. name:"港口@合并#3",
  158. fields:["smid","name","类别"],
  159. gisLayerinfoKey:gis.script.gis_gk_key
  160. },gis.script.gkonSelect);
  161. */
  162. /*
  163. var fParamList=[{
  164. attributeFilter:"smid>0 and name!=''",
  165. name:"港口@合并#3",
  166. fields:["smid","name","类别"],
  167. gisLayerinfoKey:gis.script.gis_gk_key,
  168. onSelectOpenPopkey:"openPop_GK"
  169. }];
  170. gis.script.loadLayerQueryBySqls(fParamList);
  171. */
  172. /*
  173. gis.script.loadLayerFeaturesBySqls({
  174. url:gis.script.iserverUrl+"/data-gk/rest/data",
  175. name: "港口@合并",
  176. attributeFilter: "SMID>0 and name!=''",
  177. datasetNames:["合并:港口"],
  178. fields:["smid","name","类别",'港口代码'],
  179. gisLayerinfoKey:gis.script.gis_gk_key,
  180. gisLayerinfoAttrKey:'港口代码',
  181. processCompleted:gis.script.gkonSelect,
  182. onSelectOpenPopkey:"openPop_GK"});
  183. */
  184. /*
  185. gis.script.loadLayerFeaturesBySqls({
  186. url:"http://192.168.39.120:8090/iserver/services/data-ST/rest/data",
  187. name: "L_GK_PT@gkzyYS",
  188. attributeFilter: "SMID>0",
  189. datasetNames:["gkzyYS:L_GK_PT"],
  190. fields:["smid","name","类别",'港口代码'],
  191. gisLayerinfoKey:gis.script.gis_gk_key,
  192. gisLayerinfoAttrKey:'港口代码',
  193. //processCompleted:gis.script.gkonSelect,
  194. onSelectOpenPopkey:"openPop_GK"});
  195. */
  196. //gis.script.loadzyqsjServices("zyqsjServices",{zyid:47});
  197. //gis.script.loadgisService({treeNodeType:"GK_BASIC_JSJY_GK_ZYQ"},{id:47})
  198. //gis.script.loadgisService({treeNodeType:"GK_BASIC_JSJY_GK_GQ"},{id:32100101,showPop:"true"})
  199. var dataServices=gisConfigBean.dataconfig;
  200. if(dataServices){
  201. gis.script.consolelog('dataServices',dataServices);
  202. for(var n in dataServices){
  203. var originaldata = gisConfigBean.dataconfig[n];
  204. var data=jQuery.extend(true, {}, originaldata);
  205. if(data.Model&&data.Model[gis.script.modelid]){
  206. var model=data.Model[gis.script.modelid];
  207. data.datasetNames=data.datasetNames.split(",");
  208. data.fields=data.fields.split(",");
  209. data.cachedata=model.cachedata||data.cachedata;
  210. data.zoom=model.zoom||data.zoom;
  211. data.processCompleted=model.processCompleted;
  212. data.onSelectOpenPopkey=model.onSelectOpenPopkey;
  213. //alert(data.processCompleted+"--"+data.onSelectOpenPopkey);
  214. data.modelObj=model;
  215. //defdataUrl
  216. data.url=data.url||defdataUrl;
  217. //alert(data.label+"---"+data.url);
  218. gis.script.loadLayerFeaturesBySqls(data);
  219. }
  220. }
  221. }
  222. }
  223. /*
  224. * 读取空间数据信息,在相关图层绘制相应图层信息
  225. */
  226. gis.script.loadLayerFeaturesBySqls = function(o){
  227. var featureParam = new SuperMap.REST.FilterParameter({
  228. //name: o.name,
  229. fields:o.fields,
  230. attributeFilter:o.attributeFilter
  231. });
  232. var featuresBySQLParams=new SuperMap.REST.GetFeaturesBySQLParameters({
  233. //toIndex:65536,
  234. toIndex:-1,
  235. queryParameter:featureParam,
  236. datasetNames:o.datasetNames
  237. });
  238. var featuresBySQLService = new SuperMap.REST.GetFeaturesBySQLService(o.url, {
  239. eventListeners: {
  240. "processCompleted":function(data){
  241. gis.script.sqlProcessCompleted(data,o);
  242. },
  243. "processFailed": gis.script.sqlProcessFailed
  244. }
  245. });
  246. featuresBySQLService.processAsync(featuresBySQLParams);
  247. }
  248. /*
  249. * processCompleted回调函数,读取空间数据信息,在相关图层绘制相应图层信息
  250. */
  251. gis.script.sqlProcessCompleted=function(e,o){
  252. var result=e.result;
  253. gis.script.consolelog('result::',result);
  254. gis.script.consolelog('o::',o);
  255. var features=result.features;
  256. //console.log("features",features);
  257. if(features&&features.length){
  258. gis.script.gisLayerinfo[o.gisLayerinfoKey]={};
  259. for(var k=0;k<features.length;k++){
  260. var feature = features[k];
  261. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  262. //alert(JSON.stringify(feature.attributes));
  263. var idata={};
  264. idata.smid=feature.attributes.SMID||feature.attributes.smid;
  265. idata.lon=centerLonLat.lon;
  266. idata.lat=centerLonLat.lat;
  267. idata.zoom=o.zoom;
  268. if(feature.attributes){
  269. //feature.attributes.gisidToKey=o.gisLayerinfoKey+"_"+idata.smid;
  270. //feature.attributes.gisLayerinfoKey=o.gisLayerinfoKey;
  271. feature.attributes.onSelectOpenPopkey=o.onSelectOpenPopkey;
  272. feature.attributes.gisLayerinfoAttr=feature.attributes[o.gisLayerinfoAttrKey];
  273. feature.attributes.infokey=o.gisLayerinfoKey+"_"+feature.attributes.gisLayerinfoAttr;
  274. feature.attributes.gisEditLayerinfoKey=o.gisLayerinfoKey;
  275. feature.attributes.featureidval=feature.fid;
  276. feature.attributes.labelfieldid=o.labelfield;
  277. if(o.cachedata&&o.cachedata=='true'){
  278. gis.script.gisLayerinfo[o.gisLayerinfoKey][feature.attributes.gisLayerinfoAttr]=idata;
  279. }
  280. if(o.processCompleted&&gis.script[o.processCompleted]){
  281. gis.script[o.processCompleted](feature,o);
  282. }
  283. /*
  284. if(o.processCompleted){
  285. o.processCompleted(feature);
  286. }
  287. */
  288. }
  289. //alert(feature.attributes[o.gisLayerinfoAttrKey]);
  290. //gis.script.gisLayerinfo[o.gisLayerinfoKey][feature.attributes.SMID]=idata;
  291. //break;
  292. }
  293. //debugger;
  294. gis.script.consolelog('::gis.script.gisLayerinfo::',gis.script.gisLayerinfo);
  295. }
  296. }
  297. /*
  298. * 根据参数绘制Marker,包括港口、取水口...
  299. */
  300. gis.script.publiconSelectMark=function(feature,o){
  301. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  302. var typename="";
  303. if(o.modelObj&&!gis.script.isBlank(o.modelObj.srcattr)){
  304. typename=feature.attributes[o.modelObj.srcattr];
  305. }
  306. if(gis.script.isBlank(o.modelObj.srcattr)){
  307. typename=o.modelObj.srcname;
  308. }
  309. var item={type:o.modelObj.marktypename+typename,functionName:o.onSelectOpenPopkey,
  310. lon:centerLonLat.lon,lat:centerLonLat.lat,w:o.modelObj.width||32,h:o.modelObj.height||32};
  311. item.feature=feature;
  312. item.marktypename=o.modelObj.marktypename;
  313. //item.src='../images/markerbig_select.png';
  314. item.src=o.modelObj.src;
  315. item.defshow=o.modelObj.defshow;
  316. item.showMinzoom=o.modelObj.showMinzoom;
  317. item.showMaxzoom=o.modelObj.showMaxzoom;
  318. if(!gis.script.isBlank(typename)){
  319. item.src=contextPath+'/theme/images/gis/'+typename+'.png';
  320. }
  321. //alert(item.src)
  322. gis.script.addMarker(item);
  323. }
  324. gis.script.gkonSelectMark=function(feature,o){
  325. //alert(o.onSelectOpenPopkey);
  326. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  327. var srcpng=feature.attributes['类别'];
  328. var item={type:'gk'+srcpng,functionName:o.onSelectOpenPopkey,lon:centerLonLat.lon,lat:centerLonLat.lat,w:32,h:32};
  329. item.feature=feature;
  330. item.src='../images/markerbig_select.png';
  331. if(srcpng){
  332. item.src=contextPath+'/theme/images/gis/'+srcpng+'.png';
  333. }
  334. item.name=feature.attributes.name;
  335. gis.script.addMarker(item);
  336. }
  337. /*
  338. * 绘画港区feature
  339. */
  340. gis.script.gqonSelect=function(feature,o){
  341. /*
  342. feature.style = {
  343. strokeColor: "#304DBE",
  344. strokeWidth: 2,
  345. pointerEvents: "visiblePainted",
  346. fillColor: "#304DBE",
  347. fillOpacity: 0.5
  348. };
  349. */
  350. //gis.script.consolelog('pointFeature:',feature);
  351. gqvectorLayer.addFeatures(feature);
  352. }
  353. /*
  354. * 绘画作业区feature
  355. */
  356. gis.script.zyqonSelect=function(feature,o){
  357. //console.log("1>>>",feature)
  358. zyqvectorLayer.addFeatures(feature);
  359. }
  360. /*
  361. * 锚地业区feature
  362. */
  363. gis.script.mdonSelect=function(feature,o){
  364. //console.log("2>>>",feature)
  365. mdvectorLayer.addFeatures(feature);
  366. }
  367. /*
  368. * 绘画经营人feature,并且添加经营人名称
  369. */
  370. gis.script.jyronSelect=function(feature,o){
  371. /*
  372. var sid=feature.attributes.smid;
  373. if(sid==51){
  374. // 浅层复制(只复制顶层的非 object 元素)
  375. //var newObject = jQuery.extend({}, oldObject);
  376. // 深层复制(一层一层往下复制直到最底层)
  377. //var featureDv = $.extend(true, {}, feature);
  378. var feature2=feature.clone()
  379. feature2.style = {
  380. strokeColor: "#304DBE",
  381. strokeWidth: 2,
  382. pointerEvents: "visiblePainted",
  383. fillColor: "#ff0000",
  384. fillOpacity: 0.5
  385. };
  386. locationLayer.addFeatures(feature);
  387. //alert(feature.style);alert(featureDv.style);
  388. }
  389. */
  390. //gis.script.consolelog('pointFeature:',feature);
  391. //console.log('pointFeature:',feature);
  392. jyrvectorLayer.addFeatures(feature);
  393. try{
  394. if(feature.attributes&&o.labelfield){
  395. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  396. var geoText = new SuperMap.Geometry.GeoText(centerLonLat.lon, centerLonLat.lat,gis.script.labelfontformat(feature.attributes[o.labelfield],5));
  397. var geotextFeature = new SuperMap.Feature.Vector(geoText);
  398. jyrlabelLayer.addFeatures([geotextFeature]);
  399. }
  400. }catch(e){
  401. }
  402. }
  403. /*
  404. * 格式化绘制名称
  405. */
  406. gis.script.labelfontformat=function(textval,count){
  407. if(gis.script.isNotBlank(textval)){
  408. if(count&&gis.script.isNum(count)){
  409. //console.log("textval",textval);
  410. var textarray=textval.split("");
  411. var newtextarray=[];
  412. if(textarray.length>count){
  413. for(var i=0;i<textarray.length;i++){
  414. newtextarray.push(textarray[i]);
  415. if((i+1)%count==0){
  416. newtextarray.push("\n");
  417. }
  418. }
  419. return newtextarray.join("");
  420. }
  421. //console.log("textarray",textarray);
  422. }
  423. return textval;
  424. }
  425. return "";
  426. }
  427. /*
  428. * 绘画码头feature
  429. */
  430. gis.script.mtonSelect=function(feature,o){
  431. mtvectorLayer.addFeatures(feature);
  432. }
  433. /*
  434. * 绘画泊位feature
  435. */
  436. gis.script.bwonSelect=function(feature,o){
  437. bwvectorLayer.addFeatures(feature);
  438. }
  439. gis.script.sqlProcessFailed=function(e){
  440. alert(e.error.errorMsg);
  441. }
  442. gis.script.loadLayerQueryBySqls = function(list){
  443. if(list&&list.length){
  444. var queryParams=[];
  445. for(var i=0;i<list.length;i++){
  446. var fileterParam = new SuperMap.REST.FilterParameter(list[i]);
  447. queryParams.push(fileterParam);
  448. }
  449. var queryBySQLParams=new SuperMap.REST.QueryBySQLParameters({
  450. queryParams:queryParams
  451. });
  452. var queryBySQLService = new SuperMap.REST.QueryBySQLService(gis.script.url, {eventListeners: {
  453. "processCompleted": function(e){
  454. var result=e.result;
  455. //gis.script.consolelog('result:',result);
  456. if(result&&result.totalCount>0&&result.recordsets.length==list.length){
  457. for(var i=0;i<result.recordsets.length;i++){
  458. var recordset=result.recordsets[i];
  459. var o=list[i];
  460. gis.script.gisLayerinfo[o.gisLayerinfoKey]={};
  461. for(var k=0;k<recordset.features.length;k++){
  462. var feature = recordset.features[k];
  463. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  464. //gisidTo
  465. if(feature.attributes){
  466. //feature.attributes.gisidToKey=o.gisLayerinfoKey+"_"+feature.attributes.smid;
  467. //feature.attributes.gisLayerinfoKey=o.gisLayerinfoKey;
  468. feature.attributes.onSelectOpenPopkey=o.onSelectOpenPopkey;
  469. }
  470. var temp={};
  471. temp=feature.attributes;
  472. temp.lon=centerLonLat.lon;
  473. temp.lat=centerLonLat.lat;
  474. gis.script.gisLayerinfo[o.gisLayerinfoKey][feature.attributes.smid]=temp;
  475. //alert(JSON.stringify(gis.script.gisLayerinfo[o.gisLayerinfoKey]));
  476. if(gis.script.gis_gk_key==o.gisLayerinfoKey){
  477. gis.script.gkonSelect(feature);
  478. }
  479. //break;
  480. }
  481. }
  482. }
  483. },
  484. "processFailed": function(e){
  485. alert(e.error.errorMsg);
  486. }
  487. }
  488. });
  489. queryBySQLService.processAsync(queryBySQLParams);
  490. }
  491. }
  492. gis.script.loadLayerSql = function(o,fun){
  493. var fileterParam = new SuperMap.REST.FilterParameter(o);
  494. var queryBySQLParams=new SuperMap.REST.QueryBySQLParameters({
  495. queryParams:[fileterParam]
  496. });
  497. var queryBySQLService = new SuperMap.REST.QueryBySQLService(gis.script.url, {eventListeners: {
  498. "processCompleted": function(e){
  499. var result=e.result;
  500. if(result&&result.totalCount>0){
  501. var recordset=result.recordsets[0];
  502. gis.script.gisLayerinfo[o.gisLayerinfoKey]={};
  503. for(var k=0;k<recordset.features.length;k++){
  504. var feature = recordset.features[k];
  505. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  506. //alert(JSON.stringify(feature.attributes));
  507. //alert(feature.geometry.getBounds().getCenterLonLat())
  508. if(feature.attributes.name==""){
  509. continue;
  510. }
  511. var temp={};
  512. temp=feature.attributes;
  513. temp.lon=centerLonLat.lon;
  514. temp.lat=centerLonLat.lat;
  515. gis.script.gisLayerinfo[o.gisLayerinfoKey][feature.attributes.smid]=temp;
  516. //alert(JSON.stringify(gis.script.gisLayerinfo[o.gisLayerinfoKey]));
  517. if(fun){
  518. fun(feature);
  519. }
  520. //break;
  521. }
  522. }
  523. },
  524. "processFailed": function(e){
  525. alert(e.error.errorMsg);
  526. }
  527. }
  528. });
  529. queryBySQLService.processAsync(queryBySQLParams);
  530. }
  531. gis.script.gkonSelect = function(feature){
  532. /*
  533. var centerLonLat=feature.geometry.getBounds().getCenterLonLat();
  534. var item={type:"1",functionName:"showMarkerInfo",lon:centerLonLat.lon,lat:centerLonLat.lat,w:21,h:25};
  535. item.src='../images/markerbig_select.png';
  536. item.name=feature.attributes.name;
  537. gis.script.addMarker(item);
  538. */
  539. feature.style={
  540. fillColor:"white",
  541. strokeColor:"white",
  542. pointRadius:13,
  543. strokeWidth:0,
  544. fillOpacity: 0
  545. };
  546. //gis.script.consolelog('pointFeature:',feature);
  547. gkvectorLayer.addFeatures(feature);
  548. }
  549. gis.script.openPop_GK_id=function(feature,e){
  550. if(gis.script.gisidTo){
  551. //alert(gis.script.gis_gk_key+"_"+feature.attributes.SMID);
  552. if(feature.attributes&&feature.attributes.infokey){
  553. //var sinfo=gis.script.gisidTo[gis.script.gis_gk_key+"_"+feature.attributes.gisLayerinfoAttr];
  554. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  555. if(sinfo&&sinfo.ID){
  556. //alert(sinfo.ID);
  557. gis.script.jsonAjax({url:contextPath+"/zygl/queryGK.html",async:true,data:{id:sinfo.ID}},
  558. function(data){
  559. //alert(JSON.stringify(data));
  560. if(data&&data.message){
  561. //alert(data.message);
  562. //alert(gis.script.popSize[feature.attributes.gisLayerinfoKey]);
  563. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:269},data.message,e);
  564. //alert(feature.attributes.labelfieldid);
  565. gis.anchored.addPopup(map,popup,feature);
  566. //gis.anchored.addFramedCloud(feature.geometry.getBounds().getCenterLonLat(),{},data.message);
  567. }
  568. });
  569. }else{
  570. //gis.script.openPopNull(feature);
  571. }
  572. }
  573. }
  574. }
  575. /*
  576. * 港口点击事件
  577. */
  578. gis.script.openPop_GK=function(feature,e){
  579. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  580. //alert(feature.attributes.gisLayerinfoAttr);
  581. gis.script.jsonAjax({url:contextPath+"/zygl/queryGKCode.html",async:true,data:{gkdm:feature.attributes.gisLayerinfoAttr}},
  582. function(data){
  583. if(data&&data.success&&data.message){
  584. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:233},data.message,e);
  585. gis.anchored.addPopup(map,popup,feature);
  586. }
  587. });
  588. }
  589. }
  590. gis.script.openPop_GQ_id=function(feature,e){
  591. if(feature.attributes&&feature.attributes.infokey){
  592. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  593. if(sinfo&&sinfo.ID){
  594. gis.script.jsonAjax({url:contextPath+"/zygl/queryGQ.html",async:true,data:{id:sinfo.ID}},
  595. function(data){
  596. //alert(sinfo.ID);
  597. //alert(JSON.stringify(data));
  598. if(data&&data.message){
  599. //alert(data.message);
  600. //alert(gis.script.popSize[feature.attributes.gisLayerinfoKey]);
  601. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:297},data.message,e);
  602. gis.anchored.addPopup(map,popup,feature);
  603. }
  604. });
  605. }
  606. }
  607. //gis.script.openPop_GQ_fbgp(feature);
  608. }
  609. /*
  610. * 港区点击事件
  611. */
  612. gis.script.openPop_GQ=function(feature,e){
  613. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  614. //alert(feature.attributes.gisLayerinfoAttr);
  615. gis.script.jsonAjax({url:contextPath+"/zygl/queryGQCode.html",async:true,data:{gqdm:feature.attributes.gisLayerinfoAttr}},
  616. function(data){
  617. if(data&&data.success&&data.message){
  618. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:256},data.message,e);
  619. gis.anchored.addPopup(map,popup,feature);
  620. }
  621. });
  622. }
  623. }
  624. gis.script.openPop_GQ_fbgp=function(feature){
  625. //alert(feature.geometry.intersects(feature.geometry));
  626. /*
  627. var centerLonLat=feature.geometry.getBounds().getCenterLonLat();
  628. var point= new SuperMap.Geometry.Point(centerLonLat.lon+100,centerLonLat.lat);
  629. alert(feature.geometry.intersects(point));
  630. */
  631. var getFeaturesByGeometryParameters = new SuperMap.REST.GetFeaturesByGeometryParameters({
  632. datasetNames: ["gkzyYS:L_GKJYR_PY"],
  633. toIndex:-1,
  634. spatialQueryMode:SuperMap.REST.SpatialQueryMode.INTERSECT,
  635. geometry:feature.geometry
  636. });
  637. var getFeaturesByGeometryService = new SuperMap.REST.GetFeaturesByGeometryService("http://192.168.39.120:8090/iserver/services/data-ST/rest/data", {
  638. eventListeners: {
  639. "processCompleted": function(e){
  640. gis.script.consolelog('ee:',e);
  641. },
  642. "processFailed": function(e){
  643. }
  644. }
  645. });
  646. getFeaturesByGeometryService.processAsync(getFeaturesByGeometryParameters);
  647. }
  648. gis.script.openPop_JYR_id=function(feature,e){
  649. if(feature.attributes&&feature.attributes.infokey){
  650. //gis.script.consolelog('gis.script.gisidTo:',gis.script.gisidTo);
  651. //alert(feature.attributes.smid);
  652. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  653. if(sinfo&&sinfo.ID){
  654. //alert(sinfo.ID);return;
  655. gis.script.jsonAjax({url:contextPath+"/zygl/queryJYR.html",async:true,data:{id:sinfo.ID}},
  656. function(data){
  657. if(data&&data.message){
  658. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:214},data.message,e);
  659. gis.anchored.addPopup(map,popup,feature);
  660. }
  661. });
  662. }
  663. }
  664. }
  665. /*
  666. * 经营人点击事件
  667. */
  668. gis.script.openPop_JYR=function(feature,e){
  669. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  670. //alert(feature.attributes.gisLayerinfoAttr);
  671. gis.script.jsonAjax({url:contextPath+"/zygl/queryJYRCode.html",async:true,data:{zyid:feature.attributes.gisLayerinfoAttr}},
  672. function(data){
  673. if(data&&data.success&&data.message){
  674. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:187},data.message,e);
  675. gis.anchored.addPopup(map,popup,feature);
  676. }
  677. });
  678. }
  679. }
  680. gis.script.openPop_MT_id=function(feature,e){
  681. //console.log("gis.script.gisidTo",gis.script.gisidTo)
  682. //alert(feature.attributes.infokey);return;
  683. if(feature.attributes&&feature.attributes.infokey){
  684. //gis.script.consolelog('gis.script.gisidTo:',gis.script.gisidTo);
  685. //alert(feature.attributes.smid);
  686. //alert(feature.attributes.infokey);
  687. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  688. if(sinfo&&sinfo.ID){
  689. //alert(sinfo.ID);return;
  690. gis.script.jsonAjax({url:contextPath+"/zygl/queryMT.html",async:true,data:{id:sinfo.ID}},
  691. function(data){
  692. if(data&&data.message){
  693. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:242},data.message,e);
  694. gis.anchored.addPopup(map,popup,feature);
  695. }
  696. });
  697. }
  698. }
  699. }
  700. /*
  701. * 码头点击事件
  702. */
  703. gis.script.openPop_MT=function(feature,e){
  704. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  705. //alert(feature.attributes.gisLayerinfoAttr);
  706. gis.script.jsonAjax({url:contextPath+"/zygl/queryMTCode.html",async:true,data:{zyid:feature.attributes.gisLayerinfoAttr}},
  707. function(data){
  708. if(data&&data.success&&data.message){
  709. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:210},data.message,e);
  710. gis.anchored.addPopup(map,popup,feature);
  711. }
  712. });
  713. }
  714. }
  715. gis.script.openPop_BW_id=function(feature,e){
  716. //return;
  717. if(feature.attributes&&feature.attributes.infokey){
  718. //gis.script.consolelog('gis.script.gisidTo:',gis.script.gisidTo);
  719. //alert(feature.attributes.smid);
  720. //alert(feature.attributes.infokey);
  721. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  722. if(sinfo&&sinfo.ID){
  723. //alert(sinfo.ID);return;
  724. gis.script.jsonAjax({url:contextPath+"/zygl/queryBW.html",async:true,data:{id:sinfo.ID}},
  725. function(data){
  726. if(data&&data.message){
  727. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:460,height:289},data.message,e);
  728. gis.anchored.addPopup(map,popup,feature);
  729. }
  730. });
  731. }
  732. }
  733. }
  734. /*
  735. * 泊位点击事件
  736. */
  737. gis.script.openPop_BW=function(feature,e){
  738. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  739. gis.script.jsonAjax({url:contextPath+"/zygl/popupTableshow.html",async:true,data:{sqlid:"queryPopupBWById",id:feature.attributes.gisLayerinfoAttr,namespace:"2"}},
  740. function(data){
  741. //alert(JSON.stringify(data));
  742. //console.log(1,data);
  743. if(data){
  744. gis.script.jsonAjax({url:contextPath+"/zygl/popupTableshow.html",async:true,data:{sqlid:"queryPopupBWById",id:data.AQID||'-1',bwdm:data.BWDM||'-1',namespace:"3"}},
  745. function(data2){
  746. //alert(JSON.stringify(data2));
  747. //console.log(2,data2);
  748. if(data2){
  749. var dataext=jQuery.extend(true, data, data2);
  750. //console.log(3,dataext);
  751. dataext.GKSBSL=(dataext.GKSBSL1||0)+(dataext.GKSBSL2||0);
  752. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:500,height:256,tconfig:"queryPopupBWById"},dataext,e);
  753. gis.anchored.addPopup(map,popup,feature);
  754. }
  755. },function(jqXHR, textStatus, errorThrown){
  756. //alert(jqXHR.responseText);
  757. });
  758. }
  759. /*
  760. if(data){
  761. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:500,height:256,tconfig:"queryPopupBWById"},data,e);
  762. gis.anchored.addPopup(map,popup,feature);
  763. }*/
  764. },function(jqXHR, textStatus, errorThrown){
  765. //alert(jqXHR.responseText);
  766. });
  767. }
  768. }
  769. gis.script.openPop_BW2=function(feature,e){
  770. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  771. //alert(feature.attributes.gisLayerinfoAttr);
  772. gis.script.jsonAjax({url:contextPath+"/zygl/queryBWCode.html",async:true,data:{zyid:feature.attributes.gisLayerinfoAttr}},
  773. function(data){
  774. /*
  775. if(data&&data.success&&data.message){
  776. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:460,height:289},data.message,e);
  777. gis.anchored.addPopup(map,popup,feature);
  778. }*/
  779. //console.log(data);
  780. if(data){
  781. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:500,height:256,tconfig:"queryBWCode"},data,e);
  782. gis.anchored.addPopup(map,popup,feature);
  783. }
  784. });
  785. }
  786. }
  787. gis.script.openPop_ZYQ=function(feature,e){
  788. //console.log('feature>>',feature);
  789. //alert(feature.attributes.gisLayerinfoAttr);
  790. if(feature.attributes&&feature.attributes.gisLayerinfoAttr){
  791. gis.script.jsonAjax({url:contextPath+"/zygl/queryZYQbyZYID.html",async:true,data:{id:feature.attributes.gisLayerinfoAttr}},
  792. function(data){
  793. if(data&&data.success&&data.message){
  794. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:460,height:210},data.message,e);
  795. gis.anchored.addPopup(map,popup,feature);
  796. }
  797. });
  798. }
  799. }
  800. gis.script.openPop_MD=function(feature,e){
  801. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  802. gis.script.jsonAjax({url:contextPath+"/zygl/popupTableshow.html",async:true,data:{sqlid:"queryPopupMDById",id:feature.attributes.gisLayerinfoAttr,namespace:"2"}},
  803. function(data){
  804. //alert(JSON.stringify(data));
  805. //console.log(1,data);
  806. if(data){
  807. var dataext=jQuery.extend(true, {}, data);
  808. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:250,height:164,tconfig:"queryPopupMDById"},dataext,e);
  809. gis.anchored.addPopup(map,popup,feature);
  810. /*
  811. gis.script.jsonAjax({url:contextPath+"/zygl/popupTableshow.html",async:true,data:{sqlid:"queryPopupBWById",id:data.AQID||'-1',bwdm:data.BWDM||'-1',namespace:"3"}},
  812. function(data2){
  813. if(data2){
  814. var dataext=jQuery.extend(true, data, data2);
  815. //console.log(3,dataext);
  816. dataext.GKSBSL=(dataext.GKSBSL1||0)+(dataext.GKSBSL2||0);
  817. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:500,height:256,tconfig:"queryPopupBWById"},dataext,e);
  818. gis.anchored.addPopup(map,popup,feature);
  819. }
  820. },function(jqXHR, textStatus, errorThrown){
  821. //alert(jqXHR.responseText);
  822. });
  823. */
  824. }
  825. },function(jqXHR, textStatus, errorThrown){
  826. //alert(jqXHR.responseText);
  827. });
  828. }
  829. }
  830. gis.script.openPopNull=function(feature){
  831. //var popup = gis.anchored.popup(feature.geometry.getBounds().getCenterLonLat(),{});
  832. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:220,height:60},"<div class='titleClass'>信息</div><div class='openPopNull'>无关联数据<div>");
  833. gis.anchored.addPopup(map,popup);
  834. }
  835. gis.script.initLoadGisidTo = function(){
  836. gis.script.jsonAjax({url:contextPath+"/zygl/gisidTo.html",contentType:'application/json;charset=utf-8',async:false,data:JSON.stringify({})},
  837. function(data){
  838. //alert(JSON.stringify(data));
  839. gis.script.gisidTo=data;
  840. });
  841. }
  842. /*
  843. * 封装的ajax调用
  844. */
  845. gis.script.jsonAjax= function(obj,successMethod,errorMethod){
  846. var ajaxInfo={
  847. type : 'post',
  848. dataType : 'json',
  849. //contentType : 'application/json;charset=utf-8',
  850. //timeout : 10000, //超时时间设置,单位毫秒
  851. cache : false,// 不从缓存中去数据
  852. async : true,
  853. //url : obj.url,
  854. //data : JSON.stringify(jsondate),
  855. //headers:headinfo,
  856. success : function(data) {
  857. if(successMethod){
  858. successMethod(data);
  859. }
  860. },
  861. error : function(jqXHR, textStatus, errorThrown) {
  862. //alert(jqXHR.responseText);
  863. if(errorMethod){
  864. errorMethod(jqXHR, textStatus, errorThrown);
  865. }
  866. }
  867. };
  868. ajaxInfo.url=obj.url;
  869. ajaxInfo.data=obj.data||{};
  870. if(typeof(obj.async)!="undefined"){
  871. ajaxInfo.async=obj.async
  872. }
  873. if(typeof(obj.contentType)!="undefined"){
  874. //alert(obj.contentType);
  875. ajaxInfo.contentType=obj.contentType;
  876. }
  877. //alert(ajaxInfo);
  878. $.ajax(ajaxInfo);
  879. }
  880. gis.script.isNum=function(value){
  881. if(typeof(value)!='undefined'){
  882. var result = true;
  883. var pattern = /^\d*(\.\d*)?$/;
  884. if (!pattern.test(value)) result = false;
  885. var num = parseFloat(value);
  886. if (isNaN(num)) result = false;
  887. return result;
  888. }
  889. return false;
  890. }
  891. gis.script.isBlank=function(value){
  892. if(value){
  893. value=value+"";
  894. for(var i=0; i<value.length; i++) {
  895. var c = value.charAt(i);
  896. if ((c!=' ')&&(c!='\n')&&(c!='\t')) return false;
  897. }
  898. }
  899. return true;
  900. }
  901. gis.script.isNotBlank=function(value){
  902. if(typeof(value)!='undefined'){
  903. value=value+"";
  904. for(var i=0; i<value.length; i++) {
  905. var c = value.charAt(i);
  906. if ((c!=' ')&&(c!='\n')&&(c!='\t')) return true;
  907. }
  908. }
  909. return false;
  910. }
  911. gis.script.consolelog=function(t,o){
  912. //console.log(t,o);
  913. }
  914. gis.script.loadzyqsjServices = function(servicename,obj) {
  915. var dataServices=gisConfigBean.dataconfig;
  916. if(dataServices&&obj&&gis.script.isNum(obj.zyid)){
  917. //gis.script.consolelog('dataServices',dataServices);
  918. var originaldata = gisConfigBean.dataconfig[servicename];
  919. var data=jQuery.extend(true, {}, originaldata);
  920. if(data.Model&&data.Model[gis.script.modelid]){
  921. var model=data.Model[gis.script.modelid];
  922. data.datasetNames=data.datasetNames.split(",");
  923. data.fields=data.fields.split(",");
  924. data.cachedata=model.cachedata||data.cachedata;
  925. data.zoom=model.zoom||data.zoom;
  926. data.treelocationHighlight=model.treelocationHighlight||"false";
  927. data.url=data.url||defdataUrl;
  928. data.attributeFilter="ID="+obj.zyid
  929. //console.log("data",data);
  930. gis.script.loadServicetreelocation(data,obj);
  931. }
  932. }
  933. }
  934. gis.script.loadServicexmlzyqsjlocation = function(o,datao) {
  935. var featureParam = new SuperMap.REST.FilterParameter({
  936. //name: o.name,
  937. fields:o.fields,
  938. attributeFilter:o.attributeFilter
  939. });
  940. var featuresBySQLParams=new SuperMap.REST.GetFeaturesBySQLParameters({
  941. //toIndex:65536,
  942. toIndex:-1,
  943. queryParameter:featureParam,
  944. datasetNames:o.datasetNames
  945. });
  946. var featuresBySQLService = new SuperMap.REST.GetFeaturesBySQLService(o.url, {
  947. eventListeners: {
  948. "processCompleted":function(e){
  949. var result=e.result;
  950. //console.log('..>>',result);
  951. var features=result.features;
  952. if(features&&features.length){
  953. }
  954. },
  955. "processFailed": gis.script.sqlProcessFailed
  956. }
  957. });
  958. featuresBySQLService.processAsync(featuresBySQLParams);
  959. }
  960. $(document).ready(function() {
  961. //预先加载
  962. //gis.script.initLoadGisidTo();
  963. //$.growlUI('提示', '删除成功!');
  964. });