supermap.vue 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624
  1. <template>
  2. <div v-bind:id="mapDivId" ref="map" style="width: 100%; height: 100%;background: none;">
  3. <div id="toolbar" v-if="isdynamicPlotting" class="panel panel-primary"
  4. style="position:absolute;z-index: 9999;top:4rem;left: 1rem; border-radius: 4px; width: fit-content;height:635px;overflow-y:scroll;background:#040b1f">
  5. <div class="panel-heading" id="panelheading">
  6. <h5 style=" color: #2bacf7;font-size: 1rem;padding:.5rem;">鼠标标绘</h5>
  7. </div>
  8. <div class="panel-body content" id="panelbodycontent" style="margin-bottom: .5rem;padding-right: .5rem;">
  9. <div align="right" class="button-group">
  10. <el-button type="success" @click="PlottingDrawCancel">取消标绘</el-button>
  11. &nbsp;&nbsp;
  12. <el-button type="success" @click="clearLayers">清空标绘</el-button>
  13. </div>
  14. </div>
  15. <div id="plottingPanel">
  16. <div id="plotPanel" style="width: 15rem;height:50%;overflow-y:scroll;">
  17. </div>
  18. </div>
  19. </div>
  20. <div id="toolbar-heat" v-if="isheatPlotting" class="panel panel-primary"
  21. style="position:absolute;z-index: 9999; padding: 1rem; bottom:3rem;right: 1rem; border-radius: 4px; width: fit-content;height:fit-content;overflow-y:scroll;background:#040b1f">
  22. <div class="panel-body content">
  23. <div class="panel">
  24. <div class="input-group">
  25. <span class="input-group-addon">风向</span>
  26. <select class="form-control" style="width:auto" id="heatNums">
  27. <option value="1">南风</option>
  28. <option value="31">西南风</option>
  29. <option value="41">东南风</option>
  30. <option value="2">北风</option>
  31. <option value="32">西北风</option>
  32. <option value="42">东北风</option>
  33. <option value="3">西风</option>
  34. <option value="4">东风</option>
  35. </select>
  36. </div>
  37. </div>
  38. <div class="panel">
  39. <div class="input-group">
  40. <span class="input-group-addon">风速</span>
  41. <input type="text" class="form-control" id="heatNums1" value="6" />
  42. </div>
  43. </div>
  44. <div class="panel">
  45. <div class="input-group">
  46. <span class="input-group-addon">温度</span>
  47. <input type="text" class="form-control" id="heatNums2" value="10℃" />
  48. </div>
  49. </div>
  50. <div class="panel">
  51. <div class="input-group">
  52. <span class="input-group-addon">湿度</span>
  53. <input type="text" class="form-control" id="heatNums3" value="6%RH" />
  54. </div>
  55. </div>
  56. <div class="panel">
  57. <div class="input-group">
  58. <span class="input-group-addon">持续时间</span>
  59. <input type="text" class="form-control" id="heatNums4" value="60分钟" />
  60. </div>
  61. </div>
  62. <div class="panel">
  63. <div class="input-group">
  64. <span class="input-group-addon">植被类型</span>
  65. <select class="form-control" style="width:auto" id="heatNums5">
  66. <option value="1">针叶林</option>
  67. <option value="31">落叶林</option>
  68. </select>
  69. </div>
  70. </div>
  71. <div class="panel">
  72. <div class="input-group">
  73. <span class="input-group-addon">大气压</span>
  74. <input type="text" class="form-control" id="heatNums6" value="101.325kPa" />
  75. </div>
  76. </div>
  77. <div class="panel">
  78. <el-button type="success" @click="createHeatPoints">分析</el-button>
  79. <el-button type="success" @click="clearHeatPoints">重置</el-button>
  80. </div>
  81. </div>
  82. </div>
  83. <el-dialog title="林班数据" :visible.sync="showBanData" width="80%" append-to-body>
  84. <div style="display: flex; flex-wrap: wrap; height:70vh; overflow-y: scroll; align-content: flex-start">
  85. <div v-for="(value, key ,index) in banDataList" style="width:33%;border: 1px solid #1b6d9d;" v-if="value!=''">
  86. <div style="display: flex; align-items: center;padding: .5rem; color: #3ee1fa; font-size: 14px;">
  87. <div><h5>{{ key }}:</h5></div>
  88. <div>
  89. <h5 style="margin-left: .5rem;">{{ value }}</h5>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </el-dialog>
  95. <!-- <el-dialog title="林班数据" :visible.sync="showBanData" width="80%" append-to-body>
  96. <div style="display: flex; flex-wrap: wrap; height:70vh; overflow-y: scroll; align-content: flex-start">
  97. <div style="width:33%;border: 1px solid #1b6d9d;">
  98. <div style="display: flex; align-items: center;padding: .5rem; color: #3ee1fa; font-size: 14px;">
  99. <div><h5>ID:</h5></div>
  100. <div>
  101. <h5 style="margin-left: .5rem;">{{ banDataList.id }}</h5>
  102. </div>
  103. </div>
  104. </div>
  105. <div style="width:33%;border: 1px solid #1b6d9d;">
  106. <div style="display: flex; align-items: center;padding: .5rem; color: #3ee1fa; font-size: 14px;">
  107. <div><h5>SmID:</h5></div>
  108. <div>
  109. <h5 style="margin-left: .5rem;">{{ banDataList.smid }}</h5>
  110. </div>
  111. </div>
  112. </div>
  113. <div style="width:33%;border: 1px solid #1b6d9d;">
  114. <div style="display: flex; align-items: center;padding: .5rem; color: #3ee1fa; font-size: 14px;">
  115. <div><h5>SmArea:</h5></div>
  116. <div>
  117. <h5 style="margin-left: .5rem;">{{ banDataList.smarea }}</h5>
  118. </div>
  119. </div>
  120. </div>
  121. <div style="width:33%;border: 1px solid #1b6d9d;">
  122. <div style="display: flex; align-items: center;padding: .5rem; color: #3ee1fa; font-size: 14px;">
  123. <div><h5>SmGeometry:</h5></div>
  124. <div>
  125. <h5 style="margin-left: .5rem;">{{ banDataList.smgeometry }}</h5>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </el-dialog>-->
  131. </div>
  132. </template>
  133. <script>
  134. // import 'leaflet-side-by-side'
  135. // import '@supermap/iclient-leaflet'
  136. // import 'leaflet/dist/leaflet.css'
  137. // import 'leaflet.markercluster/dist/leaflet.markercluster-src.js'
  138. // import 'leaflet.markercluster/dist/MarkerCluster.css'
  139. // import 'leaflet.markercluster/dist/MarkerCluster.Default.css'
  140. // import 'leaflet-draw'
  141. // import 'leaflet-draw/dist/leaflet.draw.css'
  142. // import L from 'leaflet'
  143. import {
  144. getSuperMap,
  145. iconList,
  146. getCenterdataTSupermapBlockBySmID,
  147. getCenterdataTSupermapBlockBySBT,
  148. } from '@/api/components/supermap.js'
  149. import {
  150. selectConfigKey
  151. } from '@/api/system/config'
  152. // import {setToken} from '../plugins/auth'
  153. import modal from '@/plugins/modal'
  154. import { getCenterdataTSupermapBlock } from '../api/components/supermap'
  155. export default {
  156. name: 'sookaSuperMap',
  157. data() {
  158. return {
  159. showBanData: false, //林班数据弹层
  160. banDataList: [], //林班数据
  161. plottingdrawControl: null,
  162. plottingLayer: null,
  163. mapDivId: '',
  164. map: null,
  165. layers: [],
  166. layersBytype: [],
  167. isAggregationLayers: [],
  168. radiusLayers: [],
  169. myGroup: [],
  170. myGroupBytype: [],
  171. isAggregationMyGroup: [],
  172. polygon: null,
  173. connectLayer: [],
  174. connectLayerTwo: [],
  175. graphicsLayer: [],
  176. graphicsLayerTwo: [],
  177. latLngLayers: [],
  178. latLngGroup: [],
  179. isEditableLayers: false, //绘图控件
  180. drawControl: null, //绘图控件
  181. deckglLayer: null, //图层Layer
  182. deckglLayerList: [], //图层Layer(数组)
  183. deckglLayerList_Data: [], //图层Layer(数组) 地图
  184. resultLayer_Data: [], //数据图层Layer(数组) 数据
  185. infoView:null,
  186. lbtInfoView:null,
  187. lbtThemeLayer:null,
  188. heatMapLayer: [], //火灾蔓延图层Layer
  189. isheatPlotting: false, //火灾蔓延
  190. heat_lat: 0, //火灾蔓延经纬度
  191. heat_lng: 0, //火灾蔓延经纬度
  192. host: '',
  193. queryParams: {
  194. smid: null,
  195. bsm: null,
  196. tbbh: null,
  197. },
  198. }
  199. },
  200. watch: {
  201. isEditableLayers: {
  202. handler(newValue, oldValue) {
  203. if (newValue) {
  204. var editableLayers = new window.L.FeatureGroup()
  205. this.map.addLayer(editableLayers)
  206. let options = {
  207. position: 'topleft',
  208. draw: {
  209. polyline: {},
  210. polygon: {},
  211. circle: {},
  212. rectangle: {},
  213. marker: {},
  214. remove: {}
  215. },
  216. edit: {
  217. featureGroup: editableLayers,
  218. remove: true
  219. }
  220. }
  221. this.drawControl = new window.L.Control.Draw(options)
  222. this.map.addControl(this.drawControl)
  223. this.map.on(window.L.Draw.Event.CREATED, function(e) {
  224. let editableLayer = e.layer
  225. let layerType = e.layerType
  226. editableLayer.on('dblclick', function(e) {
  227. if (layerType === 'polygon' || layerType === 'rectangle') {
  228. let latlng = editableLayer.getLatLngs()[0]
  229. //一个自定义的计算面积的函数
  230. var seeArea = window.L.GeometryUtil.geodesicArea(latlng)
  231. let area = (seeArea / 10e5).toFixed(2) + 'k㎡'
  232. modal.msg(area)
  233. } else if (layerType === 'polyline') {
  234. let latlng = editableLayer.getLatLngs()
  235. //一个自定义的计算长度的函数
  236. let dis = 0
  237. for (let i = 0; i < latlng.length - 1; i++) {
  238. let start = latlng[i]
  239. let end = latlng[i + 1]
  240. dis += window.L.latLng([start.lat, start.lng]).distanceTo([end.lat,
  241. end.lng
  242. ]) //计算两个点之间的距离,并累加
  243. }
  244. //结果得到的也是number类型,单位是KM
  245. modal.msg((dis / 10e2).toFixed(2) + 'km')
  246. }
  247. })
  248. if (layerType === 'marker') {
  249. let icon = new window.L.Icon({
  250. iconUrl: iconList['marker'],
  251. iconSize: [48, 48],
  252. iconAnchor: [24, 40],
  253. popupAnchor: [-3, -40],
  254. shadowSize: [41, 41]
  255. })
  256. editableLayer.options.icon = icon
  257. }
  258. editableLayers.addLayer(editableLayer)
  259. })
  260. } else {
  261. this.map.removeControl(this.drawControl)
  262. }
  263. }
  264. }
  265. },
  266. mounted() {
  267. this.initMap()
  268. //添加画图的提示信息
  269. window.L.drawLocal.draw.toolbar = {
  270. actions: {
  271. title: '取消绘图',
  272. text: '取消'
  273. },
  274. finish: {
  275. title: '完成绘图',
  276. text: '完成'
  277. },
  278. undo: {
  279. title: '删除最后绘制的点',
  280. text: '删除最后一个点'
  281. },
  282. buttons: {
  283. polyline: '绘制折线',
  284. polygon: '绘制多边形',
  285. rectangle: '绘制矩形',
  286. circle: '绘制圆圈',
  287. marker: '绘制标记',
  288. circlemarker: '绘制圆圈标记'
  289. }
  290. }
  291. window.L.drawLocal.draw.handlers = {
  292. circle: {
  293. tooltip: {
  294. start: '单击并拖动以绘制圆形'
  295. },
  296. radius: '半径'
  297. },
  298. circlemarker: {
  299. tooltip: {
  300. start: '点击地图放置圆圈标记'
  301. }
  302. },
  303. marker: {
  304. tooltip: {
  305. start: '点击地图放置标记'
  306. }
  307. },
  308. polygon: {
  309. tooltip: {
  310. start: '点击开始绘制形状',
  311. cont: '点击继续绘制形状',
  312. end: '单击第一个点以关闭此形状'
  313. }
  314. },
  315. polyline: {
  316. error: '<strong>Error:</strong> shape edges cannot cross!',
  317. tooltip: {
  318. start: '点击开始画线',
  319. cont: '点击继续画线',
  320. end: '单击最后一点以完成线'
  321. }
  322. },
  323. rectangle: {
  324. tooltip: {
  325. start: '单击并拖动以绘制矩形'
  326. }
  327. },
  328. simpleshape: {
  329. tooltip: {
  330. end: '释放鼠标完成绘图'
  331. }
  332. }
  333. }
  334. window.L.drawLocal.edit = {
  335. toolbar: {
  336. actions: {
  337. save: {
  338. title: '保存更改',
  339. text: '保存'
  340. },
  341. cancel: {
  342. title: '取消编辑,放弃所有更改',
  343. text: '取消'
  344. },
  345. clearAll: {
  346. title: '清除所有图层',
  347. text: '清除所有'
  348. }
  349. },
  350. buttons: {
  351. edit: '编辑图层',
  352. editDisabled: '没有可编辑的图层',
  353. remove: '删除图层',
  354. removeDisabled: '没有可删除的图层'
  355. }
  356. },
  357. handlers: {
  358. edit: {
  359. tooltip: {
  360. text: '拖动手柄或标记以编辑要素',
  361. subtext: '单击取消以撤消更改'
  362. }
  363. },
  364. remove: {
  365. tooltip: {
  366. text: '单击要删除的功能'
  367. }
  368. }
  369. }
  370. }
  371. },
  372. props: {
  373. mapDiv: null,
  374. codes: null,
  375. mapSite: {},
  376. isdynamicPlotting: false, //动态标绘表格
  377. isSideBySide: false,
  378. showLatLng: null,
  379. showAreaLatLng: null,
  380. showLineLatLng: null
  381. },
  382. methods: {
  383. /** ----------------------------------火势蔓延 开始------------------------------------- */
  384. // initEditView: function() {
  385. // var that = this
  386. // var infoView = window.L.control({ position: 'topright' })
  387. // infoView.onAdd = function() {
  388. // that._div = L.DomUtil.create('div', 'editPane')
  389. // that._div.style.width = '236px'
  390. // that._div.innerHTML = '<div id="toolbar" class="panel panel-primary">' +
  391. // '<div class="panel-heading">' +
  392. // '<h5 class="panel-title text-center">' + resources.text_fastHeatMapLayer + '</h5></div>' +
  393. // '<div class="panel-body content">' +
  394. // '<div class="panel">' +
  395. // '<div class="input-group">' +
  396. // '<span class="input-group-addon">风向</span>' +
  397. // '<select class="form-control" style="width:auto" id="heatNums">' +
  398. // '<option value="1" >南风</option>' +
  399. // '<option value="2" >北风</option>' +
  400. // '<option value="3" >西风</option>' +
  401. // '<option value="4" >东风</option>' +
  402. // '</select>' +
  403. // '</div>' +
  404. // '</div>' +
  405. // '<div class="panel">' +
  406. // '<div class="input-group">' +
  407. // '<span class="input-group-addon">风速</span>' +
  408. // '<input type="text" class="form-control" id="heatNums1" value="20"/>' +
  409. // '</div>' +
  410. // '</div>' +
  411. //
  412. // '<input type="button" class="btn btn-default" value="' + resources.btn_startDraw + '" onclick ="'+that.createHeatPoints()+'"/>&nbsp; &nbsp;' +
  413. // '<input type="button" class="btn btn-default" value="' + resources.text_input_value_clear + '" onclick ="'+that.clearHeatPoints()+'"/>' +
  414. // '</div>' +
  415. // '</div>'
  416. // that.handleMapEvent(that._div, that.map)
  417. // return that._div
  418. // }
  419. // infoView.addTo(that.map)
  420. // },
  421. // handleMapEvent: function(div, map) {
  422. // let that = this
  423. // if (!div || !map) {
  424. // return
  425. // }
  426. // div.addEventListener('mouseover', function() {
  427. // that.map.dragging.disable()
  428. // that.map.scrollWheelZoom.disable()
  429. // that.map.doubleClickZoom.disable()
  430. // })
  431. // div.addEventListener('mouseout', function() {
  432. // that.map.dragging.enable()
  433. // that.map.scrollWheelZoom.enable()
  434. // that.map.doubleClickZoom.enable()
  435. // })
  436. // },
  437. showheatPlotting: function(heat_lat, heat_lng) {
  438. this.heat_lat = heat_lat
  439. this.heat_lng = heat_lng
  440. this.isheatPlotting = true
  441. },
  442. createHeatPoints: function() {
  443. let that = this
  444. that.clearHeatPoints()
  445. that.heatMapLayer = new window.L.supermap.heatMapLayer(
  446. 'heatMap', {
  447. 'map': that.map,
  448. 'id': 'heatmap',
  449. 'radius': 10,
  450. // 设置图层透明度:(参数方式)
  451. 'opacity': 0.5,
  452. //featureWeight指定以哪个属性值为热力权重值创建热力图:
  453. 'featureWeight': 'value'
  454. }
  455. )
  456. var heatNums = parseInt($('#heatNums').val())
  457. //热力半径单位不使用用地理单位
  458. that.heatMapLayer.useGeoUnit = true
  459. that.heatMapLayer.radius = 0.01
  460. var features = []
  461. switch (heatNums) {
  462. case 1: //南风
  463. features = that.getPointArray1()
  464. break
  465. case 31: //西南风
  466. features = that.getPointArray3_1()
  467. break
  468. case 41: //东南风
  469. features = that.getPointArray4_1()
  470. break
  471. case 2: //北风
  472. features = that.getPointArray2()
  473. break
  474. case 32: //西北风
  475. features = that.getPointArray3_2()
  476. break
  477. case 42: //东北风
  478. features = that.getPointArray4_2()
  479. break
  480. case 3: //西风
  481. features = that.getPointArray3()
  482. break
  483. case 4: //东风
  484. features = that.getPointArray4()
  485. break
  486. }
  487. //加载heatMapFeature格式数据:
  488. that.heatMapLayer.addFeatures(features)
  489. that.heatMapLayer.addTo(that.map)
  490. },
  491. clearHeatPoints: function() {
  492. let that = this
  493. if (that.heatMapLayer) {
  494. that.map.removeLayer(that.heatMapLayer)
  495. that.heatMapLayer = null
  496. }
  497. },
  498. getPointArray1: function() {
  499. var heatNums1 = parseInt($('#heatNums1').val())
  500. var mLon = this.heat_lng,
  501. mLat = this.heat_lat
  502. var points = []
  503. for (var i = 0; i < parseInt(heatNums1 / 3); i++) {
  504. mLat = this.accAdd(mLat, 0.005)
  505. points[i] = new window.L.supermap.heatMapFeature(L.point(mLon, mLat), {
  506. 'value': 2000 - (i * Math.random())
  507. })
  508. }
  509. return points
  510. },
  511. getPointArray3_1: function() {
  512. var heatNums1 = parseInt($('#heatNums1').val())
  513. var mLon = this.heat_lng,
  514. mLat = this.heat_lat
  515. var points = []
  516. for (var i = 0; i < parseInt(heatNums1 / 3); i++) {
  517. mLat = this.accAdd(mLat, 0.005)
  518. mLon = this.accAdd(mLon, 0.005)
  519. points[i] = new window.L.supermap.heatMapFeature(L.point(mLon, mLat), {
  520. 'value': 2000 - (i * Math.random())
  521. })
  522. }
  523. return points
  524. },
  525. getPointArray4_1: function() {
  526. var heatNums1 = parseInt($('#heatNums1').val())
  527. var mLon = this.heat_lng,
  528. mLat = this.heat_lat
  529. var points = []
  530. for (var i = 0; i < parseInt(heatNums1 / 3); i++) {
  531. mLat = this.accAdd(mLat, 0.005)
  532. mLon = this.accSub(mLon, 0.005)
  533. points[i] = new window.L.supermap.heatMapFeature(L.point(mLon, mLat), {
  534. 'value': 2000 - (i * Math.random())
  535. })
  536. }
  537. return points
  538. },
  539. getPointArray2: function() {
  540. var heatNums1 = parseInt($('#heatNums1').val())
  541. var mLon = this.heat_lng,
  542. mLat = this.heat_lat
  543. var points = []
  544. for (var i = 0; i < parseInt(heatNums1 / 3); i++) {
  545. mLat = this.accSub(mLat, 0.005)
  546. points[i] = new window.L.supermap.heatMapFeature(L.point(mLon, mLat), {
  547. 'value': 2000 - (i * Math.random())
  548. })
  549. }
  550. return points
  551. },
  552. getPointArray3_2: function() {
  553. var heatNums1 = parseInt($('#heatNums1').val())
  554. var mLon = this.heat_lng,
  555. mLat = this.heat_lat
  556. var points = []
  557. for (var i = 0; i < parseInt(heatNums1 / 3); i++) {
  558. mLat = this.accSub(mLat, 0.005)
  559. mLon = this.accAdd(mLon, 0.005)
  560. points[i] = new window.L.supermap.heatMapFeature(L.point(mLon, mLat), {
  561. 'value': 2000 - (i * Math.random())
  562. })
  563. }
  564. return points
  565. },
  566. getPointArray4_2: function() {
  567. var heatNums1 = parseInt($('#heatNums1').val())
  568. var mLon = this.heat_lng,
  569. mLat = this.heat_lat
  570. var points = []
  571. for (var i = 0; i < parseInt(heatNums1 / 3); i++) {
  572. mLat = this.accSub(mLat, 0.005)
  573. mLon = this.accSub(mLon, 0.005)
  574. points[i] = new window.L.supermap.heatMapFeature(L.point(mLon, mLat), {
  575. 'value': 2000 - (i * Math.random())
  576. })
  577. }
  578. return points
  579. },
  580. getPointArray3: function() {
  581. var heatNums1 = parseInt($('#heatNums1').val())
  582. var mLon = this.heat_lng,
  583. mLat = this.heat_lat
  584. var points = []
  585. for (var i = 0; i < parseInt(heatNums1 / 3); i++) {
  586. mLon = this.accAdd(mLon, 0.005)
  587. points[i] = new window.L.supermap.heatMapFeature(L.point(mLon, mLat), {
  588. 'value': 2000 - (i * Math.random())
  589. })
  590. }
  591. return points
  592. },
  593. getPointArray4: function() {
  594. var heatNums1 = parseInt($('#heatNums1').val())
  595. var mLon = this.heat_lng,
  596. mLat = this.heat_lat
  597. var points = []
  598. for (var i = 0; i < parseInt(heatNums1 / 3); i++) {
  599. mLon = this.accSub(mLon, 0.005)
  600. points[i] = new window.L.supermap.heatMapFeature(L.point(mLon, mLat), {
  601. 'value': 2000 - (i * Math.random())
  602. })
  603. }
  604. return points
  605. },
  606. //加法函数,用来得到精确的加法结果
  607. //说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
  608. //调用:accAdd(arg1,arg2)
  609. //返回值:arg1加上arg2的精确结果
  610. accAdd: function(arg1, arg2) {
  611. var r1, r2, m, c
  612. try {
  613. r1 = arg1.toString().split('.')[1].length
  614. } catch (e) {
  615. r1 = 0
  616. }
  617. try {
  618. r2 = arg2.toString().split('.')[1].length
  619. } catch (e) {
  620. r2 = 0
  621. }
  622. c = Math.abs(r1 - r2)
  623. m = Math.pow(10, Math.max(r1, r2))
  624. if (c > 0) {
  625. var cm = Math.pow(10, c)
  626. if (r1 > r2) {
  627. arg1 = Number(arg1.toString().replace('.', ''))
  628. arg2 = Number(arg2.toString().replace('.', '')) * cm
  629. } else {
  630. arg1 = Number(arg1.toString().replace('.', '')) * cm
  631. arg2 = Number(arg2.toString().replace('.', ''))
  632. }
  633. } else {
  634. arg1 = Number(arg1.toString().replace('.', ''))
  635. arg2 = Number(arg2.toString().replace('.', ''))
  636. }
  637. return (arg1 + arg2) / m
  638. },
  639. /**
  640. ** 减法函数,用来得到精确的减法结果
  641. ** 说明:javascript的减法结果会有误差,在两个浮点数相减的时候会比较明显。这个函数返回较为精确的减法结果。
  642. ** 调用:accSub(arg1,arg2)
  643. ** 返回值:arg1加上arg2的精确结果
  644. **/
  645. accSub: function(arg1, arg2) {
  646. var r1, r2, m, n
  647. try {
  648. r1 = arg1.toString().split('.')[1].length
  649. } catch (e) {
  650. r1 = 0
  651. }
  652. try {
  653. r2 = arg2.toString().split('.')[1].length
  654. } catch (e) {
  655. r2 = 0
  656. }
  657. m = Math.pow(10, Math.max(r1, r2)) //last modify by deeka //动态控制精度长度
  658. n = r1 >= r2 ? r1 : r2
  659. return ((arg1 * m - arg2 * m) / m).toFixed(n)
  660. },
  661. /** ----------------------------------火势蔓延 结束------------------------------------- */
  662. /** ----------------------------------热力图 结束------------------------------------- */
  663. loadHeatMap: async function(points) {
  664. var heatNumbers = 150,
  665. heatRadius = 30
  666. var num = parseInt(heatNumbers)
  667. num = (num > 0) ? num : 0
  668. var radius = parseInt(heatRadius)
  669. radius = (radius > 0) ? radius : 0
  670. var heatPoints = points
  671. // for (var i = 0; i < num; i++) {
  672. // heatPoints[i] = [Math.random() * 0.28 + 42, Math.random() * 0.5 + 125, Math.random() * 80]
  673. // }
  674. var resultLayer = window.L.heatLayer(heatPoints, {
  675. radius: radius,
  676. minOpacity: 0.5
  677. }).addTo(this.map)
  678. },
  679. /** ----------------------------------热力图 开始------------------------------------- */
  680. clearM: async function(isAggregation) { //清理地图标点
  681. if (isAggregation) {
  682. if (this.isAggregationMyGroup != undefined && this.isAggregationMyGroup != false) {
  683. this.isAggregationMyGroup.clearLayers()
  684. }
  685. this.map.removeLayer(this.isAggregationLayers)
  686. this.isAggregationLayers = []
  687. this.radiusLayers = []
  688. this.isAggregationLayers = window.L.markerClusterGroup({
  689. //设置为true时显示聚类所占据的范围
  690. showCoverageOnHover: true,
  691. //设置为true时会向低一级聚类缩放
  692. zoomToBoundsOnClick: true,
  693. //增加点位时增加聚合动画(否则会出问题)
  694. animateAddingMarkers: true,
  695. //最大缩放级别点击聚合图标展开图标
  696. spiderfyOnMaxZoom: true
  697. })
  698. } else {
  699. if (this.myGroup != undefined && this.myGroup != false) {
  700. this.myGroup.clearLayers()
  701. }
  702. this.map.removeLayer(this.layers)
  703. this.layers = []
  704. }
  705. },
  706. clearMByType: async function(type) { //清理地图标点(根据类型,可取消落点)
  707. if (this.myGroupBytype != undefined && this.myGroupBytype != false) {
  708. for (var i = this.myGroupBytype.length - 1; i >= 0; i--) {
  709. if (this.myGroupBytype[i].type == type) {
  710. this.myGroupBytype[i].myGroup.clearLayers()
  711. this.myGroupBytype.splice(i, 1)
  712. }
  713. }
  714. }
  715. if (this.layersBytype != null && this.layersBytype.length > 0) {
  716. for (var i = this.layersBytype.length - 1; i >= 0; i--) {
  717. if (this.layersBytype[i].type == type) {
  718. this.layersBytype.splice(i, 1)
  719. }
  720. }
  721. }
  722. },
  723. clearC: async function() { //清理地图画线
  724. if (this.connectLayer != undefined && this.connectLayer != false) {
  725. this.connectLayer.clearLayers()
  726. }
  727. this.connectLayer = []
  728. },
  729. clearCTwo: async function() { //清理地图画线two
  730. if (this.connectLayerTwo != undefined && this.connectLayerTwo != false) {
  731. this.connectLayerTwo.clearLayers()
  732. }
  733. this.connectLayerTwo = []
  734. },
  735. clearG: async function() { //清理地图图形
  736. if (this.graphicsLayer != undefined && this.graphicsLayer != false) {
  737. this.graphicsLayer.clearLayers()
  738. }
  739. this.graphicsLayer = []
  740. },
  741. clearGTwo: async function() { //清理地图图形
  742. if (this.graphicsLayerTwo != undefined && this.graphicsLayerTwo != false) {
  743. this.graphicsLayerTwo.clearLayers()
  744. }
  745. this.graphicsLayerTwo = []
  746. },
  747. clearP: async function() { //清理点击事件落点
  748. if (this.latLngGroup != undefined && this.latLngGroup != false) {
  749. this.latLngGroup.clearLayers()
  750. }
  751. this.latLngLayers = []
  752. },
  753. initMap: function() {
  754. let _that = this
  755. this.mapDivId = this.mapDiv
  756. let mapSite = this.mapSite
  757. let isSideBySide = this.isSideBySide
  758. let isdynamicPlotting = this.isdynamicPlotting
  759. // setToken("eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6ImY5Zjg3ZjVmLWQ4NTctNDQxZC04NmQ5LTg4OWExZWRlODE4ZSIsInVzZXJuYW1lIjoiYWRtaW4ifQ.26mAzmaM9pUza9585aLnRMyRd4GxvrWbCxN0erYsuiBDYQiYnyc-TwXVNDI7Xrpt3Bqmbnul-XMszOxYQi12LA");
  760. _that.isAggregationLayers = window.L.markerClusterGroup({
  761. //设置为true时显示聚类所占据的范围
  762. showCoverageOnHover: true,
  763. //设置为true时会向低一级聚类缩放
  764. zoomToBoundsOnClick: true,
  765. //增加点位时增加聚合动画(否则会出问题)
  766. animateAddingMarkers: true,
  767. //最大缩放级别点击聚合图标展开图标
  768. spiderfyOnMaxZoom: true
  769. })
  770. if (!isSideBySide) { //只有一个地图
  771. if (this.codes.length != 1) {
  772. modal.msgError('请输入一个地图code!')
  773. return
  774. }
  775. getSuperMap(this.codes).then(resp => {
  776. let mapList = resp.data
  777. if (mapList != null && mapList.length > 0) {
  778. let url = mapList[0].url
  779. let centerLat = mapList[0].centerLat
  780. let centerLng = mapList[0].centerLng
  781. let zoom = mapList[0].zoom //默认比例
  782. let maxZoom = mapList[0].maxZoom //最大比例
  783. let minZoom = mapList[0].minZoom //最小比例
  784. let zoomControl = mapList[0].zoomControl == null ? true : mapList[0]
  785. .zoomControl //地图缩放+-号是否显示
  786. let attributionControl = mapList[0].attributionControl == null ? true : mapList[0]
  787. .attributionControl //logo是否显示
  788. let logoControl = mapList[0].logoControl == null ? false : mapList[0]
  789. .logoControl //logo是否显示
  790. let dragging = mapList[0].dragging == null ? true : mapList[0]
  791. .dragging //地图是否允许鼠标拖拽
  792. let defaultConfigure = {
  793. crs: window.L.CRS.EPSG4326,
  794. center: [centerLat, centerLng],
  795. maxZoom: maxZoom,
  796. minZoom: minZoom,
  797. zoom: zoom,
  798. editable: true,
  799. zoomControl: zoomControl,
  800. attributionControl: attributionControl,
  801. dragging: dragging,
  802. logoControl: logoControl
  803. }
  804. let loadConfiguration = Object.assign(defaultConfigure, mapSite)
  805. this.map = window.L.map(this.mapDiv, loadConfiguration)
  806. //鼠标双击落点
  807. if (this.showLatLng != undefined) {
  808. let icon = new window.L.Icon({
  809. iconUrl: iconList['marker'],
  810. iconSize: [48, 48],
  811. iconAnchor: [24, 40],
  812. popupAnchor: [-3, -40],
  813. shadowSize: [41, 41]
  814. })
  815. this.map.on('dblclick', function(e) {
  816. _that.clearP()
  817. _that.showLatLng(e.latlng.lat, e.latlng.lng)
  818. let marker = window.L.marker([e.latlng.lat, e.latlng.lng], {
  819. icon: icon
  820. }).addTo(this.map)
  821. _that.latLngLayers.push(marker)
  822. _that.latLngGroup = window.L.layerGroup(_that.latLngLayers)
  823. this.map.addLayer(_that.latLngGroup)
  824. })
  825. }
  826. //鼠标绘制区域
  827. if (this.showAreaLatLng != undefined) {
  828. var editableLayers = new window.L.FeatureGroup()
  829. this.map.addLayer(editableLayers)
  830. let options = {
  831. position: 'topleft',
  832. draw: {
  833. polyline: null,
  834. polygon: {},
  835. circle: null,
  836. rectangle: null,
  837. circlemarker: null,
  838. marker: null,
  839. remove: {}
  840. },
  841. edit: {
  842. featureGroup: editableLayers,
  843. remove: true
  844. }
  845. }
  846. var drawControl = new window.L.Control.Draw(options)
  847. this.map.addControl(drawControl)
  848. this.map.on(window.L.Draw.Event.CREATED, function(e) {
  849. let editableLayer = e.layer
  850. let layerType = e.layerType
  851. editableLayer.on('dblclick', function(e) {
  852. if (layerType === 'polygon' || layerType ===
  853. 'rectangle') {
  854. let latlng = editableLayer.getLatLngs()[0]
  855. _that.showAreaLatLng(latlng)
  856. }
  857. })
  858. editableLayers.addLayer(editableLayer)
  859. })
  860. }
  861. //鼠标绘制线段
  862. if (this.showLineLatLng != undefined) {
  863. var editableLayers = new window.L.FeatureGroup()
  864. this.map.addLayer(editableLayers)
  865. let options = {
  866. position: 'topleft',
  867. draw: {
  868. polyline: {},
  869. polygon: null,
  870. circle: null,
  871. rectangle: null,
  872. circlemarker: null,
  873. marker: null,
  874. remove: {}
  875. },
  876. edit: {
  877. featureGroup: editableLayers,
  878. remove: true
  879. }
  880. }
  881. var drawControl = new window.L.Control.Draw(options)
  882. this.map.addControl(drawControl)
  883. this.map.on(window.L.Draw.Event.CREATED, function(e) {
  884. let editableLayer = e.layer
  885. let layerType = e.layerType
  886. editableLayer.on('dblclick', function(e) {
  887. if (layerType === 'polyline') {
  888. let latlng = editableLayer.getLatLngs()
  889. _that.showLineLatLng(latlng)
  890. }
  891. })
  892. editableLayers.addLayer(editableLayer)
  893. })
  894. }
  895. // url = 'https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China_4326'
  896. window.L.supermap.tiledMapLayer(url).addTo(this.map)
  897. }
  898. })
  899. } else { //卷帘地图
  900. if (this.codes.length != 2) {
  901. modal.msgError('请输入两个地图code!')
  902. return
  903. }
  904. getSuperMap(this.codes).then(resp => {
  905. let mapList = resp.data
  906. if (mapList != null && mapList.length == 2) {
  907. let stamenurl = mapList[0].url
  908. let osmurl = mapList[1].url
  909. let centerLat = mapList[0].centerLat
  910. let centerLng = mapList[0].centerLng
  911. let zoom = mapList[0].zoom //默认比例
  912. let maxZoom = mapList[0].maxZoom //最大比例
  913. let minZoom = mapList[0].minZoom //最小比例
  914. let zoomControl = mapList[0].zoomControl == null ? true : mapList[0]
  915. .zoomControl //地图缩放+-号是否显示
  916. let attributionControl = mapList[0].attributionControl == null ? true : mapList[0]
  917. .attributionControl //logo是否显示
  918. let logoControl = mapList[0].logoControl == null ? false : mapList[0]
  919. .logoControl //logo是否显示
  920. let dragging = mapList[0].dragging == null ? true : mapList[0]
  921. .dragging //地图是否允许鼠标拖拽
  922. let defaultConfigure = {
  923. crs: window.L.CRS.EPSG4326,
  924. center: [centerLat, centerLng],
  925. maxZoom: maxZoom,
  926. minZoom: minZoom,
  927. zoom: zoom,
  928. editable: true,
  929. zoomControl: zoomControl,
  930. attributionControl: attributionControl,
  931. dragging: dragging,
  932. logoControl: logoControl
  933. }
  934. let loadConfiguration = Object.assign(defaultConfigure, mapSite)
  935. this.map = window.L.map(this.mapDiv, loadConfiguration)
  936. //鼠标双击落点
  937. if (this.showLatLng != undefined) {
  938. let icon = new window.L.Icon({
  939. iconUrl: iconList['marker'],
  940. iconSize: [48, 48],
  941. iconAnchor: [24, 40],
  942. popupAnchor: [-3, -40],
  943. shadowSize: [41, 41]
  944. })
  945. this.map.on('dblclick', function(e) {
  946. _that.clearP()
  947. _that.showLatLng(e.latlng.lat, e.latlng.lng)
  948. let marker = window.L.marker([e.latlng.lat, e.latlng.lng], {
  949. icon: icon
  950. }).addTo(this.map)
  951. _that.latLngLayers.push(marker)
  952. _that.latLngGroup = window.L.layerGroup(_that.latLngLayers)
  953. this.map.addLayer(_that.latLngGroup)
  954. })
  955. }
  956. //鼠标绘制区域
  957. if (this.showAreaLatLng != undefined) {
  958. var editableLayers = new window.L.FeatureGroup()
  959. this.map.addLayer(editableLayers)
  960. let options = {
  961. position: 'topleft',
  962. draw: {
  963. polyline: null,
  964. polygon: {},
  965. circle: null,
  966. rectangle: null,
  967. circlemarker: null,
  968. marker: null,
  969. remove: {}
  970. },
  971. edit: {
  972. featureGroup: editableLayers,
  973. remove: true
  974. }
  975. }
  976. var drawControl = new window.L.Control.Draw(options)
  977. this.map.addControl(drawControl)
  978. this.map.on(window.L.Draw.Event.CREATED, function(e) {
  979. let editableLayer = e.layer
  980. let layerType = e.layerType
  981. editableLayer.on('dblclick', function(e) {
  982. if (layerType === 'polygon' || layerType ===
  983. 'rectangle') {
  984. let latlng = editableLayer.getLatLngs()[0]
  985. _that.showAreaLatLng(latlng)
  986. }
  987. })
  988. editableLayers.addLayer(editableLayer)
  989. })
  990. }
  991. //鼠标绘制线段
  992. if (this.showLineLatLng != undefined) {
  993. var editableLayers = new window.L.FeatureGroup()
  994. this.map.addLayer(editableLayers)
  995. let options = {
  996. position: 'topleft',
  997. draw: {
  998. polyline: {},
  999. polygon: null,
  1000. circle: null,
  1001. rectangle: null,
  1002. circlemarker: null,
  1003. marker: null,
  1004. remove: {}
  1005. },
  1006. edit: {
  1007. featureGroup: editableLayers,
  1008. remove: true
  1009. }
  1010. }
  1011. var drawControl = new window.L.Control.Draw(options)
  1012. this.map.addControl(drawControl)
  1013. this.map.on(window.L.Draw.Event.CREATED, function(e) {
  1014. let editableLayer = e.layer
  1015. let layerType = e.layerType
  1016. editableLayer.on('dblclick', function(e) {
  1017. if (layerType === 'polyline') {
  1018. let latlng = editableLayer.getLatLngs()
  1019. _that.showLineLatLng(latlng)
  1020. }
  1021. })
  1022. editableLayers.addLayer(editableLayer)
  1023. })
  1024. }
  1025. let stamenLayer = window.L.supermap.tiledMapLayer(stamenurl).addTo(this.map)
  1026. let osmLayer = window.L.supermap.tiledMapLayer(osmurl).addTo(this.map)
  1027. L.control.sideBySide(stamenLayer, osmLayer).addTo(this.map)
  1028. }
  1029. })
  1030. }
  1031. },
  1032. // 获取面积
  1033. /**
  1034. * polygon [{lat:30,lng:104},{lat:30,lng:104},{lat:30,lng:104}]
  1035. */
  1036. formatArea: function(polygon) {
  1037. //L.GeometryUtil.geodesicArea(),返回number类型的数据,单位是平方米,这里做了一下转化
  1038. var seeArea = window.L.GeometryUtil.geodesicArea(polygon)
  1039. let area = (seeArea / 10e5).toFixed(2) + 'k㎡'
  1040. return area
  1041. },
  1042. // 获取长度
  1043. /**
  1044. * line[{lat:30,lng:104},{lat:30,lng:104},{lat:30,lng:104}]
  1045. */
  1046. formatLength: function(line) {
  1047. let dis = 0
  1048. for (let i = 0; i < line.length - 1; i++) {
  1049. let start = line[i]
  1050. let end = line[i + 1]
  1051. dis += window.L.latLng([start.lat, start.lng]).distanceTo([end.lat, end.lng]) //计算两个点之间的距离,并累加
  1052. }
  1053. //结果得到的也是number类型,单位是 米
  1054. return (dis / 10e2).toFixed(2) + 'km'
  1055. },
  1056. setMarkers: function(markersList) { //地图标点
  1057. const _that = this
  1058. for (let i = 0; i < markersList.length; i++) {
  1059. let isAggregation = markersList[i].isAggregation == null ? false : markersList[i]
  1060. .isAggregation //是否聚合点位
  1061. let keepBindPopup = isAggregation == true ? false : markersList[i].keepBindPopup //提示气泡是否一直显示
  1062. let icon = new window.L.Icon({
  1063. iconUrl: iconList[markersList[i].icon],
  1064. iconSize: [48, 48],
  1065. iconAnchor: [24, 40],
  1066. popupAnchor: [-3, -40],
  1067. shadowSize: [41, 41]
  1068. })
  1069. let markerClick = window.L.marker([markersList[i].lat, markersList[i].lng], {
  1070. icon: icon
  1071. })
  1072. if (markersList[i].bindPopupHtml != null && markersList[i].bindPopupHtml !== '') {
  1073. let html = markersList[i].bindPopupHtml
  1074. if (keepBindPopup) {
  1075. markerClick.bindPopup(html, {
  1076. autoClose: false,
  1077. closeOnClick: null,
  1078. closeButton: false
  1079. }).openPopup(markerClick.getLatLng())
  1080. } else {
  1081. markerClick.on('mouseover', function() {
  1082. let html = markersList[i].bindPopupHtml
  1083. this.bindPopup(html).openPopup(this.getLatLng())
  1084. }).on('mouseout', function() {
  1085. this.closePopup()
  1086. })
  1087. }
  1088. }
  1089. if (markersList[i].click != null && markersList[i].click !== '') {
  1090. if (markersList[i].parameter != null && markersList[i].parameter !== '') {
  1091. markerClick.on('click', function() {
  1092. let clickName = markersList[i].click
  1093. _that.$emit(clickName, markersList[i].parameter)
  1094. })
  1095. } else {
  1096. markerClick.on('click', function() {
  1097. let clickName = markersList[i].click
  1098. _that.$emit(clickName)
  1099. })
  1100. }
  1101. }
  1102. if (isAggregation) {
  1103. _that.isAggregationLayers.addLayer(markerClick)
  1104. _that.isAggregationMyGroup = window.L.layerGroup(_that.isAggregationLayers)
  1105. } else {
  1106. _that.layers.push(markerClick)
  1107. _that.myGroup = window.L.layerGroup(_that.layers)
  1108. }
  1109. }
  1110. if (_that.myGroup != undefined && _that.myGroup != false) {
  1111. _that.map.addLayer(_that.myGroup)
  1112. }
  1113. _that.map.addLayer(_that.isAggregationLayers)
  1114. },
  1115. setMarkersByType: function(markersList, type) { //地图标点(根据类型,可取消落点 clearMByType方法)
  1116. const _that = this
  1117. let lay = []
  1118. let myGroup = []
  1119. for (let i = 0; i < markersList.length; i++) {
  1120. let keepBindPopup = markersList[i].keepBindPopup //提示气泡是否一直显示
  1121. let icon = new window.L.Icon({
  1122. iconUrl: iconList[markersList[i].icon],
  1123. iconSize: [48, 48],
  1124. iconAnchor: [24, 40],
  1125. popupAnchor: [-3, -40],
  1126. shadowSize: [41, 41]
  1127. })
  1128. let markerClick = window.L.marker([markersList[i].lat, markersList[i].lng], {
  1129. icon: icon
  1130. }).addTo(this.map)
  1131. if (markersList[i].bindPopupHtml != null && markersList[i].bindPopupHtml !== '') {
  1132. let html = markersList[i].bindPopupHtml
  1133. if (keepBindPopup) {
  1134. markerClick.bindPopup(html, {
  1135. autoClose: false,
  1136. closeOnClick: null,
  1137. closeButton: false
  1138. }).openPopup(markerClick.getLatLng())
  1139. } else {
  1140. markerClick.on('mouseover', function() {
  1141. let html = markersList[i].bindPopupHtml
  1142. this.bindPopup(html).openPopup(this.getLatLng())
  1143. }).on('mouseout', function() {
  1144. this.closePopup()
  1145. })
  1146. }
  1147. }
  1148. if (markersList[i].click != null && markersList[i].click !== '') {
  1149. if (markersList[i].parameter != null && markersList[i].parameter !== '') {
  1150. markerClick.on('click', function() {
  1151. let clickName = markersList[i].click
  1152. _that.$emit(clickName, markersList[i].parameter)
  1153. })
  1154. } else {
  1155. markerClick.on('click', function() {
  1156. let clickName = markersList[i].click
  1157. _that.$emit(clickName)
  1158. })
  1159. }
  1160. }
  1161. lay.push(markerClick)
  1162. _that.layersBytype.push({
  1163. type: type,
  1164. marker: markerClick
  1165. })
  1166. myGroup = window.L.layerGroup(lay)
  1167. _that.myGroupBytype.push({
  1168. type: type,
  1169. myGroup: myGroup
  1170. })
  1171. this.map.addLayer(myGroup)
  1172. }
  1173. },
  1174. setMarkersRadius: function(markersList) { //地图标点带范围
  1175. const _that = this
  1176. for (let i = 0; i < markersList.length; i++) {
  1177. let isAggregation = markersList[i].isAggregation == null ? false : markersList[i]
  1178. .isAggregation //是否聚合点位
  1179. let keepBindPopup = isAggregation == true ? false : markersList[i].keepBindPopup //提示气泡是否一直显示
  1180. _that.polygon = window.L.circle([markersList[i].lat, markersList[i].lng], {
  1181. radius: markersList[i].radius
  1182. })
  1183. let icon = new window.L.Icon({ //传感器
  1184. iconUrl: iconList[markersList[i].icon],
  1185. iconSize: [48, 48],
  1186. iconAnchor: [24, 40],
  1187. popupAnchor: [-3, -40],
  1188. shadowSize: [41, 41]
  1189. })
  1190. let marker = window.L.marker([markersList[i].lat, markersList[i].lng], {
  1191. icon: icon
  1192. })
  1193. if (markersList[i].bindPopupHtml != null && markersList[i].bindPopupHtml !== '') {
  1194. let html = markersList[i].bindPopupHtml
  1195. if (keepBindPopup) {
  1196. marker.bindPopup(html, {
  1197. autoClose: false,
  1198. closeOnClick: null,
  1199. closeButton: false
  1200. }).openPopup(marker.getLatLng())
  1201. } else {
  1202. marker.on('mouseover', function() {
  1203. let html = markersList[i].bindPopupHtml
  1204. this.bindPopup(html).openPopup(this.getLatLng())
  1205. }).on('mouseout', function() {
  1206. this.closePopup()
  1207. })
  1208. }
  1209. }
  1210. if (markersList[i].click != null && markersList[i].click != '') {
  1211. if (markersList[i].parameter != null && markersList[i].parameter !== '') {
  1212. marker.on('click', function() {
  1213. let clickName = markersList[i].click
  1214. _that.$emit(clickName, markersList[i].parameter)
  1215. })
  1216. } else {
  1217. marker.on('click', function() {
  1218. let clickName = markersList[i].click
  1219. _that.$emit(clickName)
  1220. })
  1221. }
  1222. }
  1223. marker.addTo(this.map)
  1224. if (isAggregation) {
  1225. _that.isAggregationLayers.addLayer(marker)
  1226. _that.radiusLayers.push(_that.polygon)
  1227. this.map.addLayer(_that.isAggregationLayers)
  1228. _that.isAggregationMyGroup = window.L.layerGroup(_that.radiusLayers)
  1229. this.map.addLayer(_that.isAggregationMyGroup)
  1230. } else {
  1231. _that.layers.push(marker)
  1232. _that.layers.push(_that.polygon)
  1233. _that.myGroup = window.L.layerGroup(_that.layers)
  1234. this.map.addLayer(_that.myGroup)
  1235. }
  1236. }
  1237. },
  1238. setConnectList: function(connectList, color) { //地图画线
  1239. const _that = this
  1240. let points = []
  1241. for (let i = 0; i < connectList.length; i++) {
  1242. points.push([connectList[i].lat, connectList[i].lng]) //创建点
  1243. }
  1244. let polyline = window.L.polyline(points, {
  1245. color: color
  1246. })
  1247. if (this.connectLayer != undefined && this.connectLayer != false) {
  1248. _that.connectLayer.addLayer(polyline)
  1249. } else {
  1250. _that.connectLayer = window.L.featureGroup().addTo(this.map)
  1251. _that.connectLayer.addLayer(polyline)
  1252. }
  1253. },
  1254. setConnectTwoList: function(connectList, color) { //地图画线图层2
  1255. const _that = this
  1256. let points = []
  1257. for (let i = 0; i < connectList.length; i++) {
  1258. points.push([connectList[i].lat, connectList[i].lng]) //创建点
  1259. }
  1260. let polyline = window.L.polyline(points, {
  1261. color: color
  1262. })
  1263. if (this.connectLayerTwo != undefined && this.connectLayerTwo != false) {
  1264. _that.connectLayerTwo.addLayer(polyline)
  1265. } else {
  1266. _that.connectLayerTwo = window.L.featureGroup().addTo(this.map)
  1267. _that.connectLayerTwo.addLayer(polyline)
  1268. }
  1269. },
  1270. setGraphicsList: function(graphicsList, color) { //地图图形
  1271. const _that = this
  1272. let points = []
  1273. for (let i = 0; i < graphicsList.length; i++) {
  1274. points.push([graphicsList[i].lat, graphicsList[i].lng]) //创建点
  1275. }
  1276. let polygon = window.L.polygon(points, {
  1277. color: color
  1278. })
  1279. polygon.addTo(this.map)
  1280. if (this.graphicsLayer != undefined && this.graphicsLayer != false) {
  1281. _that.graphicsLayer.addLayer(polygon)
  1282. } else {
  1283. _that.graphicsLayer = window.L.featureGroup().addTo(this.map)
  1284. _that.graphicsLayer.addLayer(polygon)
  1285. }
  1286. },
  1287. setGraphicsListTwo: function(graphicsList, color) { //地图图形(林业植树造林双图层用)
  1288. const _that = this
  1289. let points = []
  1290. for (let i = 0; i < graphicsList.length; i++) {
  1291. points.push([graphicsList[i].lat, graphicsList[i].lng]) //创建点
  1292. }
  1293. let polygon = window.L.polygon(points, {
  1294. color: color
  1295. })
  1296. polygon.addTo(this.map)
  1297. if (this.graphicsLayerTwo != undefined && this.graphicsLayerTwo != false) {
  1298. _that.graphicsLayerTwo.addLayer(polygon)
  1299. } else {
  1300. _that.graphicsLayerTwo = window.L.featureGroup().addTo(this.map)
  1301. _that.graphicsLayerTwo.addLayer(polygon)
  1302. }
  1303. },
  1304. dropLocation: function(lat, lng) { //落点定位
  1305. this.map.flyTo([lat, lng], 13, {
  1306. duration: 2
  1307. })
  1308. },
  1309. dropLocation: function(lat, lng,leve) { //落点定位
  1310. this.map.flyTo([lat, lng], leve, {
  1311. duration: 2
  1312. })
  1313. },
  1314. dropLocation10: function(lat, lng) { //落点定位
  1315. this.map.flyTo([lat, lng], 10, {
  1316. duration: 2
  1317. })
  1318. },
  1319. dropLocation5: function(lat, lng) { //落点定位
  1320. this.map.flyTo([lat, lng], 5, {
  1321. duration: 2
  1322. })
  1323. },
  1324. controlLevel: function(level) { //控制地图缩放级别
  1325. this.map.setZoom(level)
  1326. },
  1327. layerSwitching: function(url, isClear) { //图层切换 url 图层地址 isClear 是否清除图层
  1328. if (isClear) {
  1329. if (this.deckglLayer != null) {
  1330. this.deckglLayer.remove()
  1331. }
  1332. }
  1333. if (url != null) {
  1334. this.deckglLayer = window.L.supermap.tiledMapLayer(url, {})
  1335. this.map.addLayer(this.deckglLayer)
  1336. }
  1337. },
  1338. layerSwitchingList: function(urlList) { //图层切换数组 urlList 图层地址(数组)
  1339. if (this.deckglLayerList != null && this.deckglLayerList.length > 0) {
  1340. for (let i = 0; i < this.deckglLayerList.length; i++) {
  1341. this.deckglLayerList[i].remove()
  1342. }
  1343. }
  1344. if (urlList != null && urlList.length > 0) {
  1345. for (let i = 0; i < urlList.length; i++) {
  1346. if (urlList[i] != null) {
  1347. this.deckglLayer = window.L.supermap.tiledMapLayer(urlList[i], {})
  1348. this.deckglLayerList.push(this.deckglLayer)
  1349. this.map.addLayer(this.deckglLayer)
  1350. }
  1351. }
  1352. }
  1353. },
  1354. /** -------------------------------图层地址(数组) 带数据图层---开始------------------------------- */
  1355. layerSwitchingList_Data: function(banCheckList) { //图层切换数组 urlList 图层地址(数组) 带数据图层
  1356. let that = this
  1357. that.initInfoView();
  1358. //清除图层,遍历图层多次清除
  1359. if(that.lbtThemeLayer != null){
  1360. that.map.eachLayer(function(layer){
  1361. if(layer.name == "lbtThemeLayer"){
  1362. that.map.removeLayer(that.lbtThemeLayer);
  1363. }
  1364. console.log(layer.name);
  1365. });
  1366. }
  1367. // 定义 Unique 单值专题图层
  1368. that.lbtThemeLayer = window.L.supermap.uniqueThemeLayer("lbtThemeLayer", {
  1369. // 开启 hover 高亮效果
  1370. isHoverAble: true,
  1371. opacity: 0.6,
  1372. alwaysMapCRS: true
  1373. }).addTo(that.map);
  1374. // 图层基础样式
  1375. that.lbtThemeLayer.style = new SuperMap.ThemeStyle({
  1376. shadowBlur: 3,
  1377. shadowColor: "#000000",
  1378. shadowOffsetX: 1,
  1379. shadowOffsetY: 1,
  1380. fillColor: "#ff4400",
  1381. fillOpacity: 0
  1382. });
  1383. // hover 高亮样式
  1384. that.lbtThemeLayer.highlightStyle = new SuperMap.ThemeStyle({
  1385. stroke: true,
  1386. strokeWidth: 2,//线宽
  1387. strokeColor: '#0ff',//线色
  1388. fillColor: "#09f",//面色
  1389. fillOpacity: 0.3//透明度
  1390. });
  1391. that.lbtThemeLayer.on("mousemove", that.lbtHighLightLayer);
  1392. /*that.lbtThemeLayer.on('dblclick', function(e) {
  1393. that.showBanData = true
  1394. var fea = that.lbtThemeLayer.getFeatureById(e.target.refDataID);
  1395. that.banDataList = fea.attributes
  1396. })*/
  1397. /*that.lbtThemeLayer.on('dblclick', function(e) {
  1398. var fea = that.lbtThemeLayer.getFeatureById(e.target.refDataID);
  1399. var smid = fea.attributes.SMID;
  1400. getCenterdataTSupermapBlockBySmID(smid).then(res => {
  1401. that.banDataList = res.data;
  1402. that.showBanData = true
  1403. });
  1404. })*/
  1405. that.lbtThemeLayer.on('dblclick', function(e) {
  1406. var fea = that.lbtThemeLayer.getFeatureById(e.target.refDataID);
  1407. that.queryParams.smid = fea.attributes.SMID;
  1408. that.queryParams.bsm = fea.attributes.BSM;
  1409. that.queryParams.tbbh = fea.attributes.TBBH;
  1410. console.log("this.queryParams" + that.queryParams)
  1411. getCenterdataTSupermapBlockBySBT(that.queryParams).then(res => {
  1412. that.banDataList = res.data;
  1413. that.showBanData = true
  1414. });
  1415. })
  1416. //清除地图图层
  1417. if (that.deckglLayerList_Data != null && that.deckglLayerList_Data.length > 0) {
  1418. for (let i = 0; i < that.deckglLayerList_Data.length; i++) {
  1419. that.deckglLayerList_Data[i].remove()
  1420. }
  1421. }
  1422. //清除数据图层
  1423. if (that.resultLayer_Data != null && that.resultLayer_Data.length > 0) {
  1424. for (let i = 0; i < that.resultLayer_Data.length; i++) {
  1425. that.resultLayer_Data[i].remove()
  1426. }
  1427. }
  1428. if (banCheckList != null && banCheckList.length > 0) {
  1429. for (let i = 0; i < banCheckList.length; i++) {
  1430. that.deckglLayer = window.L.supermap.tiledMapLayer(banCheckList[i].supermapAddress, {})
  1431. that.deckglLayerList_Data.push(that.deckglLayer)
  1432. that.map.addLayer(that.deckglLayer)
  1433. if (banCheckList[i].supermapAddress != null) {
  1434. var getFeatureBySQLParams = new SuperMap.GetFeaturesBySQLParameters({
  1435. queryParameter: {
  1436. name: banCheckList[i].name,
  1437. },
  1438. datasetNames: [banCheckList[i].datasetNames],
  1439. maxFeatures:20000,
  1440. fromIndex: 0,
  1441. toIndex: 999999
  1442. })
  1443. selectConfigKey('superMap.iserver.data').then(res => {
  1444. window.L.supermap.featureService(res.data)
  1445. .getFeaturesBySQL(getFeatureBySQLParams, function(serviceResult) {
  1446. if (serviceResult.hasOwnProperty('result') && serviceResult.result
  1447. .hasOwnProperty('features')) {
  1448. that.lbtThemeLayer.addFeatures(serviceResult.result.features);
  1449. }
  1450. }, SuperMap.DataFormat.ISERVER);
  1451. })
  1452. }
  1453. }
  1454. }
  1455. },
  1456. lbtHighLightLayer :function(e){
  1457. if (e.target && e.target.refDataID) {
  1458. var fea = this.lbtThemeLayer.getFeatureById(e.target.refDataID);
  1459. if (fea) {
  1460. //此处写信息渲染代码
  1461. }
  1462. } else if (this.lbtInfoView) {
  1463. this.lbtInfoView.remove();
  1464. }
  1465. },
  1466. //高亮时显示图层信息框的控件
  1467. initInfoView :function() {
  1468. this.infoView = window.L.control({position: 'bottomleft'});
  1469. this.infoView.onAdd = function () {
  1470. this._div = window.L.DomUtil.create('div', 'panel panel-primary infoPane');
  1471. $(this._div).css("width", "150px");
  1472. $("<div class='panel-heading'><h5 class='panel-title text-center'>林场信息</h5></div>").appendTo(this._div);
  1473. var content = $("<div class='panel-body content'></div>").appendTo(this._div);
  1474. content.css('fontSize', '14px');
  1475. handleMapEvent(this._div, this._map);
  1476. return this._div;
  1477. };
  1478. this.infoView.update = function (fea) {
  1479. var content = $(".content");
  1480. content.text("");
  1481. if (!fea) {
  1482. return;
  1483. }
  1484. var car_count = parent.$("#"+fea.attributes.SMID).val();
  1485. if(car_count == undefined){
  1486. car_count =0;
  1487. }
  1488. console.log(fea.attributes.SMID);
  1489. }
  1490. },
  1491. /** -------------------------------图层地址(数组) 带数据图层---结束------------------------------- */
  1492. /** ----------------------------------动态绘制开始------------------------------------- */
  1493. clearLayers: function() {
  1494. this.plottingLayer.removeAllFeatures()
  1495. },
  1496. PlottingDrawCancel: function() {
  1497. this.plottingdrawControl.handler.disable()
  1498. },
  1499. dynamicPlotting: function() {
  1500. setTimeout(() => {
  1501. selectConfigKey('superMap.iserver.plot').then(res => {
  1502. var host = res.data
  1503. var serverUrl = host + '/iserver/services/plot-jingyong/rest/plot/'
  1504. var me = this
  1505. this.plottingLayer = window.L.supermap.plotting.plottingLayer('plot',
  1506. serverUrl)
  1507. this.plottingLayer.spatialAnalystUrl =
  1508. host + '/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst'
  1509. this.plottingLayer.addTo(this.map)
  1510. this.plottingdrawControl = window.L.supermap.plotting.drawControl(this
  1511. .plottingLayer)
  1512. this.plottingdrawControl.addTo(this.map)
  1513. var editControl = window.L.supermap.plotting.editControl()
  1514. editControl.addTo(this.map)
  1515. window.L.supermap.plotting.initPlotPanel('plotPanel', serverUrl, this
  1516. .plottingdrawControl)
  1517. })
  1518. }, 2000)
  1519. }
  1520. /** ----------------------------------动态绘制结束------------------------------------- */
  1521. }
  1522. }
  1523. </script>
  1524. <style lang="scss" scoped>
  1525. @import '@/assets/styles/base.scss';
  1526. .panel {
  1527. margin-bottom: .5rem;
  1528. button {
  1529. margin-top: .5rem;
  1530. }
  1531. .input-group {
  1532. display: flex;
  1533. flex-direction: row;
  1534. align-items: center;
  1535. .input-group-addon {
  1536. color: $inBlue;
  1537. width: 3rem;
  1538. text-align: right;
  1539. }
  1540. .form-control {
  1541. padding: 0 .3rem;
  1542. margin-left: .5rem;
  1543. height: 1.5rem;
  1544. line-height: 1.5rem;
  1545. background-color: #112543;
  1546. color: $inBlue;
  1547. border: 1px $searchBorder;
  1548. }
  1549. }
  1550. }
  1551. .button-group {
  1552. button {
  1553. padding: 0 0.3rem;
  1554. height: 1.5rem;
  1555. background-color: #112543;
  1556. color: #2bacf7;
  1557. border: 1px solid #33467f;
  1558. }
  1559. button:hover {
  1560. border: 1px solid #33467f;
  1561. background-color: #112543;
  1562. text-shadow: 0 0 15px rgba($color: $inBlueHover, $alpha: 1.0);
  1563. }
  1564. }
  1565. </style>