bigeHeatMap.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  1. <template>
  2. <div>
  3. <div id='map'></div>
  4. <div id="position">
  5. <div id="zoom">
  6. 当前级别 : 6
  7. </div>
  8. <div id="move">
  9. 当前中心点: 纬度:0.00000,经度:0.00000
  10. </div>
  11. </div>
  12. <div style="position: fixed;bottom: 8%;left:.5%;z-index: 1000;box-shadow: rgb(56 76 85) 0px 1px 9px 4px inset">
  13. <img src="../../../../public/largeScreenImg/80mWs1.png">
  14. </div>
  15. <!-- <el-radio-group v-model="leavel" @change="setData">-->
  16. <!-- <el-radio class="radio" label="100">100Mb</el-radio>-->
  17. <!-- <el-radio class="radio" label="250">250Mb</el-radio>-->
  18. <!-- <el-radio class="radio" label="500">500Mb</el-radio>-->
  19. <!-- <el-radio class="radio" label="1000">1000Mb</el-radio>-->
  20. <!-- </el-radio-group>-->
  21. </div>
  22. </template>
  23. <script>
  24. import bigemap from '@/utils/bigemap/map'
  25. import Tiff from "tiff.js";
  26. import axios from "axios";
  27. let map;
  28. export default {
  29. name: "bigeMap",
  30. props: {mapValue: Object},
  31. watch: {
  32. mapValue: {
  33. immediate: true,
  34. handler(value) {
  35. if (value.params !== undefined) {
  36. console.log("热力图:" + value)
  37. this.mapData = value
  38. this.initBigeMap()
  39. }
  40. }
  41. }
  42. },
  43. data() {
  44. return {
  45. bMap: null,
  46. velocityLayer: null,
  47. leavel: {},
  48. latlngs: [[[0.0, 0.0], [0.0, 0.0]]],
  49. cone: {},
  50. mTime: null,
  51. code: 230000,
  52. mapData: {},// 传过来的值
  53. href: window.location.href,
  54. level: 6,
  55. center: [],
  56. }
  57. },
  58. mounted() {
  59. },
  60. methods: {
  61. initBigeMap() {
  62. let _self = this
  63. bigemap.then(() => {
  64. // window.BM.Config.HTTP_URL = 'http://www.bigemap.com:9000';
  65. //window.BM.Config.HTTP_URL = 'http://10.124.252.243:9000';
  66. window.BM.Config.HTTP_URL = process.env.VUE_APP_GIS_API;
  67. let ip1 = process.env.VUE_APP_GIS_API;
  68. let ip2 = 'http://49.4.78.194:17143';
  69. // window.BM.Config.HTTP_URL = 'http://localhost:9000';
  70. // let ip1 = 'http://localhost:9000';
  71. // let ip2 = 'http://localhost:9000';
  72. let mapid = 'bigemap.re-huafu'
  73. // window.BM.Config.HTTP_URL = 'http://192.168.1.181:9000';
  74. // arcgis-satellite
  75. // amap-satellite
  76. // zhongkexingtu
  77. let map = window.BM.map('map', null, {
  78. center: [30, 104],
  79. minZoom: 6,
  80. maxZoom: 12,
  81. zoom: 11,
  82. zoomControl: true,
  83. attributionControl: false,
  84. preferCanvas: true, //适用于数据量大时 地图反应速度加快
  85. });
  86. var promise = fetch(`${ip1}/tokens/v1?access_token=none`).then(function (response) {
  87. return response.json();
  88. }).then(function (body) {
  89. return body.token
  90. }).then(
  91. (token) => {
  92. var CanvasLayer = BM.GridLayer.extend({
  93. createTile: function (coords, done) {
  94. let error;
  95. let {
  96. x,
  97. y,
  98. z
  99. } = coords;
  100. let tile = new Image;
  101. tile.style.backgroundColor = 'inherit';
  102. tile.src = `${ip2}/${mapid}/tiles/${z}/${x}/${y}.png?access_token=${token}`
  103. setTimeout(function () {
  104. done(error, tile);
  105. return null
  106. }, 1000);
  107. return tile;
  108. }
  109. });
  110. new CanvasLayer({maxZoom: 12}).addTo(map);
  111. }
  112. )
  113. window.Bmap = map;
  114. // var layer1=window.BM.tileLayer('bigemap.re-huafu')
  115. //var layer2=window.BM.tileLayer('bigemap.heatMapWs',{opacity:0.7});
  116. let heatmapid = 'bigemap.heatMapWs';
  117. // let heatmapid = 'bigemap.900gyz4b';
  118. fetch(`${ip1}/tokens/v1?access_token=none`).then(function (response) {
  119. return response.json();
  120. }).then(function (body) {
  121. return body.token
  122. }).then(
  123. (token) => {
  124. var CanvasLayer = BM.GridLayer.extend({
  125. createTile: function (coords, done) {
  126. let error;
  127. let {
  128. x,
  129. y,
  130. z
  131. } = coords;
  132. let tile = new Image;
  133. tile.style.backgroundColor = 'inherit';
  134. tile.src = `${ip2}/${heatmapid}/tiles/${z}/${x}/${y}.png?access_token=${token}`
  135. // 给热力图图层加上错误处理事件
  136. // offline.on('tileerror',(e)=>{
  137. // e.tile.remove()
  138. // })
  139. tile.onerror = function () {
  140. tile.remove()
  141. }
  142. setTimeout(function () {
  143. done(error, tile);
  144. return null
  145. }, 1000);
  146. return tile;
  147. }
  148. });
  149. new CanvasLayer({
  150. maxNativeZoom: 8,
  151. maxZoom: 12,
  152. opacity: 0.7
  153. }).addTo(map);
  154. }
  155. )
  156. // map.setMaxZoom(12);
  157. // layer1.addTo(map);
  158. this.bMap = map;
  159. setTimeout(() => {
  160. // Object.assign(layer2.options,{
  161. // maxNativeZoom:8,
  162. // maxZoom:12
  163. // })
  164. if (this.mapData.center.length !== 0) {
  165. _self.level = this.mapData.level
  166. _self.center = this.mapData.center
  167. this.bMap.setView(this.mapData.center, this.mapData.level)
  168. } else {
  169. this.bMap.setView([46.69090, 128.13354], 7)
  170. }
  171. }, 500)
  172. // layer2.addTo(map);
  173. // 热力图是有8级需合并两个图层
  174. // var layer = window.BM.tileLayer('bigemap.0utmz6qt', {opacity: 0.7}).addTo(map).on('load', function () {
  175. // layer.options.maxNativeZoom = 8;
  176. // layer.options.maxZoom = 12;
  177. // map.setMaxZoom(12);
  178. // })
  179. //首尾需要一致
  180. let mask = window.BMturf.polygon([[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]);
  181. let geo2;
  182. fetch('/js/geojson/230000/' + this.code + '.geojson').then(res => res.json()).then(data => {
  183. // fetch('/js/geojson/' + this.code + '.geojson').then(res => res.json()).then(data => {
  184. geo2 = window.BM.geoJSON(data, {
  185. style: function () {
  186. return {
  187. color: '#ffffff',
  188. weight: 3,
  189. fillColor: '#ffffff',
  190. fillOpacity: 0.1
  191. };
  192. },
  193. onEachFeature: function (feature, layer) {
  194. feature.properties && feature.properties.name && layer.bindTooltip(feature.properties.name, {
  195. direction: 'bottom',
  196. className: 'my_tooltip',
  197. permanent: true
  198. });
  199. }
  200. }).on('mouseover', function (e) {
  201. e.layer.setStyle({
  202. color: '#ffffff',
  203. weight: 1,
  204. fillColor: 'transparent',
  205. fillOpacity: 0.9
  206. });
  207. }).on('mouseout', function (e) {
  208. e.layer.setStyle({
  209. color: '#ffffff',
  210. weight: 3,
  211. fillColor: '#ffffff',
  212. fillOpacity: 0.2
  213. });
  214. }).addTo(this.bMap);
  215. window.geo2 = geo2;
  216. //限制拖动
  217. this.bMap.setMaxBounds([[43.42301, 122.574976], [53.561657, 135.086264]]);
  218. this.bMap.fitBounds([[43.42301, 122.574976], [53.561657, 135.086264]]);
  219. const layers = geo2.getLayers();
  220. for (const item of layers) {
  221. const layer = item.feature;
  222. mask = window.BMturf.mask(layer, mask);
  223. }
  224. window.BM.geoJSON(mask, {
  225. color: 'orange',
  226. fillColor: '#0A163A',
  227. fillOpacity: 0.7
  228. }).addTo(this.bMap);
  229. //初始化热力图
  230. // this.setHeatMap(this.bMap);
  231. //绑定事件
  232. this.bindEvents(this.bMap);
  233. })
  234. let sIconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/station.png'
  235. let hfSIconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/huafuStation.png'
  236. let pIconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/project.png'
  237. let fjIconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/img/fengji.png'
  238. let gfbconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/guangfuban.png'
  239. let gfsconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/guang.png'
  240. let gfhfconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/huafuguangfu.png'
  241. let fengjiblue = 'http://' + _self.href.split("//")[1].split("/")[0] + '/img/fengji/fengjiblue.png'
  242. let fengjigreen = 'http://' + _self.href.split("//")[1].split("/")[0] + '/img/fengji/fengjigreen.png'
  243. let fengjiyellow = 'http://' + _self.href.split("//")[1].split("/")[0] + '/img/fengji/fengjiyellow.png'
  244. let fengjired = 'http://' + _self.href.split("//")[1].split("/")[0] + '/img/fengji/fengjired.png'
  245. let iconUrl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/huanjingjianceyi.png'
  246. let nIconUrl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/nibianqi.png'
  247. // 所有场站标记点位
  248. if (this.mapData.allStationInfo !== null && this.mapData.allStationInfo !== undefined) {
  249. let data = this.mapData.allStationInfo
  250. let station_icon = window.BM.icon({
  251. iconUrl: sIconurl,
  252. iconSize: [25, 43],
  253. iconAnchor: [25, 43]
  254. })
  255. let hf_station_icon = window.BM.icon({
  256. iconUrl: hfSIconurl,
  257. iconSize: [33, 55],
  258. iconAnchor: [33, 55]
  259. })
  260. let gfstation_icon = window.BM.icon({
  261. iconUrl: iconUrl,
  262. iconSize: [25, 43],
  263. iconAnchor: [25, 43]
  264. })
  265. let hf_gfstation_icon = window.BM.icon({
  266. iconUrl: gfhfconurl,
  267. iconSize: [33, 55],
  268. iconAnchor: [33, 55]
  269. })
  270. for (let item of data.otherStation) {
  271. let coordinate = [Number(item.latitude), Number(item.longitude)]
  272. let marker = '';
  273. if (item.type === '风') {
  274. marker = window.BM.marker(coordinate, {
  275. icon: station_icon,
  276. riseOnHover: true
  277. }).addTo(this.bMap);
  278. } else {
  279. marker = window.BM.marker(coordinate, {
  280. icon: gfstation_icon,
  281. riseOnHover: true
  282. }).addTo(this.bMap);
  283. }
  284. marker.on('mouseover', function (e) {
  285. marker.bindTooltip('<div>场站名称:' + item.stationName + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  286. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  287. })
  288. marker.on('mouseout', function () {
  289. marker.bindTooltip().closeTooltip();
  290. })
  291. }
  292. for (let item of data.HDStation) {
  293. let coordinate = [Number(item.latitude), Number(item.longitude)]
  294. let marker = '';
  295. if (item.type === '风') {
  296. marker = window.BM.marker(coordinate, {
  297. icon: hf_station_icon,
  298. riseOnHover: true
  299. }).addTo(this.bMap);
  300. } else {
  301. marker = window.BM.marker(coordinate, {
  302. icon: hf_gfstation_icon,
  303. riseOnHover: true
  304. }).addTo(this.bMap);
  305. }
  306. marker.on('mouseover', function (e) {
  307. marker.bindTooltip('<div>场站名称:' + item.stationName + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  308. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  309. })
  310. marker.on('mouseout', function () {
  311. marker.bindTooltip().closeTooltip();
  312. })
  313. }
  314. }
  315. // 项目标记点位
  316. if (this.mapData.projectInfo !== null && this.mapData.projectInfo !== undefined) {
  317. let data = this.mapData.projectInfo
  318. let station_icon = window.BM.icon({
  319. iconUrl: pIconurl,
  320. iconSize: [30, 50],
  321. iconAnchor: [30, 50]
  322. })
  323. let gf_icon = window.BM.icon({
  324. iconUrl: gfbconurl,
  325. iconSize: [30, 50],
  326. iconAnchor: [30, 50]
  327. })
  328. for (let item of data) {
  329. if (item.latitude !== undefined) {
  330. let coordinate = [Number(item.latitude), Number(item.longitude)]
  331. let marker = '';
  332. if (item.type === '风') {
  333. marker = window.BM.marker(coordinate, {
  334. icon: station_icon,
  335. riseOnHover: true
  336. }).addTo(this.bMap);
  337. } else {
  338. marker = window.BM.marker(coordinate, {
  339. icon: gf_icon,
  340. riseOnHover: true
  341. }).addTo(this.bMap);
  342. }
  343. // 悬浮动作
  344. marker.on('mouseover', function (e) {
  345. marker.bindTooltip('<div>项目名称:' + item.projectNameEasy + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  346. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  347. })
  348. marker.on('mouseout', function () {
  349. marker.bindTooltip().closeTooltip();
  350. })
  351. // 点击动作
  352. marker.on('click', function (e) {
  353. let project = {id: item.id, projectSort: item.projectName}
  354. sessionStorage.setItem("projectInfo", JSON.stringify(project))
  355. _self.$store.dispatch('equipmentInfo/projectInfo', JSON.stringify(project))
  356. _self.$router.push({path: "/homepage/projectInfo"})
  357. })
  358. }
  359. }
  360. }
  361. // 华富场站标记点位
  362. if (this.mapData.staionInfo !== null && this.mapData.staionInfo !== undefined) {
  363. let data = this.mapData.staionInfo
  364. let station_icon = window.BM.icon({
  365. iconUrl: sIconurl,
  366. iconSize: [30, 50],
  367. iconAnchor: [30, 50],
  368. className: 'stationIcon',
  369. })
  370. let hf_gfstation_icon = window.BM.icon({
  371. iconUrl: gfhfconurl,
  372. iconSize: [30, 50],
  373. iconAnchor: [30, 50],
  374. })
  375. for (let item of data) {
  376. let coordinate = [Number(item.latitude), Number(item.longitude)]
  377. let marker = ''
  378. if (item.type === '风') {
  379. marker = window.BM.marker(coordinate, {
  380. icon: station_icon,
  381. riseOnHover: true
  382. }).addTo(this.bMap);
  383. } else {
  384. marker = window.BM.marker(coordinate, {
  385. icon: hf_gfstation_icon,
  386. riseOnHover: true
  387. }).addTo(this.bMap);
  388. }
  389. // 悬浮动作
  390. marker.on('mouseover', function (e) {
  391. marker.bindTooltip('<div>场站名称:' + item.stationName + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  392. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  393. })
  394. marker.on('mouseout', function () {
  395. marker.bindTooltip().closeTooltip();
  396. })
  397. // 点击动作
  398. marker.on('click', function (e) {
  399. let station = {id: item.id, stationName: item.stationName}
  400. sessionStorage.setItem("stationInfo", JSON.stringify(station))
  401. _self.$store.dispatch('equipmentInfo/stationInfo', JSON.stringify(station))
  402. _self.$router.push({path: "/homepage/stationInfo"})
  403. })
  404. }
  405. }
  406. // 所有风机、塔、拐点标记点位
  407. // console.log(this.mapData.allPointInfo)
  408. if (this.mapData.allPointInfo !== null && this.mapData.allPointInfo !== undefined) {
  409. let data = this.mapData.allPointInfo
  410. let station_icon = window.BM.icon({
  411. iconUrl: pIconurl,
  412. iconSize: [35, 55],
  413. iconAnchor: [35, 55],
  414. className: 'stationIcon',
  415. })
  416. let huanjingjianceyi = window.BM.icon({
  417. iconUrl: iconUrl,
  418. iconSize: [35, 55],
  419. iconAnchor: [35, 55],
  420. className: 'stationIcon',
  421. })
  422. let nibianqi = window.BM.icon({
  423. iconUrl: nIconUrl,
  424. iconSize: [35, 55],
  425. iconAnchor: [35, 55],
  426. className: 'stationIcon',
  427. })
  428. let redFengji = window.BM.icon({
  429. iconUrl: fengjired,
  430. iconSize: [30, 30],
  431. iconAnchor: [30, 30],
  432. className: 'stationIcon',
  433. })
  434. let bluefengji = window.BM.icon({
  435. iconUrl: fengjiblue,
  436. iconSize: [30, 30],
  437. iconAnchor: [30, 30],
  438. className: 'stationIcon',
  439. })
  440. let defaultFengji = window.BM.icon({
  441. iconUrl: fjIconurl,
  442. iconSize: [30, 30],
  443. iconAnchor: [30, 30],
  444. className: 'stationIcon',
  445. })
  446. let fj_icon = [{
  447. icon: window.BM.icon({
  448. iconUrl: fengjigreen,
  449. iconSize: [30, 30],
  450. iconAnchor: [30, 30],
  451. className: 'stationIcon',
  452. })
  453. }, {
  454. icon: window.BM.icon({
  455. iconUrl: fengjiyellow,
  456. iconSize: [30, 30],
  457. iconAnchor: [30, 30],
  458. className: 'stationIcon',
  459. })
  460. }]
  461. /*环境监测仪*/
  462. for (let item of data.weather) {
  463. let coordinate = [Number(item.latitude), Number(item.longitude)]
  464. let marker = window.BM.marker(coordinate, {
  465. icon: huanjingjianceyi,
  466. riseOnHover: true
  467. }).addTo(this.bMap);
  468. marker.on('mouseover', function (e) {
  469. // console.log(item)
  470. marker.bindTooltip('<div>环境监测仪名称:' + item.name + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  471. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  472. })
  473. marker.on('mouseout', function () {
  474. marker.bindTooltip().closeTooltip();
  475. })
  476. // 点击动作
  477. marker.on('click', function (e) {
  478. let station = {stationId: item.stationId, equipmentNo: item.id}
  479. sessionStorage.setItem("realPvWindTowerInfo", JSON.stringify(station))
  480. _self.$store.dispatch('equipmentInfo/realPvWindTowerInfo', JSON.stringify(station))
  481. _self.$router.push({path: "/homepage/realPvResourcesInfo"})
  482. })
  483. }
  484. /*逆变器*/
  485. for (let inverter of data.inverter) {
  486. for (let item of inverter.data) {
  487. let coordinate = [Number(item.latitude), Number(item.longitude)]
  488. let marker = window.BM.marker(coordinate, {
  489. icon: nibianqi,
  490. riseOnHover: true
  491. }).addTo(this.bMap);
  492. marker.on('mouseover', function (e) {
  493. // console.log(item)
  494. marker.bindTooltip('<div>所属场站名称:' + inverter.name + '</div>' + '<div>逆变器名称:' + item.name + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  495. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  496. })
  497. marker.on('mouseout', function () {
  498. marker.bindTooltip().closeTooltip();
  499. })
  500. }
  501. }
  502. let i = 0
  503. for (let fan of data.fan) {
  504. if (i > 1) i = 0
  505. for (let item of fan.data) {
  506. let coordinate = [Number(item.latitudeFan), Number(item.longitudeFan)]
  507. let marker = ''
  508. if (fan.type === 'project') {
  509. marker = window.BM.marker(coordinate, {
  510. icon: redFengji,
  511. riseOnHover: true
  512. }).addTo(this.bMap);
  513. } else {
  514. if (item.type !== null) {
  515. if (item.type === '新') {
  516. marker = window.BM.marker(coordinate, {
  517. icon: defaultFengji,
  518. riseOnHover: true
  519. }).addTo(this.bMap);
  520. } else {
  521. marker = window.BM.marker(coordinate, {
  522. icon: bluefengji,
  523. riseOnHover: true
  524. }).addTo(this.bMap);
  525. }
  526. } else {
  527. // console.log(i)
  528. marker = window.BM.marker(coordinate, {
  529. icon: fj_icon[i].icon,
  530. riseOnHover: true
  531. }).addTo(this.bMap);
  532. }
  533. }
  534. marker.on('mouseover', function (e) {
  535. // console.log(item)
  536. if (fan.type === 'project') {
  537. marker.bindTooltip('<div>项目预设风机点位:</div>' + '<div>所属项目名称:' + fan.name + '</div>' + '<div>经度:' + item.longitudeFan + '</div>' + '<div>纬度:' + item.latitudeFan + '</div>',
  538. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  539. } else {
  540. marker.bindTooltip('<div>所属场站名称:' + fan.name + '</div>' + '<div>经度:' + item.longitudeFan + '</div>' + '<div>纬度:' + item.latitudeFan + '</div>' + '<div>机型:' + item.fanModel + '</div>',
  541. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  542. }
  543. })
  544. marker.on('mouseout', function () {
  545. marker.bindTooltip().closeTooltip();
  546. })
  547. }
  548. i++
  549. }
  550. for (let coordinatesList of data.coordinatesList) {
  551. for (let key in coordinatesList) {
  552. let coordinates = coordinatesList[key]
  553. if (coordinates !== null) {
  554. for (let item of coordinates) {
  555. if (item.length > 0) {
  556. let latlngs = []
  557. for (let coor of item) {
  558. latlngs.push([Number(coor.latitude), Number(coor.longitude)])
  559. // window.BM.marker([Number(coor.latitude), Number(coor.longitude)]).addTo(this.bMap);
  560. }
  561. var polygon = BM.polygon(latlngs).addTo(this.bMap);
  562. polygon.bindTooltip(key, {permanent: true, className: 'infoToolTip', offset: [0, 0]}).openTooltip();
  563. // 让地图适配当前的线段
  564. this.bMap.fitBounds(polygon.getBounds());
  565. }
  566. }
  567. }
  568. }
  569. }
  570. // 项目或者场站id
  571. let id = this.mapData.id
  572. for (let item of data.towerList) {
  573. let coordinate = [Number(item.latitude), Number(item.longitude)]
  574. let marker = window.BM.marker(coordinate, {
  575. icon: station_icon,
  576. riseOnHover: true
  577. }).addTo(this.bMap);
  578. // 悬浮动作
  579. marker.on('mouseover', function (e) {
  580. // console.log(item)
  581. if (item.type === 'project') {
  582. marker.bindTooltip('<div>测风塔名称:' + item.towerName + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  583. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  584. } else {
  585. marker.bindTooltip('<div>测风塔名称:' + item.towerName + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  586. {permanent: true, className: 'infoToolTip', offset: [0, -30]}).openTooltip();
  587. }
  588. })
  589. marker.on('mouseout', function () {
  590. marker.bindTooltip().closeTooltip();
  591. })
  592. // console.log(item.projectId)
  593. let projectId = item.projectId.find(w => w.id === id)
  594. // 点击动作
  595. marker.on('click', function (e) {
  596. if (projectId !== undefined && projectId !== null) {
  597. if (projectId.type === 'project') {
  598. let project = {projectId: id, equipmentNo: item.towerNo}
  599. sessionStorage.setItem("emailWindTowerInfo", JSON.stringify(project))
  600. _self.$store.dispatch('equipmentInfo/emailWindTowerInfo', JSON.stringify(project))
  601. _self.$router.push({path: "/homepage/emailResourcesInfo"})
  602. } else {
  603. let station = {stationId: id, equipmentNo: item.towerNo}
  604. sessionStorage.setItem("realWindTowerInfo", JSON.stringify(station))
  605. _self.$store.dispatch('equipmentInfo/realWindTowerInfo', JSON.stringify(station))
  606. _self.$router.push({path: "/homepage/realResourcesInfo"})
  607. }
  608. } else {
  609. if (item.projectId[0].type === 'project') {
  610. let project = {projectId: item.projectId[0].id, equipmentNo: item.towerNo}
  611. sessionStorage.setItem("emailWindTowerInfo", JSON.stringify(project))
  612. _self.$store.dispatch('equipmentInfo/emailWindTowerInfo', JSON.stringify(project))
  613. _self.$router.push({path: "/homepage/emailResourcesInfo"})
  614. } else {
  615. let station = {stationId: item.projectId[0].id, equipmentNo: item.towerNo}
  616. sessionStorage.setItem("realWindTowerInfo", JSON.stringify(station))
  617. _self.$store.dispatch('equipmentInfo/realWindTowerInfo', JSON.stringify(station))
  618. _self.$router.push({path: "/homepage/realResourcesInfo"})
  619. }
  620. }
  621. })
  622. }
  623. }
  624. /**
  625. * 加载实时气象源动画效果
  626. fetch("/js/json/wind_data/20230403_00_atmoslev_1000_mb.json")
  627. .then((res) => {
  628. return res.json();
  629. })
  630. .then((data) => {
  631. this.velocityLayer = window.BM.velocityLayer({
  632. displayValues: true,
  633. displayOptions: {
  634. velocityType: "windy",
  635. displayPosition: "topright",
  636. displayEmptyString: "没有数据",
  637. directionString: "风向",
  638. speedString: "速度",
  639. },
  640. data: data,
  641. minVelocity: 0.05,
  642. maxVelocity: 10,
  643. colorScale: ["red", "green", "yellow", "pink"],
  644. velocityScale: 0.02, // default 0.005,
  645. });
  646. this.velocityLayer.addTo(this.bMmap);
  647. });
  648. */
  649. })
  650. },
  651. //设置热力图效果
  652. setHeatMap(map) {
  653. axios.get("/img/heapmap/mean-wind-speed_rendering.tiff", {
  654. responseType: "arraybuffer",
  655. }).then((res) => {
  656. const fr = new FileReader();
  657. fr.onloadend = function (e) {
  658. var image = new Tiff({buffer: e.target.result});
  659. var imageUrl = image.toDataURL(),
  660. imageBounds = [
  661. [43.422993, 121.183134],
  662. [53.564656, 135.091461],
  663. ];
  664. window.imgOverlay = window.BM.imageOverlay(imageUrl, imageBounds).addTo(map);
  665. map.fitBounds(imageBounds);
  666. };
  667. fr.readAsArrayBuffer(new Blob([res.data]));
  668. });
  669. },
  670. //绑定事件-监听地图级别和拖动
  671. bindEvents(map) {
  672. let _self = this
  673. map.on('moveend', function (e) {
  674. const c = this.getCenter();
  675. _self.center = this.getCenter()
  676. document.getElementById('move').innerHTML = '当前中心点: 纬度:' + c.lat.toFixed(5) + ',经度:' + c.lng.toFixed(5);
  677. });
  678. //添加一个缩放事件
  679. map.on('zoomend', function (e) {
  680. _self.level = this.getZoom()
  681. _self.$emit('changeZoom', this.getZoom())
  682. document.getElementById('zoom').innerHTML = '当前级别 : ' + this.getZoom();
  683. });
  684. },
  685. setData(params) {
  686. fetch(`/js/json/wind_data/20230403_00_atmoslev_` + params + `_mb.json`)
  687. .then((res) => {
  688. return res.json();
  689. })
  690. .then((data) => {
  691. this.velocityLayer.options.displayOptions.velocityType = params + `Mb`;
  692. this.velocityLayer.setData(data);
  693. });
  694. },
  695. initRegion(code) {
  696. sessionStorage.clear();
  697. sessionStorage.setItem('latlngs', JSON.stringify(this.latlngs));
  698. this.chons(code)
  699. },
  700. //加载地图方法
  701. chons(code) {
  702. fetch('/js/geojson/230000/' + code + '.geojson')
  703. .then((res) => {
  704. return res.json();
  705. })
  706. .then((data) => {
  707. this.cone = this.BM.geoJSON(data, {
  708. style: function () {
  709. return {
  710. color: '#ffffff',
  711. fillColor: 'transparent',
  712. weight: 1,
  713. fillOpacity: 0.9
  714. };
  715. },
  716. }).on('mouseover', function (e) {
  717. const rel = e.layer.feature.properties;
  718. e.layer.setStyle({
  719. color: '#ffffff',
  720. fillColor: 'transparent',
  721. weight: 3,
  722. fillOpacity: 1
  723. });
  724. //显示弹窗信息坐标
  725. let x = rel.center['1'];
  726. let y = rel.center['0'];
  727. let coordinate = [[x, y]];
  728. //组装参数
  729. let adcode = rel.adcode;
  730. let name = rel.name;
  731. let level = rel.level;
  732. let cont =
  733. "<div>acode :" + adcode + "</div>" +
  734. "<div>name <span style='margin-left: 2px'>:</span>" + name + "</div>" +
  735. "<div>level <span style='margin-left: 7px'>:</span>" + level + "</div>";
  736. //显示弹窗
  737. if (!e.layer.getPopup()) {
  738. e.layer.bindPopup(cont);
  739. }
  740. e.layer.openPopup();
  741. }).on('mouseout', function (e) {
  742. e.layer.setStyle({
  743. color: '#ffffff',
  744. fillColor: 'transparent',
  745. weight: 1,
  746. fillOpacity: 0.9
  747. });
  748. // 点击地图区域向下钻取
  749. // }).on('click', (e) => {
  750. // const rel = e.layer.feature.properties;
  751. // const zb = e.layer._bounds;
  752. // if (code === rel.adcode) {
  753. // return false;
  754. // } else {
  755. // //定时器
  756. // clearTimeout(this.mTime);
  757. // this.mTime = setTimeout(() => {
  758. // //重新加载
  759. // this.chons(rel.adcode);
  760. // this.cone.remove();
  761. // //临时缓存
  762. // sessionStorage.setItem('diqu', JSON.stringify(rel.acroutes));
  763. // const latadd = sessionStorage.getItem('latlngs');
  764. // const lataddp = JSON.parse(latadd);
  765. // lataddp.push([[zb._northEast.lat, zb._northEast.lng], [zb._southWest.lat, zb._southWest.lng]]);
  766. // sessionStorage.setItem('latlngs', JSON.stringify(lataddp));
  767. // if (lataddp.slice(-1).length !== 0) {
  768. // this.bMap.fitBounds(lataddp.slice(-1));
  769. // }
  770. // }, 300);
  771. // }
  772. }).addTo(this.bMap);
  773. })
  774. }
  775. }
  776. }
  777. </script>
  778. <style>
  779. .infoToolTip {
  780. color: white !important;
  781. background: rgba(0, 133, 212, 0.75) !important;
  782. border: .5px solid #0085d4;
  783. }
  784. .my_tooltip {
  785. color: #0085d4 !important;
  786. background: transparent !important;
  787. border: none !important;
  788. /*font-size: 18px;*/
  789. }
  790. .my_tooltip::before {
  791. display: none;
  792. }
  793. </style>
  794. <style scoped>
  795. #map {
  796. width: 100%;
  797. height: calc(90vh);
  798. }
  799. .bigemap-popup-content-wrapper, .map-legends, .map-tooltip {
  800. border-radius: 8px;
  801. box-shadow: 5px 5px 5px rgb(0 0 0);
  802. }
  803. </style>