gis.map.data.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  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. var dataServices=gisConfigBean.dataconfig;
  155. if(dataServices){
  156. gis.script.consolelog('dataServices',dataServices);
  157. for(var n in dataServices){
  158. var originaldata = gisConfigBean.dataconfig[n];
  159. var data=jQuery.extend(true, {}, originaldata);
  160. if(data.Model&&data.Model[gis.script.modelid]){
  161. var model=data.Model[gis.script.modelid];
  162. data.datasetNames=data.datasetNames.split(",");
  163. data.fields=data.fields.split(",");
  164. data.cachedata=model.cachedata||data.cachedata;
  165. data.zoom=model.zoom||data.zoom;
  166. data.processCompleted=model.processCompleted;
  167. data.onSelectOpenPopkey=model.onSelectOpenPopkey;
  168. //alert(data.processCompleted+"--"+data.onSelectOpenPopkey);
  169. data.modelObj=model;
  170. //defdataUrl
  171. data.url=data.url||defdataUrl;
  172. //alert(data.label+"---"+data.url);
  173. gis.script.loadLayerFeaturesBySqls(data);
  174. }
  175. }
  176. }
  177. }
  178. /*
  179. * 读取空间数据信息,在相关图层绘制相应图层信息
  180. */
  181. gis.script.loadLayerFeaturesBySqls = function(o){
  182. var featureParam = new SuperMap.REST.FilterParameter({
  183. //name: o.name,
  184. fields:o.fields,
  185. attributeFilter:o.attributeFilter
  186. });
  187. var featuresBySQLParams=new SuperMap.REST.GetFeaturesBySQLParameters({
  188. //toIndex:65536,
  189. toIndex:-1,
  190. queryParameter:featureParam,
  191. datasetNames:o.datasetNames
  192. });
  193. var featuresBySQLService = new SuperMap.REST.GetFeaturesBySQLService(o.url, {
  194. eventListeners: {
  195. "processCompleted":function(data){
  196. gis.script.sqlProcessCompleted(data,o);
  197. },
  198. "processFailed": gis.script.sqlProcessFailed
  199. }
  200. });
  201. featuresBySQLService.processAsync(featuresBySQLParams);
  202. }
  203. /*
  204. * processCompleted回调函数,读取空间数据信息,在相关图层绘制相应图层信息
  205. */
  206. gis.script.sqlProcessCompleted=function(e,o){
  207. var result=e.result;
  208. gis.script.consolelog('result::',result);
  209. gis.script.consolelog('o::',o);
  210. var features=result.features;
  211. //console.log("features",features);
  212. if(features&&features.length){
  213. gis.script.gisLayerinfo[o.gisLayerinfoKey]={};
  214. for(var k=0;k<features.length;k++){
  215. var feature = features[k];
  216. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  217. //alert(JSON.stringify(feature.attributes));
  218. var idata={};
  219. idata.smid=feature.attributes.SMID||feature.attributes.smid;
  220. idata.lon=centerLonLat.lon;
  221. idata.lat=centerLonLat.lat;
  222. idata.zoom=o.zoom;
  223. if(feature.attributes){
  224. //feature.attributes.gisidToKey=o.gisLayerinfoKey+"_"+idata.smid;
  225. //feature.attributes.gisLayerinfoKey=o.gisLayerinfoKey;
  226. feature.attributes.onSelectOpenPopkey=o.onSelectOpenPopkey;
  227. feature.attributes.gisLayerinfoAttr=feature.attributes[o.gisLayerinfoAttrKey];
  228. feature.attributes.infokey=o.gisLayerinfoKey+"_"+feature.attributes.gisLayerinfoAttr;
  229. feature.attributes.gisEditLayerinfoKey=o.gisLayerinfoKey;
  230. feature.attributes.featureidval=feature.fid;
  231. feature.attributes.labelfieldid=o.labelfield;
  232. if(o.cachedata&&o.cachedata=='true'){
  233. gis.script.gisLayerinfo[o.gisLayerinfoKey][feature.attributes.gisLayerinfoAttr]=idata;
  234. }
  235. if(o.processCompleted&&gis.script[o.processCompleted]){
  236. gis.script[o.processCompleted](feature,o);
  237. }
  238. /*
  239. if(o.processCompleted){
  240. o.processCompleted(feature);
  241. }
  242. */
  243. }
  244. //alert(feature.attributes[o.gisLayerinfoAttrKey]);
  245. //gis.script.gisLayerinfo[o.gisLayerinfoKey][feature.attributes.SMID]=idata;
  246. //break;
  247. }
  248. //debugger;
  249. gis.script.consolelog('::gis.script.gisLayerinfo::',gis.script.gisLayerinfo);
  250. }
  251. }
  252. /*
  253. * 根据参数绘制Marker,包括港口、取水口...
  254. */
  255. gis.script.publiconSelectMark=function(feature,o){
  256. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  257. var typename="";
  258. if(o.modelObj&&!gis.script.isBlank(o.modelObj.srcattr)){
  259. typename=feature.attributes[o.modelObj.srcattr];
  260. }
  261. if(gis.script.isBlank(o.modelObj.srcattr)){
  262. typename=o.modelObj.srcname;
  263. }
  264. var item={type:o.modelObj.marktypename+typename,functionName:o.onSelectOpenPopkey,
  265. lon:centerLonLat.lon,lat:centerLonLat.lat,w:o.modelObj.width||32,h:o.modelObj.height||32};
  266. item.feature=feature;
  267. item.marktypename=o.modelObj.marktypename;
  268. //item.src='../images/markerbig_select.png';
  269. item.src=o.modelObj.src;
  270. item.defshow=o.modelObj.defshow;
  271. item.showMinzoom=o.modelObj.showMinzoom;
  272. item.showMaxzoom=o.modelObj.showMaxzoom;
  273. if(!gis.script.isBlank(typename)){
  274. item.src=imgPath+'/'+typename+'.png';
  275. }
  276. //alert(item.src)
  277. gis.script.addMarker(item);
  278. }
  279. gis.script.gkonSelectMark=function(feature,o){
  280. //alert(o.onSelectOpenPopkey);
  281. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  282. var srcpng=feature.attributes['类别'];
  283. var item={type:'gk'+srcpng,functionName:o.onSelectOpenPopkey,lon:centerLonLat.lon,lat:centerLonLat.lat,w:32,h:32};
  284. item.feature=feature;
  285. item.src='../images/markerbig_select.png';
  286. if(srcpng){
  287. item.src=imgPath+'/'+srcpng+'.png';
  288. }
  289. item.name=feature.attributes.name;
  290. gis.script.addMarker(item);
  291. }
  292. /*
  293. * 绘画港区feature
  294. */
  295. gis.script.gqonSelect=function(feature,o){
  296. /*
  297. feature.style = {
  298. strokeColor: "#304DBE",
  299. strokeWidth: 2,
  300. pointerEvents: "visiblePainted",
  301. fillColor: "#304DBE",
  302. fillOpacity: 0.5
  303. };
  304. */
  305. //gis.script.consolelog('pointFeature:',feature);
  306. gqvectorLayer.addFeatures(feature);
  307. }
  308. /*
  309. * 绘画作业区feature
  310. */
  311. gis.script.zyqonSelect=function(feature,o){
  312. zyqvectorLayer.addFeatures(feature);
  313. }
  314. /*
  315. * 绘画经营人feature,并且添加经营人名称
  316. */
  317. gis.script.jyronSelect=function(feature,o){
  318. /*
  319. var sid=feature.attributes.smid;
  320. if(sid==51){
  321. // 浅层复制(只复制顶层的非 object 元素)
  322. //var newObject = jQuery.extend({}, oldObject);
  323. // 深层复制(一层一层往下复制直到最底层)
  324. //var featureDv = $.extend(true, {}, feature);
  325. var feature2=feature.clone()
  326. feature2.style = {
  327. strokeColor: "#304DBE",
  328. strokeWidth: 2,
  329. pointerEvents: "visiblePainted",
  330. fillColor: "#ff0000",
  331. fillOpacity: 0.5
  332. };
  333. locationLayer.addFeatures(feature);
  334. //alert(feature.style);alert(featureDv.style);
  335. }
  336. */
  337. //gis.script.consolelog('pointFeature:',feature);
  338. //console.log('pointFeature:',feature);
  339. jyrvectorLayer.addFeatures(feature);
  340. try{
  341. if(feature.attributes&&o.labelfield){
  342. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  343. var geoText = new SuperMap.Geometry.GeoText(centerLonLat.lon, centerLonLat.lat,gis.script.labelfontformat(feature.attributes[o.labelfield],5));
  344. var geotextFeature = new SuperMap.Feature.Vector(geoText);
  345. jyrlabelLayer.addFeatures([geotextFeature]);
  346. }
  347. }catch(e){
  348. }
  349. }
  350. /*
  351. * 格式化绘制名称
  352. */
  353. gis.script.labelfontformat=function(textval,count){
  354. if(gis.script.isNotBlank(textval)){
  355. if(count&&gis.script.isNum(count)){
  356. //console.log("textval",textval);
  357. var textarray=textval.split("");
  358. var newtextarray=[];
  359. if(textarray.length>count){
  360. for(var i=0;i<textarray.length;i++){
  361. newtextarray.push(textarray[i]);
  362. if((i+1)%count==0){
  363. newtextarray.push("\n");
  364. }
  365. }
  366. return newtextarray.join("");
  367. }
  368. //console.log("textarray",textarray);
  369. }
  370. return textval;
  371. }
  372. return "";
  373. }
  374. /*
  375. * 绘画码头feature
  376. */
  377. gis.script.mtonSelect=function(feature,o){
  378. mtvectorLayer.addFeatures(feature);
  379. }
  380. /*
  381. * 绘画泊位feature
  382. */
  383. gis.script.bwonSelect=function(feature,o){
  384. bwvectorLayer.addFeatures(feature);
  385. }
  386. gis.script.sqlProcessFailed=function(e){
  387. alert(e.error.errorMsg);
  388. }
  389. gis.script.loadLayerQueryBySqls = function(list){
  390. if(list&&list.length){
  391. var queryParams=[];
  392. for(var i=0;i<list.length;i++){
  393. var fileterParam = new SuperMap.REST.FilterParameter(list[i]);
  394. queryParams.push(fileterParam);
  395. }
  396. var queryBySQLParams=new SuperMap.REST.QueryBySQLParameters({
  397. queryParams:queryParams
  398. });
  399. var queryBySQLService = new SuperMap.REST.QueryBySQLService(gis.script.url, {eventListeners: {
  400. "processCompleted": function(e){
  401. var result=e.result;
  402. //gis.script.consolelog('result:',result);
  403. if(result&&result.totalCount>0&&result.recordsets.length==list.length){
  404. for(var i=0;i<result.recordsets.length;i++){
  405. var recordset=result.recordsets[i];
  406. var o=list[i];
  407. gis.script.gisLayerinfo[o.gisLayerinfoKey]={};
  408. for(var k=0;k<recordset.features.length;k++){
  409. var feature = recordset.features[k];
  410. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  411. //gisidTo
  412. if(feature.attributes){
  413. //feature.attributes.gisidToKey=o.gisLayerinfoKey+"_"+feature.attributes.smid;
  414. //feature.attributes.gisLayerinfoKey=o.gisLayerinfoKey;
  415. feature.attributes.onSelectOpenPopkey=o.onSelectOpenPopkey;
  416. }
  417. var temp={};
  418. temp=feature.attributes;
  419. temp.lon=centerLonLat.lon;
  420. temp.lat=centerLonLat.lat;
  421. gis.script.gisLayerinfo[o.gisLayerinfoKey][feature.attributes.smid]=temp;
  422. //alert(JSON.stringify(gis.script.gisLayerinfo[o.gisLayerinfoKey]));
  423. if(gis.script.gis_gk_key==o.gisLayerinfoKey){
  424. gis.script.gkonSelect(feature);
  425. }
  426. //break;
  427. }
  428. }
  429. }
  430. },
  431. "processFailed": function(e){
  432. alert(e.error.errorMsg);
  433. }
  434. }
  435. });
  436. queryBySQLService.processAsync(queryBySQLParams);
  437. }
  438. }
  439. gis.script.loadLayerSql = function(o,fun){
  440. var fileterParam = new SuperMap.REST.FilterParameter(o);
  441. var queryBySQLParams=new SuperMap.REST.QueryBySQLParameters({
  442. queryParams:[fileterParam]
  443. });
  444. var queryBySQLService = new SuperMap.REST.QueryBySQLService(gis.script.url, {eventListeners: {
  445. "processCompleted": function(e){
  446. var result=e.result;
  447. if(result&&result.totalCount>0){
  448. var recordset=result.recordsets[0];
  449. gis.script.gisLayerinfo[o.gisLayerinfoKey]={};
  450. for(var k=0;k<recordset.features.length;k++){
  451. var feature = recordset.features[k];
  452. var centerLonLat = feature.geometry.getBounds().getCenterLonLat();
  453. //alert(JSON.stringify(feature.attributes));
  454. //alert(feature.geometry.getBounds().getCenterLonLat())
  455. if(feature.attributes.name==""){
  456. continue;
  457. }
  458. var temp={};
  459. temp=feature.attributes;
  460. temp.lon=centerLonLat.lon;
  461. temp.lat=centerLonLat.lat;
  462. gis.script.gisLayerinfo[o.gisLayerinfoKey][feature.attributes.smid]=temp;
  463. //alert(JSON.stringify(gis.script.gisLayerinfo[o.gisLayerinfoKey]));
  464. if(fun){
  465. fun(feature);
  466. }
  467. //break;
  468. }
  469. }
  470. },
  471. "processFailed": function(e){
  472. alert(e.error.errorMsg);
  473. }
  474. }
  475. });
  476. queryBySQLService.processAsync(queryBySQLParams);
  477. }
  478. gis.script.gkonSelect = function(feature){
  479. /*
  480. var centerLonLat=feature.geometry.getBounds().getCenterLonLat();
  481. var item={type:"1",functionName:"showMarkerInfo",lon:centerLonLat.lon,lat:centerLonLat.lat,w:21,h:25};
  482. item.src='../images/markerbig_select.png';
  483. item.name=feature.attributes.name;
  484. gis.script.addMarker(item);
  485. */
  486. feature.style={
  487. fillColor:"white",
  488. strokeColor:"white",
  489. pointRadius:13,
  490. strokeWidth:0,
  491. fillOpacity: 0
  492. };
  493. //gis.script.consolelog('pointFeature:',feature);
  494. gkvectorLayer.addFeatures(feature);
  495. }
  496. gis.script.openPop_GK_id=function(feature,e){
  497. if(gis.script.gisidTo){
  498. //alert(gis.script.gis_gk_key+"_"+feature.attributes.SMID);
  499. if(feature.attributes&&feature.attributes.infokey){
  500. //var sinfo=gis.script.gisidTo[gis.script.gis_gk_key+"_"+feature.attributes.gisLayerinfoAttr];
  501. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  502. if(sinfo&&sinfo.ID){
  503. //alert(sinfo.ID);
  504. gis.script.jsonAjax({url:contextPath+"/zygl/queryGK.html",async:true,data:{id:sinfo.ID}},
  505. function(data){
  506. //alert(JSON.stringify(data));
  507. if(data&&data.message){
  508. //alert(data.message);
  509. //alert(gis.script.popSize[feature.attributes.gisLayerinfoKey]);
  510. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:269},data.message,e);
  511. //alert(feature.attributes.labelfieldid);
  512. gis.anchored.addPopup(map,popup,feature);
  513. //gis.anchored.addFramedCloud(feature.geometry.getBounds().getCenterLonLat(),{},data.message);
  514. }
  515. });
  516. }else{
  517. //gis.script.openPopNull(feature);
  518. }
  519. }
  520. }
  521. }
  522. /*
  523. * 港口点击事件
  524. */
  525. gis.script.openPop_GK=function(feature,e){
  526. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  527. //alert(feature.attributes.gisLayerinfoAttr);
  528. gis.script.jsonAjax({url:contextPath+"/zygl/queryGKCode.html",async:true,data:{gkdm:feature.attributes.gisLayerinfoAttr}},
  529. function(data){
  530. if(data&&data.success&&data.message){
  531. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:233},data.message,e);
  532. gis.anchored.addPopup(map,popup,feature);
  533. }
  534. });
  535. }
  536. }
  537. gis.script.openPop_GQ_id=function(feature,e){
  538. if(feature.attributes&&feature.attributes.infokey){
  539. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  540. if(sinfo&&sinfo.ID){
  541. gis.script.jsonAjax({url:contextPath+"/zygl/queryGQ.html",async:true,data:{id:sinfo.ID}},
  542. function(data){
  543. //alert(sinfo.ID);
  544. //alert(JSON.stringify(data));
  545. if(data&&data.message){
  546. //alert(data.message);
  547. //alert(gis.script.popSize[feature.attributes.gisLayerinfoKey]);
  548. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:297},data.message,e);
  549. gis.anchored.addPopup(map,popup,feature);
  550. }
  551. });
  552. }
  553. }
  554. //gis.script.openPop_GQ_fbgp(feature);
  555. }
  556. /*
  557. * 港区点击事件
  558. */
  559. gis.script.openPop_GQ=function(feature,e){
  560. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  561. //alert(feature.attributes.gisLayerinfoAttr);
  562. gis.script.jsonAjax({url:contextPath+"/zygl/queryGQCode.html",async:true,data:{gqdm:feature.attributes.gisLayerinfoAttr}},
  563. function(data){
  564. if(data&&data.success&&data.message){
  565. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:233},data.message,e);
  566. gis.anchored.addPopup(map,popup,feature);
  567. }
  568. });
  569. }
  570. }
  571. gis.script.openPop_GQ_fbgp=function(feature){
  572. //alert(feature.geometry.intersects(feature.geometry));
  573. /*
  574. var centerLonLat=feature.geometry.getBounds().getCenterLonLat();
  575. var point= new SuperMap.Geometry.Point(centerLonLat.lon+100,centerLonLat.lat);
  576. alert(feature.geometry.intersects(point));
  577. */
  578. var datasetNames = [];
  579. datasetNames.push(jyrDasetName);
  580. var getFeaturesByGeometryParameters = new SuperMap.REST.GetFeaturesByGeometryParameters({
  581. // datasetNames: ["gkzyYS:L_GKJYR_PY"],
  582. datasetNames:datasetNames,
  583. toIndex:-1,
  584. spatialQueryMode:SuperMap.REST.SpatialQueryMode.INTERSECT,
  585. geometry:feature.geometry
  586. });
  587. var getFeaturesByGeometryService = new SuperMap.REST.GetFeaturesByGeometryService("http://192.168.39.120:8090/iserver/services/data-ST/rest/data", {
  588. eventListeners: {
  589. "processCompleted": function(e){
  590. gis.script.consolelog('ee:',e);
  591. },
  592. "processFailed": function(e){
  593. }
  594. }
  595. });
  596. getFeaturesByGeometryService.processAsync(getFeaturesByGeometryParameters);
  597. }
  598. gis.script.openPop_JYR_id=function(feature,e){
  599. if(feature.attributes&&feature.attributes.infokey){
  600. //gis.script.consolelog('gis.script.gisidTo:',gis.script.gisidTo);
  601. //alert(feature.attributes.smid);
  602. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  603. if(sinfo&&sinfo.ID){
  604. //alert(sinfo.ID);return;
  605. gis.script.jsonAjax({url:contextPath+"/zygl/queryJYR.html",async:true,data:{id:sinfo.ID}},
  606. function(data){
  607. if(data&&data.message){
  608. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:214},data.message,e);
  609. gis.anchored.addPopup(map,popup,feature);
  610. }
  611. });
  612. }
  613. }
  614. }
  615. /*
  616. * 经营人点击事件
  617. */
  618. gis.script.openPop_JYR=function(feature,e){
  619. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  620. //alert(feature.attributes.gisLayerinfoAttr);
  621. gis.script.jsonAjax({url:contextPath+"/zygl/queryJYRCode.html",async:true,data:{zyid:feature.attributes.gisLayerinfoAttr}},
  622. function(data){
  623. if(data&&data.success&&data.message){
  624. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:187},data.message,e);
  625. gis.anchored.addPopup(map,popup,feature);
  626. }
  627. });
  628. }
  629. }
  630. gis.script.openPop_MT_id=function(feature,e){
  631. //console.log("gis.script.gisidTo",gis.script.gisidTo)
  632. //alert(feature.attributes.infokey);return;
  633. if(feature.attributes&&feature.attributes.infokey){
  634. //gis.script.consolelog('gis.script.gisidTo:',gis.script.gisidTo);
  635. //alert(feature.attributes.smid);
  636. //alert(feature.attributes.infokey);
  637. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  638. if(sinfo&&sinfo.ID){
  639. //alert(sinfo.ID);return;
  640. gis.script.jsonAjax({url:contextPath+"/zygl/queryMT.html",async:true,data:{id:sinfo.ID}},
  641. function(data){
  642. if(data&&data.message){
  643. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:242},data.message,e);
  644. gis.anchored.addPopup(map,popup,feature);
  645. }
  646. });
  647. }
  648. }
  649. }
  650. /*
  651. * 码头点击事件
  652. */
  653. gis.script.openPop_MT=function(feature,e){
  654. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  655. //alert(feature.attributes.gisLayerinfoAttr);
  656. gis.script.jsonAjax({url:contextPath+"/zygl/queryMTCode.html",async:true,data:{zyid:feature.attributes.gisLayerinfoAttr}},
  657. function(data){
  658. if(data&&data.success&&data.message){
  659. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:320,height:210},data.message,e);
  660. gis.anchored.addPopup(map,popup,feature);
  661. }
  662. });
  663. }
  664. }
  665. gis.script.openPop_BW_id=function(feature,e){
  666. //return;
  667. if(feature.attributes&&feature.attributes.infokey){
  668. //gis.script.consolelog('gis.script.gisidTo:',gis.script.gisidTo);
  669. //alert(feature.attributes.smid);
  670. //alert(feature.attributes.infokey);
  671. var sinfo=gis.script.gisidTo[feature.attributes.infokey];
  672. if(sinfo&&sinfo.ID){
  673. //alert(sinfo.ID);return;
  674. gis.script.jsonAjax({url:contextPath+"/zygl/queryBW.html",async:true,data:{id:sinfo.ID}},
  675. function(data){
  676. if(data&&data.message){
  677. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:460,height:289},data.message,e);
  678. gis.anchored.addPopup(map,popup,feature);
  679. }
  680. });
  681. }
  682. }
  683. }
  684. /*
  685. * 泊位点击事件
  686. */
  687. gis.script.openPop_BW=function(feature,e){
  688. if(feature.attributes&&gis.script.isNotBlank(feature.attributes.gisLayerinfoAttr)){
  689. //alert(feature.attributes.gisLayerinfoAttr);
  690. gis.script.jsonAjax({url:contextPath+"/zygl/queryBWCode.html",async:true,data:{zyid:feature.attributes.gisLayerinfoAttr}},
  691. function(data){
  692. if(data&&data.success&&data.message){
  693. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:460,height:289},data.message,e);
  694. gis.anchored.addPopup(map,popup,feature);
  695. }
  696. });
  697. }
  698. }
  699. gis.script.openPop_ZYQ=function(feature,e){
  700. //console.log('feature>>',feature);
  701. //alert(feature.attributes.gisLayerinfoAttr);
  702. if(feature.attributes&&feature.attributes.gisLayerinfoAttr){
  703. gis.script.jsonAjax({url:contextPath+"/zygl/queryZYQbyZYID.html",async:true,data:{id:feature.attributes.gisLayerinfoAttr}},
  704. function(data){
  705. if(data&&data.success&&data.message){
  706. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:460,height:210},data.message,e);
  707. gis.anchored.addPopup(map,popup,feature);
  708. }
  709. });
  710. }
  711. }
  712. gis.script.openPopNull=function(feature){
  713. //var popup = gis.anchored.popup(feature.geometry.getBounds().getCenterLonLat(),{});
  714. var popup = gis.anchored.popupHtml(feature.geometry.getBounds().getCenterLonLat(),{width:220,height:60},"<div class='titleClass'>信息</div><div class='openPopNull'>无关联数据<div>");
  715. gis.anchored.addPopup(map,popup);
  716. }
  717. gis.script.initLoadGisidTo = function(){
  718. gis.script.jsonAjax({url:contextPath+"/zygl/gisidTo.html",contentType:'application/json;charset=utf-8',async:false,data:JSON.stringify({})},
  719. function(data){
  720. //alert(JSON.stringify(data));
  721. gis.script.gisidTo=data;
  722. });
  723. }
  724. /*
  725. * 封装的ajax调用
  726. */
  727. gis.script.jsonAjax= function(obj,exeJson){
  728. var ajaxInfo={
  729. type : 'post',
  730. dataType : 'json',
  731. //contentType : 'application/json;charset=utf-8',
  732. //timeout : 10000, //超时时间设置,单位毫秒
  733. cache : false,// 不从缓存中去数据
  734. async : true,
  735. //url : obj.url,
  736. //data : JSON.stringify(jsondate),
  737. //headers:headinfo,
  738. success : function(data) {
  739. if(exeJson){
  740. exeJson(data);
  741. }
  742. },
  743. error : function(jqXHR, textStatus, errorThrown) {
  744. //alert(jqXHR.responseText);
  745. }
  746. };
  747. ajaxInfo.url=obj.url;
  748. ajaxInfo.data=obj.data||{};
  749. if(typeof(obj.async)!="undefined"){
  750. ajaxInfo.async=obj.async
  751. }
  752. if(typeof(obj.contentType)!="undefined"){
  753. //alert(obj.contentType);
  754. ajaxInfo.contentType=obj.contentType;
  755. }
  756. //alert(ajaxInfo);
  757. $.ajax(ajaxInfo);
  758. }
  759. gis.script.isNum=function(value){
  760. if(typeof(value)!='undefined'){
  761. var result = true;
  762. var pattern = /^\d*(\.\d*)?$/;
  763. if (!pattern.test(value)) result = false;
  764. var num = parseFloat(value);
  765. if (isNaN(num)) result = false;
  766. return result;
  767. }
  768. return false;
  769. }
  770. gis.script.isBlank=function(value){
  771. if(value){
  772. value=value+"";
  773. for(var i=0; i<value.length; i++) {
  774. var c = value.charAt(i);
  775. if ((c!=' ')&&(c!='\n')&&(c!='\t')) return false;
  776. }
  777. }
  778. return true;
  779. }
  780. gis.script.isNotBlank=function(value){
  781. if(typeof(value)!='undefined'){
  782. value=value+"";
  783. for(var i=0; i<value.length; i++) {
  784. var c = value.charAt(i);
  785. if ((c!=' ')&&(c!='\n')&&(c!='\t')) return true;
  786. }
  787. }
  788. return false;
  789. }
  790. gis.script.consolelog=function(t,o){
  791. //console.log(t,o);
  792. }
  793. gis.script.loadzyqsjServices = function(servicename,obj) {
  794. var dataServices=gisConfigBean.dataconfig;
  795. if(dataServices&&obj&&gis.script.isNum(obj.zyid)){
  796. //gis.script.consolelog('dataServices',dataServices);
  797. var originaldata = gisConfigBean.dataconfig[servicename];
  798. var data=jQuery.extend(true, {}, originaldata);
  799. if(data.Model&&data.Model[gis.script.modelid]){
  800. var model=data.Model[gis.script.modelid];
  801. data.datasetNames=data.datasetNames.split(",");
  802. data.fields=data.fields.split(",");
  803. data.cachedata=model.cachedata||data.cachedata;
  804. data.zoom=model.zoom||data.zoom;
  805. data.treelocationHighlight=model.treelocationHighlight||"false";
  806. data.url=data.url||defdataUrl;
  807. data.attributeFilter="ID="+obj.zyid
  808. //console.log("data",data);
  809. gis.script.loadServicetreelocation(data,obj);
  810. }
  811. }
  812. }
  813. gis.script.loadServicexmlzyqsjlocation = function(o,datao) {
  814. var featureParam = new SuperMap.REST.FilterParameter({
  815. //name: o.name,
  816. fields:o.fields,
  817. attributeFilter:o.attributeFilter
  818. });
  819. var featuresBySQLParams=new SuperMap.REST.GetFeaturesBySQLParameters({
  820. //toIndex:65536,
  821. toIndex:-1,
  822. queryParameter:featureParam,
  823. datasetNames:o.datasetNames
  824. });
  825. var featuresBySQLService = new SuperMap.REST.GetFeaturesBySQLService(o.url, {
  826. eventListeners: {
  827. "processCompleted":function(e){
  828. var result=e.result;
  829. //console.log('..>>',result);
  830. var features=result.features;
  831. if(features&&features.length){
  832. }
  833. },
  834. "processFailed": gis.script.sqlProcessFailed
  835. }
  836. });
  837. featuresBySQLService.processAsync(featuresBySQLParams);
  838. }
  839. $(document).ready(function() {
  840. //预先加载
  841. //gis.script.initLoadGisidTo();
  842. //$.growlUI('提示', '删除成功!');
  843. });