GisShareApp3D2.html 53 KB

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