dangerareamap.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!--
  2. * @Title:
  3. * @Description: 危险区地图
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <view class="container">
  11. <uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
  12. @clickLeft="toBack">
  13. <view class="nav-title">
  14. <text>{{title}}</text>
  15. </view>
  16. </uni-nav-bar>
  17. <view class="page-body">
  18. <view class="page-section page-section-gap">
  19. <map :style="mapStyles" :latitude="latitude" :longitude="longitude" :markers="markets"
  20. enable-zoom="true" :polygons="polygons" :scale="scale">
  21. </map>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. gcoord
  29. } from '@/static/js/gcoord.global.prod.js'
  30. import http from '@/http/api.js';
  31. import {
  32. devUrl,
  33. prodUrl
  34. } from '@/common/setting';
  35. export default {
  36. components: {
  37. },
  38. onLoad(options) {
  39. this.mapStyles.height = (uni.getWindowInfo().windowHeight - 50) + "px";
  40. this.id = options.id;
  41. this.baseURL = process.env.NODE_ENV === 'development' ? devUrl : prodUrl;
  42. let that = this;
  43. let postData = {};
  44. postData['id'] = this.id;
  45. http.request({
  46. url: '/galaxy-business/map/dangerarea/detail',
  47. method: 'GET',
  48. data: postData
  49. }).then(res => {
  50. console.log(res)
  51. if (res.data != null) {
  52. let p = {};
  53. let ps = res.data.points.map(item => {
  54. let l = gcoord.transform(
  55. [item.pointLng, item.pointLat],
  56. gcoord.WGS84,
  57. gcoord.GCJ02
  58. );
  59. return {
  60. latitude: l[1],
  61. longitude: l[0],
  62. }
  63. })
  64. p['points'] = ps;
  65. let dashArray = [];
  66. dashArray.push(4);
  67. dashArray.push(10);
  68. p['dashArray'] = dashArray;
  69. if (res.data.dangerStatus == '1') {
  70. p['strokeColor'] = '#FF0000';
  71. p['fillColor'] = '#F72C5B7D';
  72. } else {
  73. p['strokeColor'] = '#FC8452';
  74. p['fillColor'] = '#FAC8587D';
  75. }
  76. that.polygons.push(p);
  77. let c = gcoord.transform(
  78. [res.data.centerPointLng, res.data.centerPointLat],
  79. gcoord.WGS84,
  80. gcoord.GCJ02
  81. );
  82. console.log(c)
  83. that.latitude = c[1];
  84. that.longitude = c[0];
  85. // let marketPoints = res.data.rtus.map(item => {
  86. // console.log(JSON.stringify(item))
  87. // let rtu = {};
  88. // rtu['iconPath'] = '/static/images/icon_warning.png';
  89. // rtu['id'] = parseInt(item.id);
  90. // let r = gcoord.transform(
  91. // [parseFloat(item.lng), parseFloat(item.lat)],
  92. // gcoord.WGS84,
  93. // gcoord.GCJ02
  94. // );
  95. // rtu['latitude'] = r[1];
  96. // rtu['longitude'] = r[0];
  97. // rtu['width'] = 20;
  98. // rtu['height'] = 20;
  99. // let label = {};
  100. // label['content'] = item.rtuName;
  101. // label['color'] = '#ff0000';
  102. // label['bgColor'] = '#ffffff';
  103. // label['anchorY'] = -40;
  104. // rtu['label'] = label;
  105. // return rtu;
  106. // });
  107. //that.markets = marketPoints;
  108. that.scale = 14;
  109. }
  110. }).catch(err => {
  111. console.log(err)
  112. })
  113. },
  114. data() {
  115. return {
  116. title: '危险区地图',
  117. id: 0,
  118. areaList: [],
  119. areaIndex: 0,
  120. latitude: 40.848119,
  121. longitude: 111.755426,
  122. zoom: true,
  123. scale: 14,
  124. markets: [],
  125. polygons: [],
  126. mapStyles: {
  127. width: '100%',
  128. height: '600px'
  129. },
  130. }
  131. },
  132. computed: {
  133. },
  134. onShow() {
  135. },
  136. methods: {
  137. toBack() {
  138. uni.navigateBack({
  139. delta: 1
  140. })
  141. },
  142. }
  143. }
  144. </script>
  145. <style>
  146. /* page {
  147. background-color: rgb(240, 242, 244);
  148. } */
  149. .uni-body {
  150. font-size: 0.7rem;
  151. }
  152. </style>