h5Map.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="realtimeWatch">
  3. <map-container
  4. ref="mapContainerRef"
  5. :pointsData="pointsData"
  6. @handleMarkerClick="handleMarkerClick"
  7. >
  8. </map-container>
  9. <view class="counts">
  10. <u-row>
  11. <u-col :span="3" class="counts-item" v-for="(item,index) in countInfo" :key="index" :class="item.class">
  12. <view class="counts-item-label" :style="item.style">{{ item.label }}</view>
  13. <view class="counts-item-value" :style="item.style">{{ item.value }}</view>
  14. </u-col>
  15. </u-row>
  16. </view>
  17. <view class="options">
  18. <view class="options-item" @click="showSatelliteLayer">
  19. <image
  20. style="width: 100%; height: 100%"
  21. :src="$getImages('/assetsMobile/images/map/icon/weixing.png')"
  22. />
  23. </view>
  24. <view class="options-item" @click="showPanel">
  25. <image
  26. style="width: 100%; height: 100%"
  27. :src="$getImages('/assetsMobile/images/map/icon/boxselection.png')"
  28. />
  29. </view>
  30. <view class="options-item" @click="queryLocation">
  31. <image
  32. style="width: 100%; height: 100%"
  33. :src="$getImages('/assetsMobile/images/map/icon/position.png')"
  34. />
  35. </view>
  36. </view>
  37. <panel ref="panelRef"></panel>
  38. <veh-info ref="vehInfoRef"></veh-info>
  39. </view>
  40. </template>
  41. <script>
  42. import MapContainer from '@/components/MapContainer'
  43. import panel from './panel.vue'
  44. import vehInfo from './vehInfo.vue'
  45. export default {
  46. components: {
  47. MapContainer,
  48. panel,
  49. vehInfo,
  50. },
  51. data() {
  52. return {
  53. //卫星图层
  54. isShowStelliteLayer: false,
  55. }
  56. },
  57. computed: {
  58. pointsData() {
  59. // console.log(this.$store.state.realtimeWatch.vheicleCheckArr,'realtimeWatch')
  60. let vehmap = new Map()
  61. let vehKey = 'id'
  62. let list = []
  63. let vehicleList = this.$store.state.realtimeWatch.vheicleCheckArr.filter(
  64. (item) => item.code=='vehicle' && !vehmap.has(item[vehKey].toString()) && vehmap.set(item[vehKey].toString())
  65. ).map((item) => {
  66. return {
  67. lnglat: [item.lng,item.lat],
  68. item: item,
  69. }
  70. })
  71. let usermap = new Map()
  72. let userKey = 'id'
  73. let peopleList = this.$store.state.realtimeWatch.peopleCheckArr.filter(
  74. (item) => item.code=='people' && !usermap.has(item[userKey].toString()) && usermap.set(item[userKey].toString())
  75. ).map((item) => {
  76. console.log('数据是',item)
  77. return {
  78. lnglat: [item.lng,item.lat],
  79. item
  80. }
  81. })
  82. list = vehicleList.concat(peopleList)
  83. return list;
  84. },
  85. countInfo() {
  86. return this.$store.state.realtimeWatch.countInfo
  87. },
  88. },
  89. onReady () {
  90. },
  91. methods: {
  92. // 查询自身位置
  93. queryLocation() {
  94. uni.getLocation({
  95. type: "gcj02",
  96. success: (res) => {
  97. const {latitude,longitude} = res
  98. this.$refs.mapContainerRef.setZoomAndCenter(12,[longitude,latitude],true)
  99. },
  100. fail: (res) => {
  101. console.log('定位失败',JSON.stringify(res));
  102. }
  103. });
  104. },
  105. //选车辆
  106. showPanel() {
  107. this.$refs.panelRef.show()
  108. },
  109. //展示卫星图层
  110. showSatelliteLayer() {
  111. this.isShowStelliteLayer = !this.isShowStelliteLayer
  112. if(this.$refs.mapContainerRef) this.$refs.mapContainerRef.setStelliteLayer(this.isShowStelliteLayer)
  113. },
  114. //点击标注点
  115. handleMarkerClick(e) {
  116. // console.log(e,'handleMarkerClick')
  117. const {cluster} = e
  118. let item = cluster.p.item
  119. this.$refs.vehInfoRef.show(item)
  120. }
  121. },
  122. beforeDestroy() {
  123. this.$store.dispatch('setVheicleCheckArr',[])
  124. this.$store.dispatch('setPeopleCheckArr',[])
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .realtimeWatch {
  130. width: 100%;
  131. height: 100vh;
  132. position: relative;
  133. #map {
  134. width: 750rpx;
  135. height: 100%;
  136. }
  137. .counts {
  138. position: absolute;
  139. left: 2%;
  140. top: 20rpx;
  141. width: 96%;
  142. background: #fff;
  143. border-radius: 10rpx;
  144. box-shadow: 0 2px 6px #3f57c252;
  145. // margin: 10rpx;
  146. .counts-item {
  147. padding: 14rpx 10rpx;
  148. display: flex;
  149. justify-content: center;
  150. align-items: center;
  151. flex-direction: column;
  152. .counts-item-label {
  153. font-size: 24rpx;
  154. font-family: PingFangSC-Medium, PingFang SC;
  155. font-weight: 400;
  156. color: #333333;
  157. text-align: center;
  158. }
  159. .counts-item-value {
  160. margin-top: 10rpx;
  161. font-size: 26rpx;
  162. font-family: PingFangSC-Regular, PingFang SC;
  163. font-weight: 600;
  164. color: #333333;
  165. text-align: center;
  166. }
  167. }
  168. }
  169. .options {
  170. position: absolute;
  171. width: 72rpx;
  172. right: 30rpx;
  173. bottom: 156rpx;
  174. // box-shadow: 0px 3px 30px 0px rgba(0, 0, 0, 0.15);
  175. z-index: 9999;
  176. .options-item {
  177. height: 72rpx;
  178. }
  179. .options-item+.options-item{
  180. margin-top: 20rpx;
  181. }
  182. }
  183. }
  184. </style>