index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974
  1. <template>
  2. <div>
  3. <!-- cesiumContainer ref='cesiumContainer' style="display: none"-->
  4. <div id="cesiumContainer" style="cursor: auto"></div>
  5. <div class="bottom-bar">
  6. <div class="bottom-bar-item" id="tool-clickQuery" v-on:click="clickQuery()">
  7. <div class="bottom-bar-item-ps"></div>
  8. <span>点选查询</span>
  9. </div>
  10. <div class="bottom-bar-item" id="tool-dis" v-on:click="measureDistance()">
  11. <div class="bottom-bar-item-dis"></div>
  12. <span>距离测量</span>
  13. </div>
  14. <div class="bottom-bar-item" id="tool-area" v-on:click="measureArea()">
  15. <div class="bottom-bar-item-area"></div>
  16. <span>面积测量</span>
  17. </div>
  18. <div class="bottom-bar-item" id="tool-CircleQuery">
  19. <div class="bottom-bar-item-yxcx"></div>
  20. <span>圆形查询</span>
  21. </div>
  22. <div class="bottom-bar-item" id="tool-SquarenessQuery">
  23. <div class="bottom-bar-item-jxxz"></div>
  24. <span>矩形查询</span>
  25. </div>
  26. <div class="bottom-bar-item" id="tool-ScopeQuery">
  27. <div class="bottom-bar-item-spatial"></div>
  28. <span>范围查询</span>
  29. </div>
  30. <div class="bottom-bar-item" id="tool-dmfx">
  31. <div class="bottom-bar-item-dmfx"></div>
  32. <span>断面分析</span>
  33. </div>
  34. <div class="bottom-bar-item" id="tool-kwLine">
  35. <div class="bottom-bar-item-pzfx"></div>
  36. <span>碰撞分析</span>
  37. </div>
  38. <div class="bottom-bar-item" id="tool-ftfx">
  39. <div class="bottom-bar-item-ftfx"></div>
  40. <span>覆土分析</span>
  41. </div>
  42. <div class="bottom-bar-item" id="tool-ltfx">
  43. <div class="bottom-bar-item-ltfx"></div>
  44. <span>连通分析</span>
  45. </div>
  46. <div class="bottom-bar-item" id="tool-layerCtrl" v-on:click="layerCtrl()">
  47. <div class="bottom-bar-item-layers"></div>
  48. <span>图层管理</span>
  49. </div>
  50. <div class="bottom-bar-item" id="tool-clear" v-on:click="clearLays()">
  51. <div class="bottom-bar-item-clear"></div>
  52. <span>清除量算</span>
  53. </div>
  54. <div class="bottom-bar-item" id="tool-fullscreen" v-on:click="toggleFullScreen()">
  55. <div class="bottom-bar-item-fs"></div>
  56. <span>全屏显示</span>
  57. </div>
  58. </div>
  59. <div id="tips" style=" margin-left: 800px; top: 300px; position: absolute; display: none; background-color: #fff; border: 2px solid #69b4fd; z-index: 999; ">
  60. <font color="#000000"><strong>点击地图,双击结束编辑</strong></font>
  61. </div>
  62. <!-- cesiumContainer end-->
  63. </div>
  64. </template>
  65. <script></script>
  66. <script>
  67. import $ from 'jquery'
  68. import proj4 from 'proj4'
  69. import L from 'leaflet'
  70. import 'leaflet-draw'
  71. import * as mapclient from '@supermap/iclient-leaflet'
  72. import * as turf from '@turf/turf'
  73. import Vue from 'vue'
  74. import 'leaflet/dist/leaflet.css'
  75. import 'leaflet-draw/dist/leaflet.draw.css'
  76. import 'layui-src/dist/layui.js'
  77. import 'layui-src/dist/css/layui.css'
  78. // import "layui-src/dist/css/modules/layer/cool/cool.css";
  79. // layui.use(["layer"], function () {
  80. // let layer = layui.layer;
  81. // layer.config({
  82. // extend: "cool/cool.css",
  83. // skin: "layui-ext-coolskin",
  84. // });
  85. // });
  86. Vue.prototype.$mapclent = mapclient
  87. window.jQuery = $
  88. window.panels = {}
  89. // const layuilayer = require("layui-layer");
  90. L.drawLocal = {
  91. draw: {
  92. toolbar: {
  93. // #TODO: this should be reorganized where actions are nested in actions
  94. // ex: actions.undo or actions.cancel
  95. actions: {
  96. title: '取消绘图', //'Cancel drawing',
  97. text: '', //'Cancel'
  98. },
  99. finish: {
  100. title: '完成绘图', //'Finish drawing',
  101. text: 'Finish',
  102. },
  103. undo: {
  104. title: '删除最后绘制的点', //'Delete last point drawn',
  105. text: '', //'Delete last point'
  106. },
  107. buttons: {
  108. polyline: '绘制一个多段线', //'Draw a polyline',
  109. polygon: '绘制一个多边形', //'Draw a polygon',
  110. rectangle: '绘制一个矩形', //'Draw a rectangle',
  111. circle: '绘制一个圆', //'Draw a circle',
  112. marker: '绘制一个标记', //'Draw a marker',
  113. circlemarker: '绘制一个圆形标记', //'Draw a circlemarker'
  114. },
  115. },
  116. handlers: {
  117. circle: {
  118. tooltip: {
  119. start: '单击并拖动以绘制圆', //'Click and drag to draw circle.'
  120. },
  121. radius: 'Radius',
  122. },
  123. circlemarker: {
  124. tooltip: {
  125. start: '单击“地图”以放置圆标记', //'Click map to place circle marker.'
  126. },
  127. },
  128. marker: {
  129. tooltip: {
  130. start: '单击“地图”以放置标记', //'Click map to place marker.'
  131. },
  132. },
  133. polygon: {
  134. tooltip: {
  135. start: '单击开始绘制形状', //'Click to start drawing shape.',
  136. cont: '单击继续绘制形状', //'Click to continue drawing shape.',
  137. end: '单击第一个点关闭此形状', //'Click first point to close this shape.'
  138. },
  139. },
  140. polyline: {
  141. error: '<strong>错误:</strong>形状边缘不能交叉!', //'<strong>Error:</strong> shape edges cannot cross!',
  142. tooltip: {
  143. start: '单击开始绘制线', //'Click to start drawing line.',
  144. cont: '单击以继续绘制线', //'Click to continue drawing line.',
  145. end: '单击“最后一点”以结束线', //'Click last point to finish line.'
  146. },
  147. },
  148. rectangle: {
  149. tooltip: {
  150. start: '单击并拖动以绘制矩形', //'Click and drag to draw rectangle.'
  151. },
  152. },
  153. simpleshape: {
  154. tooltip: {
  155. end: '释放鼠标完成绘图', //'Release mouse to finish drawing.'
  156. },
  157. },
  158. },
  159. },
  160. edit: {
  161. toolbar: {
  162. actions: {
  163. save: {
  164. title: '保存更改', //'Save changes',
  165. text: '保存', //'Save'
  166. },
  167. cancel: {
  168. title: '取消编辑,放弃所有更改', //'Cancel editing, discards all changes',
  169. text: '取消', //'Cancel'
  170. },
  171. clearAll: {
  172. title: '清除所有图层', //'Clear all layers',
  173. text: '清除所有', //'Clear All'
  174. },
  175. },
  176. buttons: {
  177. edit: '编辑图层', //'Edit layers',
  178. editDisabled: '无可编辑的图层', //'No layers to edit',
  179. remove: '删除图层', //'Delete layers',
  180. removeDisabled: '无可删除的图层', //'No layers to delete'
  181. },
  182. },
  183. handlers: {
  184. edit: {
  185. tooltip: {
  186. text: '拖动控制柄或标记以编辑要素', //'Drag handles or markers to edit features.',
  187. subtext: '单击“取消”撤消更改', //'Click cancel to undo changes.'
  188. },
  189. },
  190. remove: {
  191. tooltip: {
  192. text: '单击要删除的要素', //'Click on a feature to remove.'
  193. },
  194. },
  195. },
  196. },
  197. }
  198. export default {
  199. name: 'gisMapVue',
  200. data() {
  201. // data() 为变量赋值等
  202. return {
  203. // GX_Map_BaseUrl: '',
  204. GX_Datas_BaseUrl:
  205. 'http://192.168.17.44:8090/iserver/services/data-weiweiGIS110/rest/data',
  206. GX_Plot_BaseUrl:
  207. 'http://192.168.17.44:8090/iserver/services/plot-TY/rest/plot/',
  208. GX_Spatialanalyst_BaseUrl:
  209. 'http://192.168.17.44:8090/iserver/services/spatialAnalysis-weiweiGIS110/restjsr/spatialanalyst',
  210. GX_TransportationAnalyst_BaseUrl:
  211. 'http://192.168.17.44:8090/iserver/services/transportationAnalyst-weiweiGIS110/rest/networkanalyst/weiweiGIS110_Network@weiweiGIS110',
  212. GX_CZ: [
  213. '全部',
  214. '铸铁',
  215. '钢',
  216. 'PVC',
  217. 'PE',
  218. 'PP-R',
  219. '铜',
  220. '陶制',
  221. '铝塑复合管',
  222. '不锈钢复合管',
  223. 'PP-B',
  224. ],
  225. GX_GJ: [
  226. '全部',
  227. '110',
  228. '160',
  229. '200',
  230. '300',
  231. '400',
  232. '500',
  233. '600',
  234. '700',
  235. '800',
  236. '900',
  237. '1000',
  238. ],
  239. GX_GK: [
  240. '全部',
  241. '200×200',
  242. '300×300',
  243. '400×400',
  244. '500×500',
  245. '600×600',
  246. '800×800',
  247. '1000×1000',
  248. ],
  249. GX_DataSourceName: 'weiweiGIS110',
  250. GX_DataSetName: 'gsGX',
  251. JD_DataSourceName: 'weiweiGIS110',
  252. JD_DataSetName: 'gsGD',
  253. SP_Min: '1.00',
  254. CZ_Min: '0.11',
  255. QUERY_BufferDistance: '1',
  256. GX_Datas: [
  257. {
  258. id: 'waterLine',
  259. name: '供水管线',
  260. dataSourceName: 'weiweiGIS110',
  261. dataSetName: 'gsGX',
  262. tableName: 'SMDTV_5',
  263. dataType: 'line',
  264. showZoom: 0,
  265. cols: 'SMID:实体编号,BSM:管段编号,QSDH:起始点号,ZDDH:终点点号,CZ:材质,GJ:管径(MM),QDMS:起点埋深(M),ZDMS:终点埋深(M),CD:长度(M),DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,GCBH:工程编号,ZCBH:资产编号,QSDW:权属单位,CQBH:测区编号,TCDW:探测单位,BZ:备注,FLDM:分类代码,TZBM:特征编码,ENABLED:是否可用,YL:压力,LX:流向',
  266. },
  267. {
  268. id: 'waterPoint',
  269. name: '管网节点',
  270. dataSourceName: 'weiweiGIS110',
  271. dataSetName: 'dvJD',
  272. tableName: 'SMDTV_9',
  273. dataType: 'point',
  274. showZoom: 15,
  275. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  276. },
  277. {
  278. id: 'xfsPoint',
  279. name: '消防栓',
  280. dataSourceName: 'weiweiGIS110',
  281. dataSetName: 'dvXFS',
  282. tableName: 'SMDTV_11',
  283. dataType: 'point',
  284. showZoom: 15,
  285. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  286. },
  287. {
  288. id: 'fmPoint',
  289. name: '阀门',
  290. dataSourceName: 'weiweiGIS110',
  291. dataSetName: 'dvFM',
  292. tableName: 'SMDTV_10',
  293. dataType: 'point',
  294. showZoom: 15,
  295. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  296. },
  297. {
  298. id: 'waterMeter',
  299. name: '水表',
  300. dataSourceName: 'weiweiGIS110',
  301. dataSetName: 'dvSB',
  302. tableName: 'SMDTV_15',
  303. dataType: 'point',
  304. showZoom: 15,
  305. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  306. },
  307. {
  308. id: 'jyzPoint',
  309. name: '加压站',
  310. dataSourceName: 'weiweiGIS110',
  311. dataSetName: 'dvJY',
  312. tableName: 'SMDTV_28',
  313. dataType: 'point',
  314. showZoom: 15,
  315. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  316. },
  317. {
  318. id: 'pqfPoint',
  319. name: '排气阀',
  320. dataSourceName: 'weiweiGIS110',
  321. dataSetName: 'dvPQF',
  322. tableName: 'SMDTV_17',
  323. dataType: 'point',
  324. showZoom: 15,
  325. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  326. },
  327. {
  328. id: 'cldPoint',
  329. name: '流量监测点',
  330. dataSourceName: 'weiweiGIS110',
  331. dataSetName: 'dvLL',
  332. tableName: 'SMDTV_13',
  333. dataType: 'point',
  334. showZoom: 15,
  335. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  336. },
  337. {
  338. id: 'cydPoint',
  339. name: '压力监测点',
  340. dataSourceName: 'weiweiGIS110',
  341. dataSetName: 'dvYL',
  342. tableName: 'SMDTV_12',
  343. dataType: 'point',
  344. showZoom: 15,
  345. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  346. },
  347. {
  348. id: 'szdPoint',
  349. name: '水质监测点',
  350. dataSourceName: 'weiweiGIS110',
  351. dataSetName: 'dvSZ',
  352. tableName: 'SMDTV_14',
  353. dataType: 'point',
  354. showZoom: 15,
  355. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  356. },
  357. {
  358. id: 'scPoint',
  359. name: '水厂',
  360. dataSourceName: 'weiweiGIS110',
  361. dataSetName: 'dvSC',
  362. tableName: 'SMDTV_16',
  363. dataType: 'point',
  364. showZoom: 15,
  365. cols: 'SMID:实体编号,BSM:管点编号,FSW:附属物,TZ:特征,CZ:材质,GG:规格,DMGC:地面高程(M),DINGGC:管顶高程(M),MS:埋深(M),X:X坐标,Y:Y坐标,TFH:图幅号,DZMS:地址描述,LRRQ:录入日期,MSRQ:埋设日期,MSFS:埋设方式,QSDW:权属单位,SSBH:设施编号,XH:型号,BZ:备注,CQBH:测区编号,WTH:物探号,FLDM:分类代码,YL:压力,DMT:多媒体',
  366. },
  367. ],
  368. ImgCLD: require('./images/style/cld.png'),
  369. ImgCYD: require('./images/style/cyd.png'),
  370. ImgFM: require('./images/style/fm.png'),
  371. ImgJYZ: require('./images/style/jyz.png'),
  372. ImgPQF: require('./images/style/pqf.png'),
  373. ImgSB: require('./images/style/sb.png'),
  374. ImgSC: require('./images/style/sc.png'),
  375. ImgSZD: require('./images/style/szd.png'),
  376. ImgXFS: require('./images/style/xfs.png'),
  377. markerIcon: L.icon({
  378. iconUrl: require('leaflet/dist/images/marker-icon.png'),
  379. iconSize: [25, 41],
  380. iconAnchor: [13, 41],
  381. }),
  382. map: undefined,
  383. mapLayer: undefined,
  384. lableLayer: undefined,
  385. crsProj: undefined,
  386. FTFX_MINS: undefined,
  387. layerStyles: undefined,
  388. allLayers: undefined,
  389. maps: undefined,
  390. // panels: undefined,
  391. utils: undefined,
  392. resultLayer: undefined,
  393. TempLayer: undefined,
  394. subLayers: undefined,
  395. plotting: undefined,
  396. plottingLayer: undefined,
  397. drawMapControl: undefined,
  398. drawLayer: undefined,
  399. drawType: undefined,
  400. }
  401. },
  402. created() {
  403. // created 在模板渲染成html前调用,即通常初始化某些属性值,然后再渲染成视图
  404. // 覆土分析标准埋深
  405. this.FTFX_MINS = new Map([
  406. ['PE', 0.7],
  407. ['铸铁', 0.7],
  408. ['PVC', 1.0],
  409. ['砼', 1.0],
  410. ['钢', 1.0],
  411. ['PPR', 1.0],
  412. ])
  413. // 各个图层的样式
  414. this.layerStyles = new Map()
  415. // 节点样式
  416. var waterPointStyle = L.supermap.circleStyle({
  417. color: '#953716',
  418. fill: true,
  419. fillColor: 'green',
  420. })
  421. this.layerStyles.set('waterPoint', waterPointStyle)
  422. var imgNew = new Image()
  423. imgNew.src = this.ImgXFS
  424. this.layerStyles.set('xfsPoint', L.supermap.imageStyle({ img: imgNew }))
  425. imgNew = new Image()
  426. imgNew.src = this.ImgFM
  427. this.layerStyles.set('fmPoint', L.supermap.imageStyle({ img: imgNew }))
  428. imgNew = new Image()
  429. imgNew.src = this.ImgSB
  430. this.layerStyles.set('waterMeter', L.supermap.imageStyle({ img: imgNew }))
  431. imgNew = new Image()
  432. imgNew.src = this.ImgJYZ
  433. this.layerStyles.set('jyzPoint', L.supermap.imageStyle({ img: imgNew }))
  434. imgNew = new Image()
  435. imgNew.src = this.ImgPQF
  436. this.layerStyles.set('pqfPoint', L.supermap.imageStyle({ img: imgNew }))
  437. imgNew = new Image()
  438. imgNew.src = this.ImgCLD
  439. this.layerStyles.set('cldPoint', L.supermap.imageStyle({ img: imgNew }))
  440. imgNew = new Image()
  441. imgNew.src = this.ImgCYD
  442. this.layerStyles.set('cydPoint', L.supermap.imageStyle({ img: imgNew }))
  443. imgNew = new Image()
  444. imgNew.src = this.ImgSC
  445. this.layerStyles.set('scPoint', L.supermap.imageStyle({ img: imgNew }))
  446. imgNew = new Image()
  447. imgNew.src = this.ImgSZD
  448. this.layerStyles.set('szdPoint', L.supermap.imageStyle({ img: imgNew }))
  449. proj4.defs(
  450. 'EPSG:4549',
  451. '+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs'
  452. )
  453. this.crsProj = L.Proj.CRS('EPSG:4549')
  454. this.allLayers = new Map()
  455. },
  456. methods: {
  457. // methods 编写js函数
  458. clickQuery() { },
  459. layerCtrl() {
  460. that.clearLays();
  461. panels.openLayerTreePanel();
  462. },
  463. measureDistance() {
  464. that.clearLays();
  465. that.map.off('click');
  466. that.map.off('dblclick');
  467. $('#tips').css('display', 'block');
  468. var isFirstPoint = true; //判断是否是起始点
  469. var latLngTemp = null; //存储上一点击点临时变量
  470. var resultDis = 0;//总距
  471. that.map.on('click', function (ev) {
  472. that.TempLayer.clearLayers();
  473. $('#tips').css('display', 'none')
  474. var polyLine
  475. if (isFirstPoint) {
  476. L.marker([ev.latlng.lat, ev.latlng.lng], {
  477. icon: that.markerIcon,
  478. }).addTo(that.resultLayer) //起始点
  479. var texticon = L.divIcon({
  480. //定义图标
  481. html: '起点',
  482. iconSize: [30, 20],
  483. iconAnchor: [15, 0],
  484. })
  485. L.marker([ev.latlng.lat, ev.latlng.lng], { icon: texticon }).addTo(
  486. that.resultLayer
  487. ) //marker实现文本框显示
  488. latLngTemp = ev.latlng //存储上一点击点
  489. isFirstPoint = false
  490. } else {
  491. if (!latLngTemp.equals(ev.latlng)) {
  492. //避免出现结束双击,导致距离为0
  493. polyLine = L.polyline(
  494. [
  495. //与上一点连线
  496. [latLngTemp.lat, latLngTemp.lng],
  497. [ev.latlng.lat, ev.latlng.lng],
  498. ],
  499. {
  500. color: 'red',
  501. }
  502. )
  503. that.resultLayer.addLayer(polyLine)
  504. L.marker([ev.latlng.lat, ev.latlng.lng], {
  505. icon: that.markerIcon,
  506. }).addTo(that.resultLayer) // 最后点击点经纬度
  507. var from = turf.point([latLngTemp.lng, latLngTemp.lat])
  508. var to = turf.point([ev.latlng.lng, ev.latlng.lat])
  509. var options = { units: 'kilometers' }
  510. var jl11 = turf.distance(from, to, options) * 1000
  511. latLngTemp = ev.latlng //更新临时变量为新点
  512. resultDis += jl11
  513. // 距离根据地图单位进行换算成米或者千米
  514. var content =
  515. '距上点:' +
  516. Number(jl11).toFixed(2) +
  517. '米' +
  518. '<br>总距:' +
  519. Number(resultDis).toFixed(2) +
  520. '米'
  521. var texticon = L.divIcon({
  522. html: content,
  523. iconSize: [110, 40],
  524. iconAnchor: [55, -5], //设置标签偏移避免遮盖
  525. })
  526. L.marker([ev.latlng.lat, ev.latlng.lng], {
  527. icon: texticon,
  528. }).addTo(that.resultLayer)
  529. that.TempLayer.clearLayers()
  530. }
  531. }
  532. that.map.on('mousemove', function (ev) {
  533. that.TempLayer.clearLayers()
  534. var TempLine = L.polyline(
  535. [
  536. //虚线临时线段
  537. [latLngTemp.lat, latLngTemp.lng],
  538. [ev.latlng.lat, ev.latlng.lng],
  539. ],
  540. {
  541. color: 'red',
  542. dashArray: '5,5',
  543. }
  544. )
  545. that.TempLayer.addLayer(TempLine)
  546. // 对坐标系进行转换
  547. var pt1 = that.crsProj.project(latLngTemp)
  548. var pt2 = that.crsProj.project(ev.latlng)
  549. var TempLineDis = L.polyline([
  550. //与上一点连线
  551. [pt1.y, pt1.x],
  552. [pt2.y, pt2.x],
  553. ])
  554. var from = turf.point([latLngTemp.lng, latLngTemp.lat])
  555. var to = turf.point([ev.latlng.lng, ev.latlng.lat])
  556. var options = { units: 'kilometers' }
  557. var jl11 = turf.distance(from, to, options) * 1000
  558. var texticon = L.divIcon({
  559. html: Number(jl11).toFixed(2) + '米',
  560. iconSize: 90,
  561. className: 'my-div-icon',
  562. iconAnchor: [45, -5],
  563. })
  564. L.marker([ev.latlng.lat, ev.latlng.lng], {
  565. icon: texticon,
  566. }).addTo(that.TempLayer)
  567. })
  568. })
  569. that.map.on('dblclick', function (ev) {
  570. that.map.off('click')
  571. that.map.off('dblclick')
  572. that.map.off('mousemove')
  573. })
  574. },
  575. measureArea() {
  576. that.drawType = 'measureArea'
  577. // 创建绘制控件,并启用
  578. var handler = new L.Draw.Polygon(that.map)
  579. handler.enable()
  580. that.map.on(L.Draw.Event.CREATED, function (e) {
  581. if (that.drawType != 'measureArea') {
  582. return
  583. }
  584. var type = e.layerType,
  585. layer = e.layer
  586. if (type === 'marker') {
  587. layer.bindPopup('A popup!')
  588. }
  589. //将图形信息传给下一步,进行查询功能
  590. var locationArray = e.layer.getLatLngs()[0]
  591. var polygonArray = Array()
  592. var turfPolygonArray = Array()
  593. var midArray = Array()
  594. var turfMidArray = Array()
  595. var firstX = locationArray[0].lat
  596. var firstY = locationArray[0].lng
  597. for (var i = 0; i < locationArray.length; i++) {
  598. var x = locationArray[i].lat
  599. var y = locationArray[i].lng
  600. midArray.push(x)
  601. midArray.push(y)
  602. turfMidArray.push(y)
  603. turfMidArray.push(x)
  604. polygonArray.push(midArray)
  605. turfPolygonArray.push(turfMidArray)
  606. midArray = Array()
  607. turfMidArray = Array()
  608. }
  609. midArray.push(firstX)
  610. midArray.push(firstY)
  611. turfMidArray.push(firstY)
  612. turfMidArray.push(firstX)
  613. polygonArray.push(midArray)
  614. turfPolygonArray.push(turfMidArray)
  615. var polygon = L.polygon(polygonArray, { color: '#00FF00' })
  616. var polygonTurf = turf.polygon([turfPolygonArray])
  617. var area = turf.area(polygonTurf)
  618. that.resultLayer.addLayer(polygon)
  619. var content = '面积:' + Number(area).toFixed(2) + '平方米'
  620. polygon.bindPopup(content).openPopup(polygon.getCenter())
  621. })
  622. },
  623. clearLays() {
  624. this.resultLayer.clearLayers()
  625. this.TempLayer.clearLayers()
  626. // this.plottingLayer.removeFeatures(drawLayer);
  627. },
  628. loadLayerTrees() {
  629. // 添加地图服务
  630. that.map = L.map('cesiumContainer', {
  631. preferCanvas: true,
  632. center: [45.507908, 124.290565],
  633. zoom: 14,
  634. crs: L.CRS.EPSG4326,
  635. }) //TianDiTu_WGS84
  636. that.mapLayer = L.supermap.tiandituTileLayer({
  637. key: 'f988d9c24e2e2d432266d5578ffbc1b0',
  638. attribution: '',
  639. })
  640. that.map.addLayer(that.mapLayer)
  641. var lableLayer = L.supermap.tiandituTileLayer({
  642. isLabel: true,
  643. key: 'f988d9c24e2e2d432266d5578ffbc1b0',
  644. attribution: '',
  645. })
  646. that.map.addLayer(lableLayer)
  647. var thisLayer = {}
  648. thisLayer.layer = this.mapLayer
  649. thisLayer.isShow = true
  650. that.allLayers.set('baseMap', thisLayer)
  651. var lyrs = that.GX_Datas
  652. for (var index = 0; index < lyrs.length; index++) {
  653. var lyr = lyrs[index]
  654. var lyrid = lyr.id
  655. var dataSourceName = lyr.dataSourceName
  656. var dataSetName = lyr.dataSetName
  657. that.addLayerData(dataSourceName, dataSetName, lyrid, '')
  658. }
  659. // // 添加鹰眼
  660. // var osm2 = L.supermap.tiandituTileLayer({ key: '1d109683f4d84198e37a38c442d68311' });
  661. // L.control.minimap(osm2, {mapOptions: { logoControl: false}, toggleDisplay: true}).addTo(this.map);
  662. // 添加比例尺
  663. //L.control.scale({ imperial: false }).addTo(this.map);
  664. // 启动绘制功能
  665. this.InitDraw()
  666. that.map.on('zoomend', function (e) {
  667. var nowZoom = e.target.getZoom()
  668. var lyrs = that.GX_Datas
  669. for (var index = 0; index < lyrs.length; index++) {
  670. var lyr = lyrs[index]
  671. var layId = lyr.id
  672. var showZoom = lyr.showZoom
  673. if (showZoom === undefined || showZoom === 0) {
  674. continue
  675. }
  676. var thisLayer = that.allLayers.get(layId)
  677. var isShow = thisLayer.isShow
  678. var layTmp = thisLayer.layer
  679. if (nowZoom >= showZoom) {
  680. if (isShow && !that.map.hasLayer(layTmp)) {
  681. that.map.addLayer(layTmp)
  682. }
  683. } else {
  684. if (isShow && that.map.hasLayer(layTmp)) {
  685. that.map.removeLayer(layTmp)
  686. }
  687. }
  688. }
  689. that.map.invalidateSize(true)
  690. })
  691. that.resultLayer = L.featureGroup().addTo(that.map)
  692. that.TempLayer = L.featureGroup().addTo(that.map)
  693. $('body').append("<div id='layerTree' ></div>")
  694. let openThePanel = function () {
  695. if ($('#layerTree').html().length > 0) {
  696. that.panelsloadLayerTreePanelByDom('layerTree')
  697. return
  698. }
  699. that.panelsloadLayerTreePanelByDom('layerTree', function () {
  700. var allLayersTemp = []
  701. for (var index = 0; index < lyrs.length; index++) {
  702. var lyr = lyrs[index]
  703. var nodeLayerInScene = {
  704. title: lyr.name,
  705. id: lyr.id,
  706. layer: lyr,
  707. checked: true,
  708. }
  709. allLayersTemp.push(nodeLayerInScene)
  710. }
  711. var nodeLayerInScene = {
  712. title: '地图服务',
  713. id: 'baseMap',
  714. layer: that.mapLayer,
  715. checked: true,
  716. }
  717. allLayersTemp.push(nodeLayerInScene)
  718. layui.use('tree', function () {
  719. const tree = layui.tree
  720. tree.render({
  721. elem: '#layerTree',
  722. data: allLayersTemp,
  723. showCheckbox: true,
  724. showLine: true,
  725. oncheck: function (obj) {
  726. var layId = obj.data.id
  727. var thisLayer = that.allLayers.get(layId)
  728. var layTmp = thisLayer.layer
  729. if (obj.checked) {
  730. if (!that.map.hasLayer(layTmp)) {
  731. that.map.addLayer(layTmp)
  732. thisLayer.isShow = true
  733. that.allLayers.set(layId, thisLayer)
  734. if (layId == 'baseMap' && lableLayer != null) {
  735. that.map.addLayer(lableLayer)
  736. }
  737. }
  738. } else {
  739. if (that.map.hasLayer(layTmp)) {
  740. that.map.removeLayer(layTmp)
  741. thisLayer.isShow = false
  742. that.allLayers.set(layId, thisLayer)
  743. if (layId == 'baseMap' && lableLayer != null) {
  744. that.map.removeLayer(lableLayer)
  745. }
  746. }
  747. }
  748. // 重新指定一下中心点,解决不刷新图层的问题
  749. that.map.panTo(that.map.getCenter())
  750. },
  751. })
  752. })
  753. })
  754. }
  755. panels.openLayerTreePanel = openThePanel
  756. },
  757. panelsloadLayerTreePanelByDom(domID, callback) {
  758. layui.use('layer', function () {
  759. const layer = layui.layer
  760. panels.layerTreePanelIndex = layer.open({
  761. anim: 3,
  762. id: 'layerTreePanel',
  763. area: '280px',
  764. title: ['全部图层', 'font-size:14px;'],
  765. offset: ['65px', that.panelsSideWidth() + 5 + 'px'],
  766. shade: 0,
  767. type: 1,
  768. content: $('#' + domID), //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
  769. cancel: function () { },
  770. success: function (layero, index) { },
  771. })
  772. if (callback != undefined) {
  773. callback()
  774. }
  775. })
  776. },
  777. panelsSideWidth() {
  778. return $('.layui-side').width()
  779. },
  780. addLayerData(dataSourceName, dataSetName, lyrid, showCss) {
  781. // var that = this;
  782. that.queryBySql(
  783. dataSetName,
  784. dataSourceName,
  785. 'SmID > 0',
  786. 0,
  787. 2000000,
  788. '',
  789. function (rs) {
  790. if (rs.result === undefined) return
  791. var result = L.Util.transform(
  792. rs.result.features,
  793. that.crsProj,
  794. L.CRS.EPSG4326
  795. )
  796. var rsLayer
  797. var thisLayer = {}
  798. if (lyrid === 'waterLine') {
  799. rsLayer = L.geoJSON(result, { style: { color: '#070af3' } })
  800. that.map.addLayer(rsLayer)
  801. } else {
  802. var circleStyle = that.layerStyles.get(lyrid)
  803. var graphics = []
  804. // 设置每个点的经纬度和传入样式
  805. for (var i = 0; i < result.features.length; i++) {
  806. var feature = result.features[i]
  807. var coordinates = feature.geometry.coordinates
  808. var pointVector = L.supermap.graphic({
  809. id: i + 1,
  810. latLng: L.latLng(coordinates[1], coordinates[0]),
  811. style: circleStyle.getStyle(),
  812. })
  813. graphics.push(pointVector)
  814. }
  815. // 将管点要素画在地图上
  816. //rsLayer = L.supermap.graphicLayer(graphics, {render: 'canvas'});
  817. rsLayer = L.supermap.graphicLayer(graphics)
  818. }
  819. thisLayer.layer = rsLayer
  820. thisLayer.isShow = true
  821. that.allLayers.set(lyrid, thisLayer)
  822. }
  823. )
  824. },
  825. InitDraw() { },
  826. toggleFullScreen() {
  827. var el = document.body
  828. var isFullscreen =
  829. document.fullScreen ||
  830. document.mozFullScreen ||
  831. document.webkitIsFullScreen
  832. if (!isFullscreen) {
  833. //进入全屏,多重短路表达式
  834. ; (el.requestFullscreen && el.requestFullscreen()) ||
  835. (el.mozRequestFullScreen && el.mozRequestFullScreen()) ||
  836. (el.webkitRequestFullscreen && el.webkitRequestFullscreen()) ||
  837. (el.msRequestFullscreen && el.msRequestFullscreen())
  838. } else {
  839. //退出全屏,三目运算符
  840. document.exitFullscreen
  841. ? document.exitFullscreen()
  842. : document.mozCancelFullScreen
  843. ? document.mozCancelFullScreen()
  844. : document.webkitExitFullscreen
  845. ? document.webkitExitFullscreen()
  846. : ''
  847. }
  848. },
  849. // #region queryBySql queryByBounds queryByGeometry
  850. queryBySql(
  851. datasetName,
  852. wsName,
  853. sql,
  854. fromIndex,
  855. toIndex,
  856. aggregations,
  857. callback
  858. ) {
  859. var sqlParam = new this.$mapclent.GetFeaturesBySQLParameters({
  860. queryParameter: {
  861. name: datasetName + '@' + wsName,
  862. attributeFilter: sql,
  863. },
  864. datasetNames: [wsName + ':' + datasetName],
  865. fromIndex: fromIndex,
  866. toIndex: toIndex,
  867. maxFeatures: toIndex,
  868. })
  869. L.supermap
  870. .featureService(this.GX_Datas_BaseUrl)
  871. .getFeaturesBySQL(sqlParam, function (sr) {
  872. if (callback === undefined) return
  873. else callback(sr)
  874. })
  875. },
  876. queryByBounds(title, datasetName, wsName, bounds, callback) {
  877. var paramsTmp = {}
  878. paramsTmp.title = title
  879. paramsTmp.dataSetName = datasetName
  880. paramsTmp.dataSourceName = wsName
  881. var geometryParam = new this.$mapclent.GetFeaturesByGeometryParameters({
  882. datasetNames: [wsName + ':' + datasetName],
  883. geometry: bounds,
  884. spatialQueryMode: 'INTERSECT',
  885. })
  886. L.supermap
  887. .featureService(this.GX_Datas_BaseUrl)
  888. .getFeaturesByGeometry(geometryParam, function (serviceResult) {
  889. if (callback !== undefined) {
  890. callback(serviceResult, paramsTmp)
  891. }
  892. })
  893. },
  894. queryByGeometry(
  895. title,
  896. distanceTmp,
  897. datasetName,
  898. wsName,
  899. geometry,
  900. callback
  901. ) {
  902. var paramsTmp = {}
  903. paramsTmp.title = title
  904. paramsTmp.dataSetName = datasetName
  905. paramsTmp.dataSourceName = wsName
  906. if (distanceTmp === undefined) {
  907. distanceTmp = this.QUERY_BufferDistance
  908. }
  909. var bufferParam = new this.$mapclent.GetFeaturesByBufferParameters({
  910. datasetNames: [wsName + ':' + datasetName],
  911. bufferDistance: distanceTmp,
  912. geometry: geometry,
  913. })
  914. L.supermap
  915. .featureService(this.GX_Datas_BaseUrl)
  916. .getFeaturesByBuffer(bufferParam, function (serviceResult) {
  917. if (callback !== undefined) {
  918. callback(serviceResult, paramsTmp)
  919. }
  920. })
  921. },
  922. // #endregion
  923. },
  924. mounted() {
  925. // mounted在模板渲染成html后调用,通常是初始化页面完成后,再对html的dom节点进行一些需要的操作
  926. window.that = this
  927. layui.use(['layer'], function () {
  928. let layer = layui.layer
  929. layer.config({
  930. extend: 'cool/cool.css',
  931. skin: 'layui-ext-coolskin',
  932. })
  933. })
  934. this.loadLayerTrees()
  935. setTimeout(() => {
  936. this.map.invalidateSize(true)
  937. }, 1000)
  938. },
  939. }
  940. </script>
  941. <style scoped>
  942. @import url(css/styles.css);
  943. </style>