GisShareApp3D.html 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  6. <title>上海城地API</title>
  7. <style>
  8. html,
  9. body,
  10. #mapDiv {
  11. padding: 0;
  12. margin: 0;
  13. height: 100%;
  14. width: 100%;
  15. }
  16. /*自定义窗口样式*/
  17. .leaflet-popup-content-wrapper{
  18. background-color: rgba(0,0,0,0.8) !important;
  19. color:white !important;
  20. }
  21. .leaflet-popup-tip{
  22. background-color: rgba(0,0,0,0.8) !important;
  23. }
  24. .esri-view-surface--inset-outline:focus::after {
  25. outline: none !important;
  26. }
  27. </style>
  28. <script src="js/echarts.min.js"></script>
  29. <script src="jquery/jquery-2.2.3.min.js"></script>
  30. <script type="text/javascript" src="jquery/xml2json.js"></script>
  31. <script>
  32. var dojoConfig = {
  33. async: true,
  34. parseOnLoad: true,
  35. packages: [{
  36. name: "lib",
  37. location: location.pathname.replace(/\/[^/]+$/, "") + "/lib"
  38. }]
  39. };
  40. </script>
  41. <script src="Common/mapClass/corrugatedPoint/gl-matrix.js"></script>
  42. <!--<script src="http://172.16.28.83/arcgis_api/library/4.17/init.js"></script>-->
  43. <!--<link rel="stylesheet" href="http://172.16.28.83/arcgis_js_api/library/4.17/esri/themes/light/main.css">-->
  44. <script src="https://10.101.35.50/arcgis_js_api/library/4.17/init.js"></script>
  45. <link rel="stylesheet" href="https://10.101.35.50/arcgis_js_api/library/4.17/esri/themes/light/main.css">
  46. <link rel="stylesheet" href="css/echartsLayerCss.css">
  47. <!--系统自定义JS-->
  48. <script src="Common/dataClass/XMLUtil.js"></script> <!--XML操作功能-->
  49. <script src="Common/dataClass/ConfigManagertest.js"></script>
  50. <script src="Common/dataClass/DataCommonClass.js"></script>
  51. <script src="Common/dataClass/MD5.js"></script>
  52. <script src="Common/dataClass/Base64.js"></script>
  53. <script src="Common/mapClass/MapClass4.js"></script>
  54. <script src="Common/WsCommonClass.js"></script>
  55. <script src="Common/mapClass/GSFunction.js"></script>
  56. <script src="Common/mapClass/corrugatedPoint/corrugatedPoint.js"></script>
  57. <script>
  58. //监听message
  59. window.onmessage = function(e) {
  60. //alert(e.origin);
  61. //if (e.origin !== 'http://10.101.35.46/WJGisShare/')
  62. //return;
  63. var payload;
  64. try{
  65. payload= JSON.parse(e.data);
  66. }
  67. catch(e){
  68. return;
  69. }
  70. switch (payload.method) {
  71. case 'ZoomIn':
  72. //localStorage.setItem(payload.key, JSON.stringify(payload.data));
  73. ZoomIn(payload.data);
  74. break;
  75. case 'ZoomOut':
  76. ZoomOut(payload.data);
  77. break;
  78. case 'Clear':
  79. Clear(payload.data);
  80. break;
  81. case 'ViewChange':
  82. ViewChange();
  83. break;
  84. case 'fullExtent':
  85. toFullExtent();
  86. break;
  87. case 'doSetExtent':
  88. doSetExtent(parseInt(payload.data));
  89. break;
  90. case 'measureSquare':
  91. measureSquare();
  92. break;
  93. case 'measureLength':
  94. measureLength();
  95. break;
  96. case 'downLoadPicture':
  97. downLoadPicture();
  98. break;
  99. case 'doGetGraphicByJson':
  100. doGetGraphicByJson(payload.data[0],payload.data[1]);
  101. break;
  102. case 'drawSquare':
  103. drawSquare();
  104. break;
  105. case 'query':
  106. query(payload.data[0],payload.data[1]);
  107. break;
  108. case 'queryByWhereStr':
  109. querybyWhereStr(payload.data[0],payload.data[1]);
  110. break;
  111. case 'openFeatureLayer':
  112. OpenFeatureLayerByID(payload.data[0],payload.data[1]);
  113. break;
  114. case 'openFeatureLayerByName':
  115. // var isVisible=true;
  116. // if(parseInt(payload.data[1])==0)
  117. // {
  118. // isVisible=false;
  119. // }
  120. OpenMapImageLayerByName(payload.data[0],payload.data[1],payload.data[2]);
  121. break;
  122. case "CloseChangeLayer":{
  123. closeMapImageLayerByName();
  124. break;
  125. }
  126. case "doClusterByJson":{
  127. clusterByJson(payload.data[0]);
  128. break;
  129. }
  130. case 'openFeatureLayer0':
  131. var isVisible=true;
  132. if(parseInt(payload.data[0])==0)
  133. {
  134. isVisible=false;
  135. }
  136. OpenFeatureLayerByID1(0,isVisible);
  137. break;
  138. case 'openFeatureLayer1':
  139. var isVisible=true;
  140. if(parseInt(payload.data[0])==0)
  141. {
  142. isVisible=false;
  143. }
  144. OpenFeatureLayerByID1(1,isVisible);
  145. break;
  146. case 'openFeatureLayer2':
  147. var isVisible=true;
  148. if(parseInt(payload.data[0])==0)
  149. {
  150. isVisible=false;
  151. }
  152. OpenFeatureLayerByID1(2,isVisible);
  153. break;
  154. case 'openFeatureLayer3':
  155. var isVisible=true;
  156. if(parseInt(payload.data[0])==0)
  157. {
  158. isVisible=false;
  159. }
  160. OpenFeatureLayerByID1(3,isVisible);
  161. break;
  162. case 'openFeatureLayer4':
  163. var isVisible=true;
  164. if(parseInt(payload.data[0])==0)
  165. {
  166. isVisible=false;
  167. }
  168. OpenFeatureLayerByID1(4,isVisible);
  169. break;
  170. case 'openFeatureLayer5':
  171. var isVisible=true;
  172. if(parseInt(payload.data[0])==0)
  173. {
  174. isVisible=false;
  175. }
  176. OpenFeatureLayerByID1(5,isVisible);
  177. break;
  178. case 'openFeatureLayer6':
  179. var isVisible=true;
  180. if(parseInt(payload.data[0])==0)
  181. {
  182. isVisible=false;
  183. }
  184. OpenFeatureLayerByID1(6,isVisible);
  185. break;
  186. case 'openFeatureLayer7':
  187. var isVisible=true;
  188. if(parseInt(payload.data[0])==0)
  189. {
  190. isVisible=false;
  191. }
  192. OpenFeatureLayerByID1(7,isVisible);
  193. break;
  194. case 'openFeatureLayer8':
  195. var isVisible=true;
  196. if(parseInt(payload.data[0])==0)
  197. {
  198. isVisible=false;
  199. }
  200. OpenFeatureLayerByID1(8,isVisible);
  201. break;
  202. case 'openFeatureLayer9':
  203. var isVisible=true;
  204. if(parseInt(payload.data[0])==0)
  205. {
  206. isVisible=false;
  207. }
  208. OpenFeatureLayerByID1(9,isVisible);
  209. break;
  210. case 'openFeatureLayer10':
  211. var isVisible=true;
  212. if(parseInt(payload.data[0])==0)
  213. {
  214. isVisible=false;
  215. }
  216. OpenFeatureLayerByID1(10,isVisible);
  217. break;
  218. case 'setCenterExtent':
  219. setCenterExtent(payload.data[0],payload.data[1],payload.data[2]);
  220. break;
  221. case 'drawCircle':{
  222. drawCircle(payload.data[0]);
  223. break;
  224. }
  225. case 'queryByCircle':{
  226. queryByCircle(payload.data[0] ,payload.data[1] ,payload.data[2] ,payload.data[3] )
  227. break;
  228. }
  229. case 'doFlashStatus':{
  230. var flahLayerName=payload.data[0];
  231. switch(flahLayerName)
  232. {
  233. case "违章建筑":
  234. flashLayerStatus(fe0,"状态",1);
  235. break;
  236. case "电梯":
  237. flashLayerStatus(fe4,"状态",1);
  238. break;
  239. case "虹口烟感":
  240. flashLayerStatus(fe1,"状态",1);
  241. break;
  242. case "摄像头":
  243. flashLayerStatus(fe2,"状态",1);
  244. break;
  245. case "危险源":
  246. flashLayerStatus(fe3,"状态",1);
  247. break;
  248. case "门磁":
  249. flashLayerStatus(fe5,"状态",1);
  250. break;
  251. default:
  252. ClearLightLayerStatus();
  253. break;
  254. }
  255. break;
  256. }
  257. case "onLocation":{
  258. setPointBylonlat(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.data[4],payload.data[5] ,payload.data[6]);
  259. break;
  260. }
  261. case "MeasureLengthByPoint":{
  262. //parent.eval(payload.backfun+"()");
  263. MeasureLengthByPoint(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.backfun);
  264. break;
  265. }
  266. case "newQuery":{
  267. newQuerybyWhereStr(payload.data[0],payload.data[1],GetConfigDataByName("MYQueryLayer"),null,null,payload.data[2]);
  268. break;
  269. }
  270. case "onLocationforGrid" :{
  271. setPointBylonlatForGrid(payload.data[0],payload.data[1]);
  272. break;
  273. }
  274. case "onLocationforAddress":{
  275. setPointBylonlatForAddress(payload.data[0],payload.data[1]);
  276. break;
  277. }
  278. case "onQueryByPoint":{
  279. setPointBylonlatForGetBuffer(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.data[4],payload.data[5]);
  280. break;
  281. }
  282. case "onQueryByGrid":{
  283. getGridGeometry(payload.data[0],payload.data[1]);
  284. break;
  285. }
  286. case "onMapCenter":{
  287. var mapcenter = m_view.center ;
  288. window.parent.postMessage(
  289. {
  290. method: "mapCenterCallback",
  291. data:[JSON.stringify(mapcenter).replace(/\"/g,'"')]
  292. },
  293. '*'
  294. );
  295. break;
  296. }
  297. case "onMapLevel":{
  298. var mapzoom = m_view.zoom;
  299. window.parent.postMessage(
  300. {
  301. method: "mapLevelCallback",
  302. data:[JSON.stringify(mapzoom).replace(/\"/g,'"')]
  303. },
  304. '*'
  305. );
  306. break;
  307. }
  308. case "onMapSetCenter":{
  309. goToZoom(payload.data[0],payload.data[1]);
  310. // setPointBylonlatForSetCenter(payload.data[0],payload.data[1]);
  311. break;
  312. }
  313. case "onGetXYbyAddress":{
  314. getXYbyAddress(payload.data[0]);
  315. break;
  316. }
  317. case "onSetInitExtentByStr":{
  318. // getXYbyAddress(payload.data[0]);
  319. if(payload.data[0] == "区县边界")
  320. queryForExtent(payload.data[0],"区县名称=" +"'"+ payload.data[1]+"'",100);
  321. else
  322. queryForExtent(payload.data[0], "街道名称=" +"'"+ payload.data[1]+"'",100);
  323. break;
  324. }
  325. case "onQueryByCondition":{
  326. newQuerybyWhereStr(payload.data[0],payload.data[1],GetConfigDataByName("MYQueryLayer"),null,payload.data[2],payload.data[3]);
  327. break;
  328. }
  329. case "openFeatureLayerByNameandWhere":{
  330. newOpenFeatureLayer(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.data[4]);
  331. break;
  332. }
  333. case "onClickLocation":{
  334. m_mapClickdraw = true;
  335. m_mapAttribute = payload.data[0];
  336. m_mapToolTip = payload.data[1];
  337. m_mapImgUrl = payload.data[2];
  338. m_mapImgWidth = payload.data[3];
  339. m_mapImgHeight = payload.data[4];
  340. break;
  341. }
  342. case "onSetResizeType":{
  343. sj_type = payload.data[0];
  344. sj_radius = payload.data[1];
  345. sj_layername = payload.data[2];
  346. break;
  347. }
  348. case "onSetLayerCluster":{
  349. setLayerCluster(payload.data[0],payload.data[1]);
  350. break;
  351. }
  352. case "onShowPolygonandText":{
  353. var jsonarr = payload.data[0];
  354. for(var i=0;i<jsonarr.length;i++){
  355. var jsonStr = jsonarr[i];
  356. // var test = jsonStr;
  357. ShowPolygonandText(jsonStr.type,jsonStr.name,jsonStr.text);
  358. }
  359. // ShowPolygonandText(payload.data[0],payload.data[1],payload.data[2]);
  360. break;
  361. }
  362. case "onLocationGetLatLon":{
  363. var action = m_drawtool.create("point");
  364. require(["esri/geometry/Point","esri/Graphic"],
  365. function(Point,Graphic) {
  366. action.on("draw-complete",
  367. function(evt) {
  368. m_view.graphics.removeAll();
  369. GraphicsLayer_flyTipLayer.removeAll();
  370. var point = new Point({
  371. x: evt.coordinates[0],
  372. y: evt.coordinates[1],
  373. spatialReference: m_view.spatialReference
  374. });
  375. var markerSymbol = {
  376. type: "simple-marker",
  377. color: payload.data[0],
  378. style: "circle",
  379. size: 10
  380. }
  381. var pointGraphic = new Graphic({
  382. geometry: point,
  383. symbol: markerSymbol
  384. });
  385. GraphicsLayer_flyTipLayer.add(pointGraphic);
  386. window.parent.postMessage(
  387. {
  388. method: "onLocationGetLatLonbackfun",
  389. data: [evt.coordinates]
  390. },
  391. '*'
  392. );
  393. });
  394. });
  395. break;
  396. }
  397. case "onDrawPolygonCircle":{
  398. require(["esri/geometry/Polygon","esri/Graphic","esri/geometry/Point","esri/geometry/Circle"],
  399. function(Polygon,Graphic,Point,Circle) {
  400. m_view.graphics.removeAll();
  401. GraphicsLayer_flyTipLayer.removeAll();
  402. var action = m_drawtool.create("circle");
  403. // 获取焦点
  404. m_view.focus();
  405. //顶点移除事件
  406. action.on("vertex-remove", createCircle);
  407. // 鼠标移动事件
  408. action.on("cursor-update", createCircle);
  409. // 绘制完成事件
  410. action.on("draw-complete", createCirclecomplete);
  411. function createCircle(event) {
  412. //获取所有顶点
  413. var vertices = event.vertices;
  414. //少于一个点无法展示圆
  415. if(vertices.length<2){
  416. return
  417. }
  418. //清除之前绘制
  419. GraphicsLayer_flyTipLayer.removeAll();
  420. //生成绘制的图形,两点画圆
  421. var center=new Point({
  422. hasZ: false,
  423. hasM: false,
  424. x:vertices[0][0],
  425. y:vertices[0][1],
  426. spatialReference: m_view.spatialReference
  427. });
  428. var dis=center.distance(new Point({
  429. hasZ: false,
  430. hasM: false,
  431. x:vertices[1][0],
  432. y:vertices[1][1],
  433. spatialReference: m_view.spatialReference
  434. }));
  435. var graphic = new Graphic({
  436. geometry: new Circle({
  437. hasZ: false,
  438. hasM: false,
  439. center:center,
  440. radius:dis,
  441. spatialReference: m_view.spatialReference
  442. }),
  443. symbol: {
  444. type: "simple-fill", // autocasts as new SimpleFillSymbol()
  445. color: [ 51,51, 204, 0.9 ],
  446. style: "solid",
  447. outline: { // autocasts as new SimpleLineSymbol()
  448. color: "white",
  449. width: 1
  450. }
  451. }
  452. });
  453. // 将绘制的图形添加到view
  454. GraphicsLayer_flyTipLayer.add(graphic);
  455. }
  456. function createCirclecomplete(event) {
  457. //获取所有顶点
  458. var vertices = event.vertices;
  459. //少于一个点无法展示圆
  460. if(vertices.length<2){
  461. return
  462. }
  463. //清除之前绘制
  464. GraphicsLayer_flyTipLayer.removeAll();
  465. //生成绘制的图形,两点画圆
  466. var center=new Point({
  467. hasZ: false,
  468. hasM: false,
  469. x:vertices[0][0],
  470. y:vertices[0][1],
  471. spatialReference: m_view.spatialReference
  472. });
  473. var dis=center.distance(new Point({
  474. hasZ: false,
  475. hasM: false,
  476. x:vertices[1][0],
  477. y:vertices[1][1],
  478. spatialReference: m_view.spatialReference
  479. }));
  480. var graphic = new Graphic({
  481. geometry: new Circle({
  482. hasZ: false,
  483. hasM: false,
  484. center:center,
  485. radius:dis,
  486. spatialReference: m_view.spatialReference
  487. }),
  488. symbol: {
  489. type: "simple-fill", // autocasts as new SimpleFillSymbol()
  490. color: [ 51,51, 204, 0.9 ],
  491. style: "solid",
  492. outline: { // autocasts as new SimpleLineSymbol()
  493. color: "white",
  494. width: 1
  495. }
  496. }
  497. });
  498. // 将绘制的图形添加到view
  499. GraphicsLayer_flyTipLayer.add(graphic);
  500. window.parent.postMessage(
  501. {
  502. method: "onDrawPolygoncallbackfun",
  503. data: [graphic.geometry.rings]
  504. },
  505. '*'
  506. );
  507. }
  508. });
  509. break;
  510. }
  511. case "onLightArea":{
  512. highLightArea(payload.data[0],payload.data[1],payload.data[2],payload.data[3]);
  513. break;
  514. }
  515. case "onEchartsRoute":{
  516. echartsRoute(payload.data[0],payload.data[1],payload.data[2],payload.data[3]);
  517. break;
  518. }
  519. case "onPopupIn":{
  520. if(popupInfos.length>0){
  521. popupShowAll();
  522. }
  523. else{
  524. popupInit(payload.data[0],payload.data[1]);
  525. }
  526. break;
  527. }
  528. case "onPopupClose":{
  529. popupCloseAll();
  530. popupInfos=[];
  531. break;
  532. }
  533. case "doClusterByJson":{
  534. clusterByJson(payload.data[0]);
  535. break;
  536. }
  537. case "doCloseClusterByJson":{
  538. closeClusterByJson();
  539. break
  540. }
  541. case 'doDeletePointById':
  542. doDeletePointById(payload.data[0]);
  543. break;
  544. case "doShowAreaName":
  545. doShowAreaName(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.data[4]);
  546. break;
  547. case "onDrawPolygonSquare":{
  548. require(["esri/geometry/Polygon","esri/Graphic","esri/geometry/Point","esri/geometry/Circle"],
  549. function(Polygon,Graphic,Point,Circle) {
  550. m_view.graphics.removeAll();
  551. GraphicsLayer_flyTipLayer.removeAll();
  552. var action = m_drawtool.create("rectangle", {
  553. mode: "click"//点击方式加点
  554. });
  555. // 获取焦点
  556. m_view.focus();
  557. //顶点移除事件
  558. action.on("vertex-remove", createRectangle);
  559. // 鼠标移动事件
  560. action.on("cursor-update", createRectangle);
  561. // 绘制完成事件
  562. action.on("draw-complete", createRectangleComplete);
  563. function createRectangle(event) {
  564. //获取所有顶点
  565. var vertices = event.vertices;
  566. //两点画矩形
  567. if(vertices.length<2){
  568. return
  569. }
  570. var rings=[vertices[0],[vertices[0][0],vertices[1][1]],vertices[1],[vertices[1][0],vertices[0][1]]];
  571. //清除之前绘制
  572. GraphicsLayer_flyTipLayer.removeAll();
  573. // 生成绘制的图形
  574. var graphic = new Graphic({
  575. geometry: new Polygon({
  576. hasZ: false,
  577. hasM: false,
  578. rings: [rings],
  579. spatialReference: m_view.spatialReference
  580. }),
  581. symbol: {
  582. type: "simple-fill", // autocasts as new SimpleFillSymbol()
  583. color: [ 51,51, 204, 0.9 ],
  584. style: "solid",
  585. outline: { // autocasts as new SimpleLineSymbol()
  586. color: "white",
  587. width: 1
  588. }
  589. }
  590. });
  591. // 将绘制的图形添加到view
  592. GraphicsLayer_flyTipLayer.add(graphic);
  593. }
  594. function createRectangleComplete(event) {
  595. //获取所有顶点
  596. var vertices = event.vertices;
  597. //两点画矩形
  598. if(vertices.length<2){
  599. return
  600. }
  601. var rings=[vertices[0],[vertices[0][0],vertices[1][1]],vertices[1],[vertices[1][0],vertices[0][1]]];
  602. //清除之前绘制
  603. GraphicsLayer_flyTipLayer.removeAll();
  604. // 生成绘制的图形
  605. var graphic = new Graphic({
  606. geometry: new Polygon({
  607. hasZ: false,
  608. hasM: false,
  609. rings: [rings],
  610. spatialReference: m_view.spatialReference
  611. }),
  612. symbol: {
  613. type: "simple-fill", // autocasts as new SimpleFillSymbol()
  614. color: [ 51,51, 204, 0.9 ],
  615. style: "solid",
  616. outline: { // autocasts as new SimpleLineSymbol()
  617. color: "white",
  618. width: 1
  619. }
  620. }
  621. });
  622. // 将绘制的图形添加到view
  623. GraphicsLayer_flyTipLayer.add(graphic);
  624. window.parent.postMessage(
  625. {
  626. method: "onDrawPolygoncallbackfun",
  627. data: [graphic.geometry.rings]
  628. },
  629. '*'
  630. );
  631. }
  632. });
  633. break;
  634. }
  635. case "doCorrugatedPointByOid":{
  636. doCorrugatedPointByOid(payload.data[0]);
  637. break;
  638. }
  639. case "doClearCorrugatedPoint":{
  640. doClearCorrugatedPoint();
  641. break;
  642. }
  643. case "doXyToStreetId":{
  644. doXyToStreetId(payload.data[0],payload.data[1]);
  645. break;
  646. }
  647. case "goToGraphic":{
  648. goToGraphic(payload.data[0], payload.data[1]);
  649. break;
  650. }
  651. case "doWaterRouteClick":{
  652. if(chartLayer){
  653. chartLayer.removeLayer();
  654. chartLayer=null;
  655. }
  656. if(chartLayer2){
  657. chartLayer2.removeLayer();
  658. chartLayer2=null;
  659. }
  660. if(chartLayer3){
  661. chartLayer3.removeLayer();
  662. chartLayer3=null;
  663. }
  664. queryResetNumByType(payload.data[0]);
  665. break
  666. }
  667. }
  668. };
  669. //初始化配置文件
  670. GetConfigData();
  671. require(["dojo/domReady!"
  672. ], function () {
  673. loadMap();
  674. });
  675. function loadMap() {
  676. //判断
  677. if (GetConfigDataByName("maptype") == "3D") {
  678. init3DScene();
  679. }
  680. else {
  681. initMap();
  682. }
  683. }
  684. function onMapLoadInfo(){
  685. console.log("test2")
  686. postToParentPageMethed("maploadCallback",[]);
  687. }
  688. function onMapLoaded()
  689. {
  690. removeLoadingDiv();
  691. // GetLayerMainRestInfo2(GetConfigDataByName("MYQueryLayer"));
  692. // var test = GetConfigDataByName("MYCXFeatureLayerLayer");
  693. // setPointBylonlat(121,30);
  694. //alert("加载完成");
  695. }
  696. //--------------- 按钮事件 -----------------
  697. //切换二三维地图
  698. function onViewTestClick() {
  699. ViewChange()
  700. }
  701. function ViewChange() {
  702. //m_view.container=null;
  703. // showLoadingDiv("正在切换地图,请稍后...");
  704. if (currentMapMode == "2D") {
  705. switchTo3DMap();
  706. }
  707. else {
  708. switchTo2DMap();
  709. }
  710. }
  711. //清空地图
  712. function btClear_Click() {
  713. //Clear();
  714. }
  715. function Clear(type) {
  716. require(["esri/layers/GraphicsLayer"],
  717. function ( GraphicsLayer) {
  718. switch (type) {
  719. case "all":
  720. {
  721. m_map.remove(GraphicsLayer_DrawLayer)
  722. GraphicsLayer_DrawLayer = new GraphicsLayer({id: "myDrawGLayer"});
  723. GraphicsLayer_DrawLayer.listMode = "hide";
  724. m_map.add(GraphicsLayer_DrawLayer);
  725. GraphicsLayer_myLayer.removeAll();
  726. isInLightArea = ""
  727. // GraphicsLayer_DrawLayer.removeAll();
  728. GraphicsLayer_flyTipLayer.removeAll();
  729. if (chartLayer) {
  730. chartLayer.removeLayer();
  731. chartLayer = null;
  732. }
  733. if (chartLayer2) {
  734. chartLayer2.removeLayer();
  735. chartLayer2 = null;
  736. }
  737. if (chartLayer3) {
  738. chartLayer3.removeLayer();
  739. chartLayer3 = null;
  740. }
  741. xmlQueryExtend = null;
  742. queryExtent = null;
  743. break;
  744. }
  745. case "drawLayer":
  746. {
  747. GraphicsLayer_DrawLayer.removeAll();
  748. GraphicsLayer_flyTipLayer.removeAll();
  749. xmlQueryExtend = null;
  750. queryExtent = null;
  751. break;
  752. }
  753. case "queryLayer":
  754. {
  755. GraphicsLayer_myLayer.removeAll();
  756. isInLightArea = ""
  757. GraphicsLayer_flyTipLayer.removeAll();
  758. xmlQueryExtend = null;
  759. queryExtent = null;
  760. break;
  761. }
  762. case "chartLayer":
  763. {
  764. if (chartLayer) {
  765. chartLayer.removeLayer();
  766. chartLayer = null;
  767. }
  768. if (chartLayer2) {
  769. chartLayer2.removeLayer();
  770. chartLayer2 = null;
  771. }
  772. if (chartLayer3) {
  773. chartLayer3.removeLayer();
  774. chartLayer3 = null;
  775. }
  776. break;
  777. }
  778. }
  779. })
  780. // var mtype = type | "all";
  781. }
  782. //查询
  783. function btSearch_Click() {
  784. // var dynamicLayerURL="https://services8.arcgis.com/wUIATpkD1eTGk5lC/arcgis/rest/services/CMRQTest2_WFL1/FeatureServer";
  785. // var QueryLayerID="13";
  786. var dynamicLayerURL ="http://139.196.105.31:6080/ArcGIS/rest/services/HKEMAP/MapServer";
  787. if(GetConfigDataByName("QueryLayer"))
  788. {
  789. dynamicLayerURL=GetConfigDataByName("QueryLayer");
  790. }
  791. var QueryLayerID = "13";
  792. var whereString = "";
  793. whereString = "HANDLE号 like '%" + document.getElementById("txtSearch").value + "%'";
  794. require([
  795. "esri/Graphic",
  796. "esri/tasks/QueryTask",
  797. "esri/tasks/support/Query",
  798. "esri/symbols/SimpleMarkerSymbol",
  799. "esri/symbols/SimpleLineSymbol",
  800. "esri/geometry/Point",
  801. "esri/geometry/Polyline",
  802. "esri/symbols/PointSymbol3D",
  803. "esri/renderers/SimpleRenderer",
  804. "esri/symbols/ObjectSymbol3DLayer",
  805. "esri/PopupTemplate",
  806. "dojo/_base/array"
  807. ], function (Graphic, QueryTask, Query, SimpleMarkerSymbol, SimpleLineSymbol, Point, Polyline, PointSymbol3D, SimpleRenderer, ObjectSymbol3DLayer, PopupTemplate, array) {
  808. var layerinfo = getLayerByLayerId(QueryLayerID);
  809. var queryTask = new QueryTask(dynamicLayerURL + "/" + QueryLayerID);
  810. var query = new Query();
  811. query.returnGeometry = true;
  812. query.outFields = ["*"];
  813. query.where = whereString;
  814. var defaultPointSymbol = new SimpleMarkerSymbol({
  815. color: [226, 119, 40],
  816. outline: { // autocasts as new SimpleLineSymbol()
  817. color: [255, 255, 255],
  818. width: 2
  819. }
  820. });
  821. var defaultLineSymbol = new SimpleLineSymbol({
  822. color: [255, 0, 255],
  823. width: 2
  824. });
  825. var objectSymbol = new PointSymbol3D({
  826. symbolLayers: [new ObjectSymbol3DLayer({
  827. width: 2,
  828. height: 3,
  829. resource: {
  830. primitive: "cone"
  831. },
  832. material: {
  833. color: "#FFD700"
  834. }
  835. })]
  836. });
  837. var objectSymbolRenderer = new SimpleRenderer({
  838. symbol: objectSymbol
  839. });
  840. //graphicsLayer.renderer = objectSymbolRenderer;
  841. queryTask.execute(query).then(function (results) {
  842. array.forEach(results.features, function (graphic, i) {
  843. var graphic2;
  844. var point2;
  845. switch (graphic.geometry.type) {
  846. case "point":
  847. {
  848. graphic.geometry.z = 1000;
  849. graphic.symbol = defaultPointSymbol;
  850. break;
  851. }
  852. case "polyline":
  853. var geo = Polyline(graphic.geometry);
  854. geo.hasZ = true;
  855. geo.hasM = false;
  856. var paths = geo.paths;
  857. for (var i = 0; i < paths.length; i++) {
  858. for (var j = 0; j < paths[i].length; j++) {
  859. paths[i][j] = [paths[i][j][0], paths[i][j][1], 50];
  860. }
  861. var middleNumber = Math.floor(paths[i].length / 2);
  862. point2 = new Point({
  863. x: paths[i][middleNumber][0],
  864. y: paths[i][middleNumber][1],
  865. z: 50,
  866. spatialReference: view.spatialReference
  867. });
  868. }
  869. graphic.symbol = defaultLineSymbol;
  870. graphic.geometry = geo;
  871. graphic2 = new Graphic();
  872. graphic2.attributes = graphic.attributes;
  873. graphic2.geometry = point2;
  874. graphic2.symbol = objectSymbol;
  875. graphic2.attributes = graphic.attributes;
  876. graphic2.popupTemplate = layerinfo.popupTemplate;
  877. graphic.popupTemplate = new PopupTemplate({
  878. title: "HANDLE号:{HANDLE号}"
  879. });
  880. break;
  881. }
  882. GraphicsLayer_myLayer.add(graphic);
  883. GraphicsLayer_myLayer.add(graphic2);
  884. });
  885. });
  886. })
  887. }
  888. var laylistshow=0;
  889. function layerOnOff() {
  890. if(laylistshow==0){
  891. laylistshow=1;
  892. m_view.ui.add(layerList, {
  893. position: "bottom-right"
  894. });
  895. }
  896. else
  897. {
  898. laylistshow=0;
  899. m_view.ui.remove(layerList);
  900. }
  901. }
  902. function doSetExtent(num) {
  903. var xmin,ymin,xmax,ymax;
  904. switch(num){
  905. case 1:
  906. xmin=-17221.816;
  907. ymin=-5450.66;
  908. xmax=-15189.445;
  909. ymax=-4297.402;
  910. break;
  911. case 2:
  912. xmin=-25930.782;
  913. ymin=-10527.042;
  914. xmax=-5599.259;
  915. ymax=647.995;
  916. break;
  917. case 3:
  918. xmin=-89836.648;
  919. ymin=-56485.216;
  920. xmax=70797.201;
  921. ymax=31738.557;
  922. break;
  923. }
  924. setExtent(xmin,ymin,xmax,ymax);
  925. }
  926. var myAttribute,myToolTip,myImgUrl,myImgWidth,myImgHeight;
  927. function setPointBylonlat(x,y,Attribute,ToolTip,ImgUrl,ImgWidth,ImgHeight){
  928. myAttribute = Attribute;
  929. myToolTip = ToolTip;
  930. myImgUrl = ImgUrl;
  931. myImgWidth = ImgWidth;
  932. myImgHeight=ImgHeight
  933. var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
  934. WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x,y],getXYbylonlat,null,url);
  935. }
  936. function getXYbylonlat(evt){
  937. if(evt[0] == null) {
  938. console.log("经纬度转换失败 error");
  939. return;
  940. }
  941. // console.log(evt[0].textContent);
  942. var point = evt[0].textContent;
  943. var jsonStr = '{"ExChangeRoot": {"Features": [' +
  944. ' { "type": "point", "featureName": "兴趣点", "Feature":[ { "Geometry": { "Points":[ { "Point": "'+point+'" } ]},' +
  945. '"Attribute": '+myAttribute+', "ToolTip": "'+myToolTip+'",' +
  946. '"ImgUrl":"'+myImgUrl +'" ,"ImgWidth":"'+ myImgWidth +'","ImgHeight":"'+myImgHeight +'" } ] } ]}}';
  947. doGetGraphicByJson(jsonStr,true);
  948. // console.log(jsonStr);
  949. }
  950. function setPointBylonlatForGrid(x,y){
  951. var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
  952. WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x,y],getXYbylonlatforGrid,null,url);
  953. }
  954. function getXYbylonlatforGrid(evt){
  955. if(evt[0] == null) {
  956. console.log("经纬度转换失败 error");
  957. return;
  958. }
  959. // console.log(evt[0].textContent);
  960. var point = evt[0].textContent;
  961. identifyTask(point,identifyTaskcallbackfun);
  962. }
  963. function identifyTaskcallbackfun(results){
  964. window.parent.postMessage(
  965. {
  966. method: "identifyTaskcallbackfun",
  967. data: [results]
  968. },
  969. '*'
  970. );
  971. }
  972. function setPointBylonlatForAddress(x,y){
  973. var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
  974. WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x,y],getXYbylonlatforAddress,null,url);
  975. }
  976. function getXYbylonlatforAddress(evt){
  977. if(evt[0] == null) {
  978. console.log("经纬度转换失败 error");
  979. return;
  980. }
  981. // console.log(evt[0].textContent);
  982. var point = evt[0].textContent;
  983. // var url = GetConfigDataByName("WebServiceExtraURL");
  984. // WsCommonClass("GetAddress",["x","y"],[point.split(',')[0],point.split(',')[1]],getAddressCallback,null,url);
  985. GetAddressByXY(point.split(',')[0],point.split(',')[1],50);
  986. }
  987. function getAddressCallback(evt){
  988. if(evt[0] == null) {
  989. console.log("经纬度转换失败 error");
  990. return;
  991. }
  992. var address = evt[0].textContent;
  993. window.parent.postMessage(
  994. {
  995. method: "addressdataCallback",
  996. data: [address]
  997. },
  998. '*'
  999. );
  1000. }
  1001. var m_radius;
  1002. var m_layername;
  1003. var m_showGraphic;
  1004. function setPointBylonlatForGetBuffer(x,y,layername,radius,isshow,isGoTo){
  1005. m_radius = radius;
  1006. m_layername = layername;
  1007. m_showGraphic = isshow;
  1008. var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
  1009. WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x-0,y-0],getXYbylonlatforBuffer,isGoTo,url);
  1010. }
  1011. function getXYbylonlatforBuffer(evt,isGoTo){
  1012. if(evt[0] == null) {
  1013. console.log("经纬度转换失败 error");
  1014. return;
  1015. }
  1016. var point = evt[0].textContent;
  1017. // var buffer = getBufferByPoint(point.split(',')[0],point.split(',')[1],m_radius);
  1018. getBufferByPoint(point.split(',')[0],point.split(',')[1],m_radius,m_layername,m_showGraphic,isGoTo);
  1019. //m_layername;
  1020. // queryByGeometryAndLayer(buffer,m_layername);
  1021. }
  1022. function getGridGeometry(grid,layername){
  1023. getGridGeometryByGridID(grid,layername);
  1024. }
  1025. function setPointBylonlatForSetCenter(x,y){
  1026. var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
  1027. WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x-0,y-0],getPointBylonlatForSetCenterr,null,url);
  1028. }
  1029. function getPointBylonlatForSetCenterr(evt){
  1030. if(evt[0] == null) {
  1031. console.log("经纬度转换失败 error");
  1032. return;
  1033. }
  1034. var point = evt[0].textContent;
  1035. m_view.center.x = point.split(',')[0]-0;
  1036. m_view.center.y = point.split(',')[1]-0;
  1037. m_view.goTo({
  1038. target: m_view.center
  1039. });
  1040. // m_view.center = [point.split(',')[0]-0,point.split(',')[1]-0];
  1041. }
  1042. var callMeasureLengthfun;
  1043. function MeasureLengthByPoint(x,y,x1,y1,fun){
  1044. callMeasureLengthfun = fun;
  1045. var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
  1046. var sql="121,31;121,31.1";
  1047. sql = x+","+y+";"+x1+","+y1;
  1048. WsCommonClass("ConvertLonLatToXYMass",["lonAndLatGroup"],[sql],getXYbylonlatMass,null,url);
  1049. }
  1050. function getXYbylonlatMass(evt){
  1051. console.log(evt[0].textContent);
  1052. var points = evt[0].textContent.split(';');
  1053. var x = points[0].split(',')[0];
  1054. var y = points[0].split(',')[1];
  1055. var x1 = points[1].split(',')[0];
  1056. var y1 = points[1].split(',')[1];
  1057. var len = measurePolylineByPoint(x,y,x1,y1);
  1058. // parent.eval(callMeasureLengthfun+"("+ len+")");
  1059. window.parent.postMessage(
  1060. {
  1061. method: callMeasureLengthfun,
  1062. data: [len]
  1063. },
  1064. '*'
  1065. );
  1066. }
  1067. function getXYbyAddress(str){
  1068. var url = GetConfigDataByName("WebServiceExtraURL");
  1069. WsCommonClass("GetStreetInfo",["address"],[str],getXYbyAddressCallback,null,url);
  1070. }
  1071. function getXYbyAddressCallback(evt){
  1072. if(evt[0] == null) {
  1073. console.log("error");
  1074. return;
  1075. }
  1076. // var jsonArray = $.xml2json(evt[0].textContent);
  1077. var jsonArray = $.xml2json(evt[0].innerHTML);
  1078. // var jsonArray = xmltojson(evt[0].textContent);
  1079. //var jsonArray =JSON.parse(evt[0].textContent)[0].data;
  1080. window.parent.postMessage(
  1081. {
  1082. method: "XYbyAddressCallback",
  1083. data:[JSON.stringify(jsonArray).replace(/\"/g,'"')]
  1084. },
  1085. '*'
  1086. );
  1087. }
  1088. function newOpenFeatureLayer(layername,type ,name,isGoTo,isOpen){
  1089. newOpenLayer(layername,type ,name,isGoTo,isOpen);
  1090. }
  1091. function popupClick(json) {
  1092. postToParentPageMethed("popupClickReturn",[json]);
  1093. }
  1094. function sqlReturn(evt,keyValue){
  1095. require(["esri/geometry/Extent", "esri/Graphic"],
  1096. function(Extent, Graphic) {
  1097. var allCount;
  1098. var pageIndex;
  1099. var jsonArray ;
  1100. if(evt[0] != null) {
  1101. allCount =JSON.parse(evt[0].textContent)[0].AllCount;
  1102. pageIndex=JSON.parse(evt[0].textContent)[0].pageIndex;
  1103. jsonArray =JSON.parse(evt[0].textContent)[0].data;
  1104. }else{
  1105. jsonArray =[]
  1106. }
  1107. switch (keyValue){
  1108. case "queryResetNumByType":{
  1109. var TestData1 = [ ]; var TestData2 = [ ];
  1110. for(var i=0;i<jsonArray.length;i++){
  1111. TestData1.push( [{ name:jsonArray[i].water_source_name,xy:[jsonArray[i].x1,jsonArray[i].y1] },
  1112. { name: jsonArray[i].water_work_name,xy:[jsonArray[i].x2,jsonArray[i].y2] }]);
  1113. TestData2.push( [{ name:jsonArray[i].water_work_name,xy:[jsonArray[i].x2,jsonArray[i].y2] },
  1114. { name: jsonArray[i].area_name,xy:[jsonArray[i].x3,jsonArray[i].y3] }]);
  1115. }
  1116. echartsWaterSourceToWorkRoute(TestData1,"#3581FF","",4);
  1117. echartsWaterWorkToAreaRoute(TestData2,"#42ebff","",4);
  1118. break;
  1119. }
  1120. }
  1121. })
  1122. }
  1123. </script>
  1124. </head>
  1125. <body>
  1126. <div id="mapDiv">
  1127. <!--<div id="viewTest">-->
  1128. <!--<button onclick="layerOnOff();">图层开关</button>-->
  1129. <!--</div>-->
  1130. </div>
  1131. <div id="infoDialog" title="详细信息">
  1132. <div id="divShowResult"></div>
  1133. </div>
  1134. </body>
  1135. </html>