mapVisualization-th.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" :isBack="true" backUrl="/pages/indexcf/indexcf">
  4. <block slot="backText">返回</block>
  5. <block slot="content"> 地图可视化</block>
  6. </cu-custom>
  7. <!--绑定点击事件-->
  8. <!--地图容器-->
  9. <map id="myMap" :markers="markers" style="width: 100%;" :style="'height:' + windowHeight + 'px;'"
  10. :longitude="m_longitude" :latitude="m_latitude" scale='11' @markertap="markertap">
  11. <view class="cu-capsule radius capsule-custom" >
  12. <view class='cu-tag bg-blue' >
  13. 园区
  14. </view>
  15. <view class="cu-tag line-blue tag-custom" >
  16. 7个
  17. </view>
  18. </view>
  19. <cover-view class="cu-bar search" style="width: 51%;float: right; min-height: 35px;">
  20. <view class="search-form round" style="height: 30px; line-height: 30px; margin: 5px 5px 0px 0px;border: 1rpx solid #36A7F3;">
  21. <text class="cuIcon-search"></text>
  22. <input type="text" placeholder="厂区面积搜索" v-model="curWord" confirm-type="search" @input="inputWord"></input>
  23. </view>
  24. </cover-view>
  25. <br/>
  26. <view class="cu-capsule radius capsule-custom" >
  27. <view class='cu-tag bg-blue '>
  28. 厂房
  29. </view>
  30. <view class="cu-tag line-blue tag-custom">
  31. 360000㎡
  32. </view>
  33. </view>
  34. <br/>
  35. <view class="cu-capsule radius capsule-custom" >
  36. <view class='cu-tag bg-blue '>
  37. 楼宇
  38. </view>
  39. <view class="cu-tag line-blue tag-custom">
  40. 28栋
  41. </view>
  42. </view>
  43. <br/>
  44. <view class="cu-capsule radius capsule-custom" >
  45. <view class='cu-tag bg-blue '>
  46. 土地
  47. </view>
  48. <view class="cu-tag line-blue tag-custom">
  49. 54900亩
  50. </view>
  51. </view>
  52. </map>
  53. </view>
  54. </template>
  55. <script>
  56. // 引入SDK核心类
  57. var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
  58. // 实例化API核心类
  59. var qqmapsdk = new QQMapWX({
  60. key: '4OWBZ-KZICJ-PCPFK-XWKUM-FLKFJ-C5FI2' // 必填
  61. });
  62. import mapVisualizationService from '@/api/map/mapVisualization'
  63. export default {
  64. data() {
  65. return {
  66. windowHeight: uni.getSystemInfoSync().windowHeight - 45, //屏幕高度
  67. markers: [],
  68. m_longitude: 120.139726,
  69. m_latitude: 33.345562,
  70. currentWebview: '',
  71. webviewStyles: { // web-view样式
  72. width: "100%",
  73. height: "100%",
  74. top: 90,
  75. },
  76. curWord: "" ,//当前搜索关键词
  77. yqList: [
  78. {
  79. building_id: '1',
  80. building_name: "亭湖区电子信息产业园",
  81. site: "盐城市亭湖区南洋镇太湖路99号",
  82. distance: "10km",
  83. building_longitude: 120.232445,
  84. building_latitude: 33.430631,
  85. building_image: '../../static/img/th-park-1.jpg'
  86. },
  87. {
  88. building_id: '2',
  89. building_name: "睿思亭湖数字基地",
  90. site: "江苏省盐城市亭湖区中亭路9号力拓花园3幢",
  91. distance: "5.4km",
  92. building_longitude: 120.209738,
  93. building_latitude: 33.400009,
  94. building_image: '../../static/img/th-park-2.jpg'
  95. },
  96. {
  97. building_id: '3',
  98. building_name: "盐城环保产业园",
  99. site: "光伏路与经一路交叉口西北150米",
  100. distance: "13.4km",
  101. building_longitude: 120.269329,
  102. building_latitude: 33.440453,
  103. building_image: '../../static/img/th-park-3.jpg'
  104. },
  105. {
  106. building_id: '4',
  107. building_name: "江苏盐城光电产业园",
  108. site: "盐城市亭湖区青墩连接线与太湖路交叉路口往西南约90米",
  109. distance: "11km",
  110. building_longitude: 120.237555,
  111. building_latitude: 33.432122,
  112. building_image: '../../static/img/th-park-4.jpg'
  113. },
  114. {
  115. building_id: '5',
  116. building_name: "盐东镇科技产业园",
  117. site: "盐城市亭湖区利民村3组",
  118. distance: "22.2km",
  119. building_longitude: 120.355611,
  120. building_latitude: 33.473836,
  121. building_image: '../../static/img/th-park-5.jpg'
  122. },
  123. {
  124. building_id: '6',
  125. building_name: "兴泰(亭湖)产业园",
  126. site: "江苏省盐城市亭湖区瑞鹤路",
  127. distance: "14km",
  128. building_longitude: 120.275086,
  129. building_latitude: 33.44331,
  130. building_image: '../../static/img/th-park-6.jpg'
  131. },
  132. {
  133. building_id: '7',
  134. building_name: "江苏新青洋智能装备产业园",
  135. site: "江苏省盐城市亭湖区盐才路1号",
  136. distance: "16.3km",
  137. building_longitude: 120.192397,
  138. building_latitude: 33.468225,
  139. building_image: '../../static/img/th-park-7.jpg'
  140. },
  141. ],
  142. }
  143. },
  144. components: {},
  145. onReady() {
  146. },
  147. mounted() {
  148. this.getBuildingList()
  149. },
  150. methods: {
  151. // 输入监听
  152. inputWord(e){
  153. // this.curWord = e.detail.value // 已使用v-model,无需再次赋值
  154. // 节流,避免输入过快多次请求
  155. this.searchTimer && clearTimeout(this.searchTimer)
  156. this.searchTimer = setTimeout(()=>{
  157. this.doSearch(this.curWord)
  158. },300)
  159. },
  160. doSearch(sWord){
  161. },
  162. markertap(e) {
  163. // 获取点击的marker的customData
  164. let markerId = e.detail.markerId;
  165. let selectedMarker = this.markers.find(marker => marker.id === markerId);
  166. let customData = selectedMarker.customData
  167. uni.navigateTo({
  168. url: '/pages/map/parkShow?parkId=' + customData.buildingId +
  169. '&parkName=' + customData.buildingName +
  170. '&parkImage=' + customData.buildingImage
  171. });
  172. },
  173. convert2TecentMap(lng, lat) {
  174. if (lng == '' && lat == '') {
  175. return {
  176. lng: '',
  177. lat: ''
  178. }
  179. }
  180. var x_pi = 3.14159265358979324 * 3000.0 / 180.0
  181. var x = lng - 0.0065
  182. var y = lat - 0.006
  183. var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi)
  184. var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi)
  185. var qqlng = z * Math.cos(theta)
  186. var qqlat = z * Math.sin(theta)
  187. return {
  188. lng: qqlng,
  189. lat: qqlat
  190. }
  191. },
  192. //获取楼宇信息
  193. getBuildingList() {
  194. let data = this.yqList
  195. if (data != null && data.length > 0) {
  196. let mar_arr = []
  197. data.forEach((item, index) => {
  198. //百度坐标转腾讯
  199. let convertPoint = this.convert2TecentMap(item.building_longitude, item.building_latitude)
  200. mar_arr.push({
  201. id: index,
  202. title: item.building_name,
  203. longitude: convertPoint.lng,
  204. latitude: convertPoint.lat,
  205. iconPath: '/static/img/building_ph.png',
  206. width: 35,
  207. callout: {
  208. content: item.building_name,
  209. display: 'ALWAYS'
  210. },
  211. customData: {
  212. buildingId: item.building_id,
  213. buildingName: item.building_name,
  214. buildingImage: item.building_image
  215. }
  216. })
  217. })
  218. this.markers = mar_arr
  219. this.getCenterPoint(this.markers)
  220. }
  221. },
  222. //计算所有点的中心点
  223. getCenterPoint(markers) {
  224. let minLat = 90, maxLat = -90, minLng = 180, maxLng = -180;
  225. markers.forEach(marker => {
  226. if (marker.latitude < minLat) minLat = marker.latitude;
  227. if (marker.latitude > maxLat) maxLat = marker.latitude;
  228. if (marker.longitude < minLng) minLng = marker.longitude;
  229. if (marker.longitude > maxLng) maxLng = marker.longitude;
  230. });
  231. this.m_latitude = (minLat + maxLat) / 2
  232. this.m_longitude = (minLng + maxLng) / 2
  233. },
  234. }
  235. }
  236. </script>
  237. <style scoped lang="scss">
  238. .capsule-custom{
  239. margin: 5px 0px 0px 5px;
  240. box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
  241. }
  242. .tag-custom{
  243. background-color: #f3f3f3;
  244. }
  245. .input-box-search{
  246. margin-left: 20rpx;
  247. background: #fff;
  248. height: 60rpx;
  249. width: 420rpx;
  250. display: flex;
  251. align-items: center;
  252. border-radius: 30rpx;
  253. padding-left: 10rpx;
  254. margin-right: 20rpx;
  255. }
  256. </style>