bigeMap.vue 30 KB

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