equip_list_map.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <link rel="stylesheet" href="../css/mui.min.css" />
  8. <link rel="stylesheet" href="../css/common.css" />
  9. <link rel="stylesheet" type="text/css" href="../css/equipList.css" />
  10. <style type="text/css">
  11. .mapBox {
  12. position: fixed;
  13. left: 0;
  14. right: 0;
  15. top: 0;
  16. bottom: 0;
  17. /*background: pink;*/
  18. }
  19. #map {
  20. height: 100%;
  21. width: 100%;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <header class="mui-bar mui-bar-nav">
  27. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  28. <h1 class="mui-title">手动定位</h1>
  29. <a id="addbtn" class="mui-icon mui-icon-gear mui-pull-right"></a>
  30. </header>
  31. <div class="mui-content">
  32. <!--srfwegwerg-->
  33. <!--<div class="searchBox">
  34. <div class="searchControl">
  35. <div class="mui-input-row mui-search">
  36. <input type="search" id="searchInp" class="mui-input-clear" placeholder="请输入设备ID">
  37. </div>
  38. <button id="searchBtn" class="searchBtn">搜索</button>
  39. </div>
  40. </div>-->
  41. <div class="mapBox">
  42. <div id="map"></div>
  43. </div>
  44. </div>
  45. <script src="../js/jquery-2.1.0.js"></script>
  46. <script src="../js/mui.min.js"></script>
  47. <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=La58N63t7hPhafQ7Eror2kon"></script>
  48. <script type="text/javascript">
  49. mui.init();
  50. mui.plusReady(function() {
  51. //百度地图获取坐标
  52. var map = new BMap.Map("map"); // 创建地图实例
  53. map.centerAndZoom(new BMap.Point(113.64964385, 34.75661006), 13); // 创建点坐标
  54. map.enableScrollWheelZoom(true);
  55. map.addControl(new BMap.ScaleControl()); // 添加比例尺控件
  56. map.addControl(new BMap.NavigationControl()); //为地图添加鱼骨(默认)
  57. map.addEventListener("tilesloaded", function() {
  58. $(".BMap_cpyCtrl").hide();
  59. }); //地图加载完毕后 隐藏百度图标
  60. var lng = '',
  61. lat = '';
  62. //单击获取点击的经纬度
  63. map.addEventListener("click", function(e) {
  64. map.clearOverlays();
  65. lng = '';
  66. lat = '';
  67. $('#lng').val(e.point.lng);
  68. $('#lat').val(e.point.lat);
  69. var point = new BMap.Point(e.point.lng, e.point.lat);
  70. var marker = new BMap.Marker(point);
  71. map.addOverlay(marker);
  72. lng = e.point.lng;
  73. lat = e.point.lat;
  74. mui.confirm('添加经纬度', '添加经纬度', ['确定', '取消'], function() {
  75. mui.ajax('http://120.27.222.26/qxz_location', {
  76. dataType: 'json', //服务器返回json格式数据
  77. type: 'post', //HTTP请求类型
  78. timeout: 10000, //超时时间设置为10秒;
  79. data: {
  80. e_id: self.imei,
  81. lng: lng,
  82. lat: lat,
  83. },
  84. success: function(data) {
  85. console.log(data)
  86. if(data == 0) {
  87. mui.toast('添加成功')
  88. } else {
  89. mui.toast('添加失败')
  90. }
  91. },
  92. error: function(type) {
  93. console.log(type)
  94. }
  95. });
  96. }, 'div')
  97. // alert(e.point.lng + "," + e.point.lat);
  98. });
  99. var self = plus.webview.currentWebview(); //获取上页发送的id
  100. console.log(self.imei)
  101. //添加位置
  102. document.getElementById('addbtn').addEventListener('tap', function(e) {
  103. mui('#popover').popover('toggle'); //show hide toggle
  104. e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug,使用plus.nativeUI.prompt会造成输入法闪一下又没了
  105. var btnArray = ['确定', '取消'];
  106. mui.prompt('英文逗号隔开:', '请填写设备经纬度', '请填写设备经纬度', btnArray, function(e) {
  107. if(e.index == 0) {
  108. var value = document.querySelector('.mui-popup-input textarea').value;
  109. if(value == '') {
  110. return false;
  111. }
  112. lng = value.split(',')[0];
  113. lat = value.split(',')[1];
  114. map.clearOverlays();
  115. var points = []
  116. var point = new BMap.Point(lng, lat);
  117. var marker = new BMap.Marker(point);
  118. map.addOverlay(marker);
  119. points.push(point)
  120. console.log(points)
  121. map.setViewport(points);
  122. mui.ajax('http://120.27.222.26/qxz_location', {
  123. dataType: 'json', //服务器返回json格式数据
  124. type: 'post', //HTTP请求类型
  125. timeout: 10000, //超时时间设置为10秒;
  126. data: {
  127. e_id: self.imei,
  128. lng: lng,
  129. lat: lat,
  130. },
  131. success: function(data) {
  132. console.log(data)
  133. if(data == 0) {
  134. mui.toast('添加成功')
  135. } else {
  136. mui.toast('添加失败')
  137. }
  138. },
  139. error: function(type) {
  140. console.log(type)
  141. }
  142. });
  143. } else {
  144. // info.innerText = '你点了取消按钮';
  145. console.log('你点了取消按钮')
  146. }
  147. }, 'div')
  148. $('.mui-popup-input').html('');
  149. $('.mui-popup-input').append('<textarea></textarea>')
  150. //prompt默认值
  151. if(lng != '' && lng != '') {
  152. document.querySelector('.mui-popup-input textarea').value = lng + ',' + lat;
  153. }
  154. })
  155. })
  156. //搜索操作
  157. // $("#searchInp").on('keypress',function(e) {
  158. // var keycode = e.keyCode;
  159. // if(keycode=='13') {
  160. // e.preventDefault();
  161. // //请求搜索接口
  162. // if(mui('#searchInp')[0].value) {
  163. // getListData({num:1, size:10})
  164. // } else {
  165. // mui.toast("请输入设备ID");
  166. // }
  167. // }
  168. // })
  169. // document.getElementById('searchBtn').addEventListener('tap', function() {
  170. // if(mui('#searchInp')[0].value) {
  171. // getListData({num:1, size:10})
  172. // } else {
  173. // mui.toast("请输入设备ID");
  174. // }
  175. // })
  176. </script>
  177. </body>
  178. </html>