bigeHeatSunMap.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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://localhost:9000';
  67. // arcgis-satellite
  68. // amap-satellite
  69. // zhongkexingtu
  70. // let map = window.BM.map('map', 'bigemap.arcgis-satellite', {
  71. let map = window.BM.map('map', null, {
  72. center: [30, 104],
  73. minZoom: 6,
  74. zoom: 11,
  75. zoomControl: true,
  76. attributionControl: false,
  77. preferCanvas: true, //适用于数据量大时 地图反应速度加快
  78. });
  79. window.Bmap = map;
  80. var layer1=window.BM.tileLayer('bigemap.6914xxtx')
  81. var layer2=window.BM.tileLayer('bigemap.ct4z5ch5',{opacity:0.7});
  82. map.setMaxZoom(12);
  83. layer1.addTo(map);
  84. setTimeout(()=>{
  85. Object.assign(layer2.options,{
  86. opacity:0.7,
  87. maxNativeZoom:8,
  88. maxZoom:12
  89. })
  90. if (this.mapData.center.length !== 0) {
  91. _self.level = this.mapData.level
  92. _self.center = this.mapData.center
  93. this.bMap.setView(this.mapData.center, this.mapData.level)
  94. }
  95. },500)
  96. layer2.addTo(map);
  97. this.bMap = map;
  98. //首尾需要一致
  99. let mask = window.BMturf.polygon([[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]);
  100. let geo2;
  101. fetch('/js/geojson/230000/' + this.code + '.geojson').then(res => res.json()).then(data => {
  102. // fetch('/js/geojson/' + this.code + '.geojson').then(res => res.json()).then(data => {
  103. geo2 = window.BM.geoJSON(data, {
  104. style: function () {
  105. return {
  106. color: '#ffffff',
  107. weight: 3,
  108. fillColor: '#ffffff',
  109. fillOpacity: 0.1
  110. };
  111. },
  112. onEachFeature: function (feature, layer) {
  113. feature.properties && feature.properties.name && layer.bindTooltip(feature.properties.name, {
  114. direction: 'bottom',
  115. className: 'my_tooltip',
  116. permanent: true
  117. });
  118. }
  119. }).on('mouseover', function (e) {
  120. e.layer.setStyle({
  121. color: '#ffffff',
  122. weight: 1,
  123. fillColor: 'transparent',
  124. fillOpacity: 0.9
  125. });
  126. }).on('mouseout', function (e) {
  127. e.layer.setStyle({
  128. color: '#ffffff',
  129. weight: 3,
  130. fillColor: '#ffffff',
  131. fillOpacity: 0.2
  132. });
  133. }).addTo(this.bMap);
  134. window.geo2 = geo2;
  135. //限制拖动
  136. this.bMap.setMaxBounds(geo2.getBounds());
  137. this.bMap.fitBounds(geo2.getBounds());
  138. const layers = geo2.getLayers();
  139. for (const item of layers) {
  140. const layer = item.feature;
  141. mask = window.BMturf.mask(layer, mask);
  142. }
  143. window.BM.geoJSON(mask, {
  144. color: 'orange',
  145. fillColor: '#0A163A',
  146. fillOpacity: 0.7
  147. }).addTo(this.bMap);
  148. //初始化热力图
  149. // this.setHeatMap(this.bMap);
  150. //绑定事件
  151. this.bindEvents(this.bMap);
  152. })
  153. let sIconurl = 'http://'+_self.href.split("//")[1].split("/")[0]+'/largeScreenImg/station.png'
  154. let hfSIconurl = 'http://'+_self.href.split("//")[1].split("/")[0]+'/largeScreenImg/huafuStation.png'
  155. let pIconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/project.png'
  156. let fjIconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/img/fengji.png'
  157. // 所有场站标记点位
  158. if(this.mapData.allStationInfo !== null && this.mapData.allStationInfo !== undefined){
  159. let data = this.mapData.allStationInfo
  160. let station_icon = window.BM.icon({
  161. iconUrl: sIconurl,
  162. iconSize: [25, 43],
  163. iconAnchor: [25, 43]
  164. })
  165. let hf_station_icon = window.BM.icon({
  166. iconUrl: hfSIconurl,
  167. iconSize: [35, 55],
  168. iconAnchor: [35, 55]
  169. })
  170. for(let item of data.otherStation){
  171. let coordinate = [Number(item.latitude),Number(item.longitude)]
  172. let marker = window.BM.marker(coordinate,{
  173. icon: station_icon,
  174. riseOnHover: true
  175. }).addTo(this.bMap);
  176. marker.on('mouseover', function (e) {
  177. marker.bindTooltip('<div>场站名称:' + item.stationName + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  178. {permanent:true,className:'infoToolTip',offset:[0,-30]}).openTooltip();
  179. })
  180. marker.on('mouseout', function () {
  181. marker.bindTooltip().closeTooltip();
  182. })
  183. }
  184. for(let item of data.HDStation){
  185. let coordinate = [Number(item.latitude),Number(item.longitude)]
  186. let marker = window.BM.marker(coordinate,{
  187. icon: hf_station_icon,
  188. riseOnHover: true
  189. }).addTo(this.bMap);
  190. marker.on('mouseover', function (e) {
  191. marker.bindTooltip('<div>场站名称:' + item.stationName + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  192. {permanent:true,className:'infoToolTip',offset:[0,-30]}).openTooltip();
  193. })
  194. marker.on('mouseout', function () {
  195. marker.bindTooltip().closeTooltip();
  196. })
  197. }
  198. }
  199. // 项目标记点位
  200. if (this.mapData.projectInfo !== null && this.mapData.projectInfo !== undefined) {
  201. let data = this.mapData.projectInfo
  202. let station_icon = window.BM.icon({
  203. iconUrl: pIconurl,
  204. iconSize: [30, 50],
  205. iconAnchor: [30, 50]
  206. })
  207. for (let item of data) {
  208. let coordinate = [Number(item.latitude), Number(item.longitude)]
  209. let marker = window.BM.marker(coordinate, {
  210. icon: station_icon,
  211. riseOnHover: true
  212. }).addTo(this.bMap);
  213. // 悬浮动作
  214. marker.on('mouseover', function (e) {
  215. marker.bindTooltip('<div>项目名称:' + item.projectNameEasy + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  216. {permanent:true,className:'infoToolTip',offset:[0,-30]}).openTooltip();
  217. })
  218. marker.on('mouseout', function () {
  219. marker.bindTooltip().closeTooltip();
  220. })
  221. // 点击动作
  222. marker.on('click', function (e) {
  223. let project = {id: item.id,projectSort: item.projectName}
  224. sessionStorage.setItem("projectInfo", JSON.stringify(project))
  225. _self.$store.dispatch('equipmentInfo/projectInfo', JSON.stringify(project))
  226. _self.$router.push({path: "/homepage/projectInfo"})
  227. })
  228. }
  229. }
  230. // 华富场站标记点位
  231. if (this.mapData.staionInfo !== null && this.mapData.staionInfo !== undefined) {
  232. let data = this.mapData.staionInfo
  233. let station_icon = window.BM.icon({
  234. iconUrl: sIconurl,
  235. iconSize: [30, 50],
  236. iconAnchor: [30, 50],
  237. className:'stationIcon',
  238. })
  239. for (let item of data) {
  240. let coordinate = [Number(item.latitude), Number(item.longitude)]
  241. let marker = window.BM.marker(coordinate, {
  242. icon: station_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. marker.on('click', function (e) {
  255. let station = {id: item.id,stationName: item.stationName}
  256. sessionStorage.setItem("stationInfo",JSON.stringify(station))
  257. _self.$store.dispatch('equipmentInfo/stationInfo',JSON.stringify(station))
  258. _self.$router.push({path: "/homepage/stationInfo"})
  259. })
  260. }
  261. }
  262. // 所有风机、塔、拐点标记点位
  263. if (this.mapData.allPointInfo !== null && this.mapData.allPointInfo !== undefined) {
  264. let data = this.mapData.allPointInfo
  265. let station_icon = window.BM.icon({
  266. iconUrl: pIconurl,
  267. iconSize: [35, 55],
  268. iconAnchor: [35, 55],
  269. className:'stationIcon',
  270. })
  271. let fj_icon = window.BM.icon({
  272. iconUrl: fjIconurl,
  273. iconSize: [30, 30],
  274. iconAnchor: [30, 30],
  275. className:'stationIcon',
  276. })
  277. for(let item of data.fan){
  278. let coordinate = [Number(item.latitudeFan),Number(item.longitudeFan)]
  279. let marker = window.BM.marker(coordinate,{
  280. icon: fj_icon,
  281. riseOnHover: true
  282. }).addTo(this.bMap);
  283. }
  284. for(let item of data.coordinatesList){
  285. if(item.length>0){
  286. let latlngs = []
  287. for (let coor of item){
  288. latlngs.push([Number(coor.latitude),Number(coor.longitude)])
  289. window.BM.marker([Number(coor.latitude),Number(coor.longitude)]).addTo(this.bMap);
  290. }
  291. var polygon = BM.polygon(latlngs).addTo(this.bMap);
  292. // 让地图适配当前的线段
  293. this.bMap.fitBounds(polygon.getBounds());
  294. }
  295. }
  296. for (let item of data.towerList) {
  297. let coordinate = [Number(item.latitude), Number(item.longitude)]
  298. let marker = window.BM.marker(coordinate, {
  299. icon: station_icon,
  300. riseOnHover: true
  301. }).addTo(this.bMap);
  302. // 悬浮动作
  303. marker.on('mouseover', function (e) {
  304. // console.log(item)
  305. if(item.type === 'project'){
  306. marker.bindTooltip('<div>项目名称:' + item.projectName + '</div>'+ '<div>测风塔名称:' + item.towerName + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  307. {permanent:true,className:'infoToolTip',offset:[0,-30]}).openTooltip();
  308. }else{
  309. marker.bindTooltip('<div>场站名称:' + item.stationName + '</div>'+ '<div>测风塔名称:' + item.towerName + '</div>' + '<div>经度:' + item.longitude + '</div>' + '<div>纬度:' + item.latitude + '</div>',
  310. {permanent:true,className:'infoToolTip',offset:[0,-30]}).openTooltip();
  311. }
  312. })
  313. marker.on('mouseout', function () {
  314. marker.bindTooltip().closeTooltip();
  315. })
  316. // 点击动作
  317. marker.on('click', function (e) {
  318. if(item.type === 'project'){
  319. let project = {projectId:item.projectId,equipmentNo:item.towerNo}
  320. sessionStorage.setItem("emailWindTowerInfo", JSON.stringify(project))
  321. _self.$store.dispatch('equipmentInfo/emailWindTowerInfo', JSON.stringify(project))
  322. _self.$router.push({path: "/homepage/emailResourcesInfo"})
  323. }else {
  324. let station = {stationId:item.stationId,equipmentNo:item.towerNo}
  325. sessionStorage.setItem("realWindTowerInfo", JSON.stringify(station))
  326. _self.$store.dispatch('equipmentInfo/realWindTowerInfo', JSON.stringify(station))
  327. _self.$router.push({path: "/homepage/realResourcesInfo"})
  328. }
  329. })
  330. }
  331. }
  332. /**
  333. * 加载实时气象源动画效果
  334. fetch("/js/json/wind_data/20230403_00_atmoslev_1000_mb.json")
  335. .then((res) => {
  336. return res.json();
  337. })
  338. .then((data) => {
  339. this.velocityLayer = window.BM.velocityLayer({
  340. displayValues: true,
  341. displayOptions: {
  342. velocityType: "windy",
  343. displayPosition: "topright",
  344. displayEmptyString: "没有数据",
  345. directionString: "风向",
  346. speedString: "速度",
  347. },
  348. data: data,
  349. minVelocity: 0.05,
  350. maxVelocity: 10,
  351. colorScale: ["red", "green", "yellow", "pink"],
  352. velocityScale: 0.02, // default 0.005,
  353. });
  354. this.velocityLayer.addTo(this.bMmap);
  355. });
  356. */
  357. })
  358. },
  359. //设置热力图效果
  360. setHeatMap(map) {
  361. axios.get("/img/heapmap/mean-wind-speed_rendering.tiff", {
  362. responseType: "arraybuffer",
  363. }).then((res) => {
  364. const fr = new FileReader();
  365. fr.onloadend = function (e) {
  366. var image = new Tiff({buffer: e.target.result});
  367. var imageUrl = image.toDataURL(),
  368. imageBounds = [
  369. [43.422993, 121.183134],
  370. [53.564656, 135.091461],
  371. ];
  372. window.imgOverlay = window.BM.imageOverlay(imageUrl, imageBounds).addTo(map);
  373. map.fitBounds(imageBounds);
  374. };
  375. fr.readAsArrayBuffer(new Blob([res.data]));
  376. });
  377. },
  378. //绑定事件-监听地图级别和拖动
  379. bindEvents(map) {
  380. let _self = this
  381. map.on('moveend', function (e) {
  382. const c = this.getCenter();
  383. _self.center = this.getCenter()
  384. document.getElementById('move').innerHTML = '当前中心点: 纬度:' + c.lat.toFixed(5) + ',经度:' + c.lng.toFixed(5);
  385. });
  386. //添加一个缩放事件
  387. map.on('zoomend', function (e) {
  388. _self.level = this.getZoom()
  389. document.getElementById('zoom').innerHTML = '当前级别 : ' + this.getZoom();
  390. });
  391. },
  392. setData(params) {
  393. fetch(`/js/json/wind_data/20230403_00_atmoslev_` + params + `_mb.json`)
  394. .then((res) => {
  395. return res.json();
  396. })
  397. .then((data) => {
  398. this.velocityLayer.options.displayOptions.velocityType = params + `Mb`;
  399. this.velocityLayer.setData(data);
  400. });
  401. },
  402. initRegion(code) {
  403. sessionStorage.clear();
  404. sessionStorage.setItem('latlngs', JSON.stringify(this.latlngs));
  405. this.chons(code)
  406. },
  407. //加载地图方法
  408. chons(code) {
  409. fetch('/js/geojson/230000/' + code + '.geojson')
  410. .then((res) => {
  411. return res.json();
  412. })
  413. .then((data) => {
  414. this.cone = this.BM.geoJSON(data, {
  415. style: function () {
  416. return {
  417. color: '#ffffff',
  418. fillColor: 'transparent',
  419. weight: 1,
  420. fillOpacity: 0.9
  421. };
  422. },
  423. }).on('mouseover', function (e) {
  424. const rel = e.layer.feature.properties;
  425. e.layer.setStyle({
  426. color: '#ffffff',
  427. fillColor: 'transparent',
  428. weight: 3,
  429. fillOpacity: 1
  430. });
  431. //显示弹窗信息坐标
  432. let x = rel.center['1'];
  433. let y = rel.center['0'];
  434. let coordinate = [[x, y]];
  435. //组装参数
  436. let adcode = rel.adcode;
  437. let name = rel.name;
  438. let level = rel.level;
  439. let cont =
  440. "<div>acode :" + adcode + "</div>" +
  441. "<div>name <span style='margin-left: 2px'>:</span>" + name + "</div>" +
  442. "<div>level <span style='margin-left: 7px'>:</span>" + level + "</div>";
  443. //显示弹窗
  444. if (!e.layer.getPopup()) {
  445. e.layer.bindPopup(cont);
  446. }
  447. e.layer.openPopup();
  448. }).on('mouseout', function (e) {
  449. e.layer.setStyle({
  450. color: '#ffffff',
  451. fillColor: 'transparent',
  452. weight: 1,
  453. fillOpacity: 0.9
  454. });
  455. // 点击地图区域向下钻取
  456. // }).on('click', (e) => {
  457. // const rel = e.layer.feature.properties;
  458. // const zb = e.layer._bounds;
  459. // if (code === rel.adcode) {
  460. // return false;
  461. // } else {
  462. // //定时器
  463. // clearTimeout(this.mTime);
  464. // this.mTime = setTimeout(() => {
  465. // //重新加载
  466. // this.chons(rel.adcode);
  467. // this.cone.remove();
  468. // //临时缓存
  469. // sessionStorage.setItem('diqu', JSON.stringify(rel.acroutes));
  470. // const latadd = sessionStorage.getItem('latlngs');
  471. // const lataddp = JSON.parse(latadd);
  472. // lataddp.push([[zb._northEast.lat, zb._northEast.lng], [zb._southWest.lat, zb._southWest.lng]]);
  473. // sessionStorage.setItem('latlngs', JSON.stringify(lataddp));
  474. // if (lataddp.slice(-1).length !== 0) {
  475. // this.bMap.fitBounds(lataddp.slice(-1));
  476. // }
  477. // }, 300);
  478. // }
  479. }).addTo(this.bMap);
  480. })
  481. }
  482. }
  483. }
  484. </script>
  485. <style>
  486. .infoToolTip{
  487. color: white;
  488. background: rgba(0, 133, 212, 0.75);
  489. border: .5px solid #0085d4;
  490. }
  491. .my_tooltip{
  492. color: #0085d4;
  493. background: transparent;
  494. border: none;
  495. /*font-size: 18px;*/
  496. }
  497. .my_tooltip::before{
  498. display: none;
  499. }
  500. </style>
  501. <style scoped>
  502. #map {
  503. width: 100%;
  504. height: calc(90vh);
  505. }
  506. .bigemap-popup-content-wrapper, .map-legends, .map-tooltip {
  507. border-radius: 8px;
  508. box-shadow: 5px 5px 5px rgb(0 0 0);
  509. }
  510. </style>