map.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view>
  3. <map id="map" style="width: 100%; height: 100vh;" :layer-style='5' :show-location='true' :latitude="latitude"
  4. :longitude="longitude" :markers="marker" :scale="scale" @markertap="markertap"
  5. @callouttap='callouttap'></map>
  6. <view class="cover-box ddflex">
  7. <view style="justify-content: center;" class="ddflex fflex">
  8. <image class="cover-icon" src="../static/images/baojing.png"></image>
  9. <view>报警</view>
  10. </view>
  11. <view style="justify-content: center;" class="ddflex fflex">
  12. <image class="cover-icon" src="../static/images/daohang.png"></image>
  13. <view>导航</view>
  14. </view>
  15. </view>
  16. <view class="dingwei ddflex" @click="toLocation">
  17. <image src="../static/images/dingwei.png"></image>
  18. </view>
  19. <view class="info-card">
  20. <view class="info-card-title">
  21. GPS
  22. </view>
  23. <view class="ddflex info-card-item">
  24. <view class="fflex">
  25. 名称: ZX03D209685
  26. </view>
  27. <view class="fflex info-card-item-right">
  28. 状态:静止(30秒)
  29. </view>
  30. </view>
  31. <view class="ddflex info-card-item">
  32. <view class="fflex">
  33. 编号: 016881209685
  34. </view>
  35. <view class="fflex info-card-item-right">
  36. 设防状态:撤防
  37. </view>
  38. </view>
  39. <view class="ddflex info-card-item">
  40. <view class="fflex">
  41. 控制: 已通电
  42. </view>
  43. <view class="fflex info-card-item-right">
  44. 定位类型:LBS
  45. </view>
  46. </view>
  47. <view class="ddflex info-card-item">
  48. <view class="fflex">
  49. 电压: 66.99V(主电接通)
  50. </view>
  51. </view>
  52. <view class="ddflex info-card-item">
  53. <view class="fflex">
  54. 通信: 2023-04-0311:08:16
  55. </view>
  56. </view>
  57. <view class="ddflex info-card-item">
  58. <view class="fflex">
  59. 定位: 2023-04-03 11:07:46
  60. </view>
  61. </view>
  62. <view class="ddflex info-card-item">
  63. <view class="fflex">
  64. 地址:广东省东莞市兴育路东一街2号
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. const app = getApp();
  72. const req = require("../../utils/request.js");
  73. export default {
  74. components: {},
  75. props: {},
  76. data() {
  77. return {
  78. map:null,
  79. latitude: 23.106574, //纬度
  80. longitude: 113.324587, //经度
  81. scale: 13, //缩放级别
  82. marker: [{
  83. id: 0,
  84. latitude: 23.13065, //纬度
  85. longitude: 113.3274, //经度
  86. iconPath: '', //显示的图标
  87. rotate: 0, // 旋转度数
  88. width: 20, //宽
  89. height: 30, //高
  90. // title:'我在这里',//标注点名
  91. alpha: 0.5, //透明度
  92. callout: { //自定义标记点上方的气泡窗口 点击有效
  93. content: '天宝大厦', //文本
  94. color: '#ffffff', //文字颜色
  95. fontSize: 14, //文本大小
  96. borderRadius: 15, //边框圆角
  97. borderWidth: '10',
  98. bgColor: '#e51860', //背景颜色
  99. display: 'ALWAYS', //常显
  100. },
  101. },
  102. {
  103. id: 1234597,
  104. latitude: 23.106574, //纬度
  105. longitude: 113.324587, //经度
  106. iconPath: '', //显示的图标
  107. rotate: 0, // 旋转度数
  108. width: 20, //宽
  109. height: 30, //高
  110. // title:'我在这里',//标注点名
  111. alpha: 0.5, //透明度
  112. // label:{//为标记点旁边增加标签 //因背景颜色H5不支持
  113. // color:'red',//文本颜色
  114. // },
  115. callout: { //自定义标记点上方的气泡窗口 点击有效
  116. content: '广州塔', //文本
  117. color: '#ffffff', //文字颜色
  118. fontSize: 14, //文本大小
  119. borderRadius: 15, //边框圆角
  120. borderWidth: '10',
  121. bgColor: '#e51860', //背景颜色
  122. display: 'ALWAYS', //常显
  123. },
  124. },
  125. {
  126. id: 2,
  127. latitude: 23.1338, //纬度
  128. longitude: 113.33052, //经度
  129. iconPath: '', //显示的图标
  130. rotate: 0, // 旋转度数
  131. width: 20, //宽
  132. height: 30, //高
  133. alpha: 0.5, //透明度
  134. callout: { //自定义标记点上方的气泡窗口 点击有效
  135. content: '德隆大厦', //文本
  136. color: '#ffffff', //文字颜色
  137. fontSize: 14, //文本大小
  138. borderRadius: 15, //边框圆角
  139. borderWidth: '10',
  140. bgColor: '#e51860', //背景颜色
  141. display: 'ALWAYS', //常显
  142. },
  143. },
  144. {
  145. id: 3,
  146. latitude: 23.136455, //纬度
  147. longitude: 113.329002, //经度
  148. iconPath: '', //显示的图标
  149. rotate: 0, // 旋转度数
  150. width: 20, //宽
  151. height: 30, //高
  152. alpha: 0.5, //透明度
  153. callout: { //自定义标记点上方的气泡窗口 点击有效
  154. content: '羊城国际商贸中心', //文本
  155. color: '#ffffff', //文字颜色
  156. fontSize: 14, //文本大小
  157. borderRadius: 15, //边框圆角
  158. borderWidth: '10',
  159. bgColor: '#e51860', //背景颜色
  160. display: 'ALWAYS', //常显
  161. },
  162. },
  163. {
  164. id: 4,
  165. latitude: 23.224781, //纬度
  166. longitude: 113.293911, //经度
  167. iconPath: '', //显示的图标
  168. rotate: 0, // 旋转度数
  169. width: 20, //宽
  170. height: 30, //高
  171. alpha: 0.5, //透明度
  172. callout: { //自定义标记点上方的气泡窗口 点击有效
  173. content: '天瑞广场A座', //文本
  174. color: '#ffffff', //文字颜色
  175. fontSize: 16, //文本大小
  176. borderRadius: 15, //边框圆角
  177. borderWidth: '12',
  178. bgColor: '#e51860', //背景颜色
  179. display: 'ALWAYS', //常显
  180. },
  181. },
  182. {
  183. id: 5,
  184. latitude: 23.072726, //纬度
  185. longitude: 113.277921, //经度
  186. iconPath: '', //显示的图标
  187. rotate: 0, // 旋转度数
  188. width: 20, //宽
  189. height: 30, //高
  190. alpha: 0.5, //透明度
  191. callout: { //自定义标记点上方的气泡窗口 点击有效
  192. content: '大米和小米儿童康复(广州盈丰)中心', //文本
  193. color: '#ffffff', //文字颜色
  194. fontSize: 14, //文本大小
  195. borderRadius: 15, //边框圆角
  196. borderWidth: '8',
  197. bgColor: '#e51860', //背景颜色
  198. display: 'ALWAYS', //常显
  199. },
  200. },
  201. ],
  202. }
  203. },
  204. onLoad(options) {
  205. this.toLocation()
  206. },
  207. onShow() {
  208. },
  209. onReady() {
  210. },
  211. mounted(){
  212. },
  213. computed: {},
  214. methods: {
  215. //地图点击事件
  216. markertap(e) {
  217. console.log("===你点击了标记点===", e)
  218. },
  219. //地图点击事件
  220. callouttap(e) {
  221. console.log('地图点击事件', e)
  222. },
  223. toLocation() {
  224. console.log('地图控件回到原位');
  225. req.getLocation((res) =>{
  226. console.log('当前位置:' ,res);
  227. console.log('当前位置的经度:' + res.longitude);
  228. console.log('当前位置的纬度:' + res.latitude);
  229. this.longitude = res.longitude;
  230. this.latitude = res.latitude;
  231. this.map = uni.createMapContext("map", this);
  232. this.map.moveToLocation()
  233. })
  234. }
  235. },
  236. mounted() {
  237. },
  238. onPageScroll: function(e) {}
  239. }
  240. </script>
  241. <style>
  242. @import "./map.css";
  243. </style>