zaiXianBigeMap.vue 29 KB

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