bigeMap.vue 30 KB

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