bigeHeatSunMap.vue 31 KB

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