home_map.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /**
  2. * Created by Wandergis on 2015/7/8.
  3. * 提供了百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换
  4. */
  5. var map, geoc;
  6. $.ajax({
  7. type: "post",
  8. url: "user_location",
  9. data: {
  10. // req: "cbd",
  11. },
  12. dataType: "json",
  13. success: function (data) {
  14. //百度地图获取坐标
  15. map = new BMap.Map("allmap", { });// 创建地图实例
  16. // map = new BMap.Map("allmap", { mapType: BMAP_HYBRID_MAP });// 创建地图实例
  17. // map.centerAndZoom(new BMap.Point(113.64964385, 34.75661006), 13);// 创建点坐标
  18. var parentUserName = $('#parentUserName', parent.document).html();
  19. if (parentUserName == '罗普特') {
  20. map.centerAndZoom(new BMap.Point(112.55, 37.87), 13);// 创建点坐标
  21. } else if (data.user_pro != '' || data.user_city != '' ||data.user_area != '') {
  22. if(data.user_area){
  23. map.centerAndZoom(data.user_area,11);
  24. }else if(data.user_city){
  25. map.centerAndZoom(data.user_city,11);
  26. }else{
  27. map.centerAndZoom(data.user_pro,11);
  28. }
  29. }else{
  30. map.centerAndZoom(new BMap.Point(113.64964385, 34.75661006), 13);// 创建点坐标
  31. }
  32. map.enableScrollWheelZoom(true);
  33. map.addControl(new BMap.NavigationControl()); // 添加平移缩放控件
  34. map.addControl(new BMap.ScaleControl()); // 添加比例尺控件
  35. map.addControl(new BMap.OverviewMapControl()); //添加缩略地图控件
  36. map.enableScrollWheelZoom(); //启用滚轮放大缩小
  37. map.addControl(new BMap.MapTypeControl()); //添加地图类型控件
  38. // map.setMapStyle({style:'midnight'});
  39. map.addEventListener("tilesloaded", function () {
  40. $(".BMap_cpyCtrl").hide();
  41. // $(".anchorBL").hide();
  42. });//地图加载完毕后 隐藏百度图标
  43. geoc = new BMap.Geocoder();
  44. if ($('.content').height() > 750) {
  45. $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
  46. } else {
  47. $('#iframe-main', parent.document).css('height', '750px')
  48. }
  49. }
  50. });
  51. // //百度地图获取坐标
  52. // var map = new BMap.Map("allmap", { mapType: BMAP_HYBRID_MAP });// 创建地图实例
  53. // // map.centerAndZoom(new BMap.Point(113.64964385, 34.75661006), 13);// 创建点坐标
  54. // var parentUserName = $('#parentUserName', parent.document).html();
  55. // if (parentUserName == '罗普特') {
  56. // map.centerAndZoom(new BMap.Point(112.55, 37.87), 13);// 创建点坐标
  57. // } else {
  58. // map.centerAndZoom(new BMap.Point(113.64964385, 34.75661006), 13);// 创建点坐标
  59. // }
  60. // map.enableScrollWheelZoom(true);
  61. // map.addControl(new BMap.NavigationControl()); // 添加平移缩放控件
  62. // map.addControl(new BMap.ScaleControl()); // 添加比例尺控件
  63. // map.addControl(new BMap.OverviewMapControl()); //添加缩略地图控件
  64. // map.enableScrollWheelZoom(); //启用滚轮放大缩小
  65. // map.addControl(new BMap.MapTypeControl()); //添加地图类型控件
  66. // // map.setMapStyle({style:'midnight'});
  67. // var stCtrl = new BMap.PanoramaControl(); //全景图
  68. // stCtrl.setOffset(new BMap.Size(20, 20));
  69. // map.addControl(stCtrl);
  70. window.onload = function () {
  71. //请求数据:
  72. // $.ajax({
  73. // type: "post",
  74. // url: "home_map/map_locat",
  75. // data: {
  76. // req: "cbd",
  77. // },
  78. // dataType: "json",
  79. // success: function (data) {
  80. // eachItem(data)
  81. // }
  82. // });
  83. // $.ajax({
  84. // type: "post",
  85. // url: "home_map/map_locat",
  86. // data: {
  87. // req: "scd",
  88. // },
  89. // dataType: "json",
  90. // success: function (data) {
  91. // eachItem(data)
  92. // }
  93. // });
  94. // $.ajax({
  95. // type: "post",
  96. // url: "home_map/map_locat",
  97. // data: {
  98. // req: "qxz",
  99. // },
  100. // dataType: "json",
  101. // success: function (data) {
  102. // eachItem(data)
  103. // }
  104. // });
  105. }
  106. function eachItem(data_info) {
  107. // console.log(data_info)
  108. var points = []; // 添加海量点数据
  109. for (var i = 0; i < data_info.length; i++) {
  110. if (data_info[i].lng > 999) {
  111. var lng = Math.floor(data_info[i].lng / 100) + ((data_info[i].lng % 100) / 60);
  112. var lat = Math.floor(data_info[i].lat / 100) + ((data_info[i].lat % 100) / 60);
  113. } else {
  114. var lat = data_info[i].lat;
  115. var lng = data_info[i].lng;
  116. }
  117. if (data_info[i].lat && data_info[i].lng) {
  118. //标注图标
  119. var orgType = data_info[i].equip_type;//parseInt(0) data_info[i].equip_type
  120. if (orgType == 5) {
  121. var equip_type = '环境监测';
  122. var options = {
  123. size: BMAP_POINT_SIZE_BIG,
  124. shape: BMAP_POINT_SHAPE_CIRCLE,
  125. color: '#001dff'
  126. }
  127. // var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 1 * 23) });
  128. } else if (orgType == 2) {
  129. var equip_type = '杀虫灯';
  130. var options = {
  131. size: BMAP_POINT_SIZE_BIG,
  132. shape: BMAP_POINT_SHAPE_CIRCLE,
  133. color: '#ff6600'
  134. }
  135. // var myIcon = new BMap.Icon("/static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 2 * 23) });
  136. } else if (orgType == 3) {
  137. var equip_type = '虫情测报';
  138. var options = {
  139. size: BMAP_POINT_SIZE_BIG,
  140. shape: BMAP_POINT_SHAPE_CIRCLE,
  141. color: '#9c1ee4'
  142. }
  143. // var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -13), imageOffset: new BMap.Size(0, 0 - 3 * 23) });
  144. } else if (orgType == 4) {
  145. var equip_type = '性诱器设备';
  146. var options = {
  147. size: BMAP_POINT_SIZE_BIG,
  148. shape: BMAP_POINT_SHAPE_CIRCLE,
  149. color: '#ff2da9'
  150. }
  151. // var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 6 * 23) });
  152. } else if (orgType == 6) {
  153. var equip_type = '监控设备';
  154. var options = {
  155. size: BMAP_POINT_SIZE_BIG,
  156. shape: BMAP_POINT_SHAPE_CIRCLE,
  157. color: 'green'
  158. }
  159. // var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 5 * 23) });
  160. } else if (orgType == 7) {
  161. var equip_type = '孢子仪设备';
  162. var options = {
  163. size: BMAP_POINT_SIZE_BIG,
  164. shape: BMAP_POINT_SHAPE_CIRCLE,
  165. color: '#ff0000'
  166. }
  167. // var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 0 * 23) });
  168. } else if (orgType == 8) {
  169. var equip_type = '农药残留';
  170. var options = {
  171. size: BMAP_POINT_SIZE_BIG,
  172. shape: BMAP_POINT_SHAPE_CIRCLE,
  173. color: '#ff7600'
  174. }
  175. // var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 4 * 23) });
  176. }
  177. // console.log(lat,lng);
  178. //判断当前是否为杀虫灯
  179. if (data_info[i].equip_type == 2) {
  180. if (data_info[i].gps == 1) {
  181. // 先从WGS84转火星再转百度 GPS定位
  182. var lng1 = wgs84togcj02(lng, lat);
  183. var lngData = gcj02tobd09(lng1[0], lng1[1]);
  184. // console.log(lngData + 'GPS定位')
  185. } else if (data_info[i].gps == 2) {
  186. //直接从火星转百度 基站定位
  187. var lngData = gcj02tobd09(lng, lat)
  188. // console.log(lngData + '基站定位')
  189. } else if (data_info[i].gps == 0) {
  190. //手动定位不需要进行操作
  191. var lngData = []
  192. lngData.push(lng)
  193. lngData.push(lat)
  194. // console.log(lngData + '手动定位')
  195. }
  196. var point = new BMap.Point(lngData[0], lngData[1]);
  197. point.equip_id= data_info[i].equip_id;
  198. point.equip_name= data_info[i].equip_name;
  199. point.equip_type = equip_type;
  200. point.orgType = orgType;
  201. points.push(point);
  202. } else if (data_info[i].equip_type == 3) {
  203. console.log('测报灯')
  204. //测报灯
  205. if (data_info[i].gps == 1) {
  206. // 先从WGS84转火星再转百度 GPS定位
  207. var lng1 = wgs84togcj02(lng, lat);
  208. var lngData = gcj02tobd09(lng1[0], lng1[1]);
  209. // console.log(lngData + 'GPS定位')
  210. } else if (data_info[i].gps == 2) {
  211. //直接从火星转百度 基站定位
  212. var lngData = gcj02tobd09(lng, lat)
  213. // console.log(lngData + '基站定位')
  214. } else if (data_info[i].gps == 0) {
  215. //手动定位不需要进行操作
  216. var lngData = []
  217. lngData.push(lng)
  218. lngData.push(lat)
  219. // console.log(lngData + '手动定位')
  220. }
  221. var point = new BMap.Point(lngData[0], lngData[1]);
  222. point.equip_id= data_info[i].equip_id;
  223. point.equip_name= data_info[i].equip_name;
  224. point.equip_type = equip_type;
  225. point.orgType = orgType;
  226. points.push(point);
  227. } else {
  228. var lng1 = wgs84togcj02(lng, lat);
  229. var lng2 = gcj02tobd09(lng1[0], lng1[1]);
  230. // console.log(lng1[0] + ',' + lng1[1] + '火星坐标')
  231. // console.log(lng2[0] + ',' + lng2[1] + '百度坐标')
  232. // console.log(lng1,lng2);
  233. // pointArray[i] = new BMap.Point(lng2[0], lng2[1]);
  234. // pointArray.push(new BMap.Point(lng2[0], lng2[1]))
  235. // var point = new BMap.Point(lng2[0], lng2[1]);
  236. var point = new BMap.Point(lng1[0], lng1[1]);
  237. point.equip_id= data_info[i].equip_id;
  238. point.equip_name= data_info[i].equip_name;
  239. point.equip_type = equip_type;
  240. point.orgType = orgType;
  241. points.push(point);
  242. }
  243. // var lng1 = wgs84togcj02(lng, lat);
  244. // var lng2 = gcj02tobd09(lng1[0], lng1[1]);
  245. // // console.log(lng1[0] + ',' + lng1[1] + '火星坐标')
  246. // // console.log(lng2[0] + ',' + lng2[1] + '百度坐标')
  247. // // console.log(lng1,lng2);
  248. // // pointArray[i] = new BMap.Point(lng2[0], lng2[1]);
  249. // // pointArray.push(new BMap.Point(lng2[0], lng2[1]))
  250. // // var point = new BMap.Point(lng2[0], lng2[1]);
  251. // var point = new BMap.Point(lng1[0], lng1[1]);
  252. // point.equip_id= data_info[i].equip_id;
  253. // point.equip_name= data_info[i].equip_name;
  254. // point.equip_type = equip_type;
  255. // point.orgType = orgType;
  256. // points.push(point);
  257. // var enterNum = equip_type;//data_info[i].equip_name
  258. // var content = '<p>名称:' + data_info[i].equip_name + '</p><p class="gotoDetial" onclick="gotoManageDetial(\'' + data_info[i].equip_id + ' \',' + orgType + ')">IMEI:' + data_info[i].equip_id + '</p><p>经度:' + lng2[0] + '</p><p>纬度:' + lng2[1] + '</p><p class="area">位置:' + data_info[i].equip_location + '</p></br>';
  259. // if (data_info[i].equip_location) {
  260. // var flag = true;
  261. // } else {
  262. // var flag = false;
  263. // }
  264. // 将标注添加到地图中
  265. // addClickHandler(content, marker, enterNum, flag);
  266. }
  267. }
  268. var pointCollection = new BMap.PointCollection(points, options); // 初始化PointCollection
  269. pointCollection.addEventListener('click', function (e) {
  270. var point = new BMap.Point(e.point.lng, e.point.lat);
  271. geoc.getLocation(point, function (rs) {
  272. var addComp = rs.addressComponents;
  273. $('.area').html('位置:' + addComp.province + ", " + addComp.city + ", " + addComp.district)
  274. // alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
  275. });
  276. var opts = {
  277. width: 200, // 信息窗口宽度
  278. height: 150, // 信息窗口高度
  279. title: e.point.equip_type, // 信息窗口标题
  280. enableMessage: true//设置允许信息窗发送短息
  281. };
  282. console.log(e.point.lat)
  283. console.log(e.point.lng)
  284. var content = '<p>名称:' + e.point.equip_name + '</p><p class="gotoDetial" onclick="gotoManageDetial(\'' + e.point.equip_id + ' \',' + e.point.orgType + ')">IMEI:' + e.point.equip_id + '</p><p>经度:' + e.point.lng + '</p><p>纬度:' + e.point.lat + '</p><p class="area">位置:' + e.point.equip_location + '</p></br>';
  285. var infowindow = new BMap.InfoWindow(content, opts);
  286. map.openInfoWindow(infowindow, point);
  287. // alert('单击点的坐标为:' + e.point.lng + ',' + e.point.lat); // 监听点击事件
  288. });
  289. map.addOverlay(pointCollection); // 添加Overlay
  290. //让所有点在视野范围内
  291. map.setViewport(points);
  292. }
  293. function eachItem1(data_info) {
  294. var pointArray = [];
  295. for (var i = 0; i < data_info.length; i++) {
  296. if (data_info[i].lng > 999) {
  297. var lng = Math.floor(data_info[i].lng / 100) + ((data_info[i].lng % 100) / 60);
  298. var lat = Math.floor(data_info[i].lat / 100) + ((data_info[i].lat % 100) / 60);
  299. } else {
  300. var lat = data_info[i].lat;
  301. var lng = data_info[i].lng;
  302. }
  303. if (data_info[i].lat && data_info[i].lng) {
  304. //标注图标
  305. var orgType = data_info[i].equip_type;//parseInt(0) data_info[i].equip_type
  306. if (orgType == 5) {
  307. var equip_type = '环境监测';
  308. var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 1 * 23) });
  309. } else if (orgType == 2) {
  310. var equip_type = '杀虫灯';
  311. var myIcon = new BMap.Icon("/static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 2 * 23) });
  312. } else if (orgType == 3) {
  313. var equip_type = '虫情测报';
  314. var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -13), imageOffset: new BMap.Size(0, 0 - 3 * 23) });
  315. } else if (orgType == 4) {
  316. var equip_type = '性诱器设备';
  317. var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 6 * 23) });
  318. } else if (orgType == 6) {
  319. var equip_type = '监控设备';
  320. var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 5 * 23) });
  321. } else if (orgType == 7) {
  322. var equip_type = '孢子仪设备';
  323. var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 0 * 23) });
  324. } else if (orgType == 8) {
  325. var equip_type = '农药残留';
  326. var myIcon = new BMap.Icon("static/img/locationIcon2.png", new BMap.Size(17, 23), { offset: new BMap.Size(0, -18), imageOffset: new BMap.Size(0, 0 - 4 * 23) });
  327. }
  328. var lng1 = wgs84togcj02(lng, lat);
  329. var lng2 = gcj02tobd09(lng1[0], lng1[1]);
  330. // pointArray[i] = new BMap.Point(lng2[0], lng2[1]);
  331. pointArray.push(new BMap.Point(lng2[0], lng2[1]))
  332. var marker = new BMap.Marker(new BMap.Point(lng2[0], lng2[1]), { icon: myIcon }); // 创建标注
  333. map.addOverlay(marker);
  334. var enterNum = equip_type;//data_info[i].equip_name
  335. var content = '<p>名称:' + data_info[i].equip_name + '</p><p class="gotoDetial" onclick="gotoManageDetial(\'' + data_info[i].equip_id + ' \',' + orgType + ')">IMEI:' + data_info[i].equip_id + '</p><p>经度:' + lng2[0] + '</p><p>纬度:' + lng2[1] + '</p><p class="area">位置:' + data_info[i].equip_location + '</p></br>';
  336. if (data_info[i].equip_location) {
  337. var flag = true;
  338. } else {
  339. var flag = false;
  340. }
  341. // 将标注添加到地图中
  342. addClickHandler(content, marker, enterNum, flag);
  343. }
  344. }
  345. //让所有点在视野范围内
  346. map.setViewport(pointArray);
  347. }
  348. function addClickHandler(content, marker, enterNum, flag) {
  349. marker.addEventListener("click", function (e) {
  350. if (!flag) {
  351. var pt = marker.point;
  352. geoc.getLocation(pt, function (rs) {
  353. var addComp = rs.addressComponents;
  354. $('.area').html('位置:' + addComp.province + ", " + addComp.city + ", " + addComp.district)
  355. // alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
  356. });
  357. }
  358. openInfo(content, e, enterNum)
  359. }
  360. );
  361. }
  362. function openInfo(content, event, orgname) {
  363. var p = event.target;
  364. var opts = {
  365. title: orgname, // 信息窗口标题
  366. enableMessage: true//设置允许信息窗发送短息
  367. };
  368. var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
  369. var infoWindow = new BMap.InfoWindow(content, opts); // 创建信息窗口对象
  370. map.openInfoWindow(infoWindow, point); //开启信息窗口
  371. }
  372. // 查询相对类型的数据
  373. $('#selectType').on('click', 'span', function () {
  374. var dtype = $(this).data('type');
  375. if (dtype == 2 || dtype == 3 || dtype == 5 || dtype == 7 || dtype == 8) {
  376. if (dtype == 2) { dtype = "scd" }
  377. else if (dtype == 3) { dtype = "cbd" }
  378. else if (dtype == 5) { dtype = "qxz" }
  379. else if (dtype == 7) { dtype = "bzy" }
  380. else if (dtype == 8) { dtype = "xyq" }
  381. map.clearOverlays();//清除全部
  382. $.ajax({
  383. type: "post",
  384. url: "home_map/map_locat",
  385. data: { req: dtype },
  386. dataType: "json",
  387. success: function (data) {
  388. map.clearOverlays();//清除全部
  389. eachItem(data)
  390. }
  391. });
  392. } else if (dtype == 0) {
  393. map.clearOverlays();//清除全部
  394. $.ajax({
  395. type: "post",
  396. url: "home_map/map_locat",
  397. data: {
  398. req: "cbd",
  399. },
  400. dataType: "json",
  401. success: function (data) {
  402. eachItem(data)
  403. }
  404. });
  405. $.ajax({
  406. type: "post",
  407. url: "home_map/map_locat",
  408. data: {
  409. req: "scd",
  410. },
  411. dataType: "json",
  412. success: function (data) {
  413. eachItem(data)
  414. }
  415. });
  416. $.ajax({
  417. type: "post",
  418. url: "home_map/map_locat",
  419. data: {
  420. req: "qxz",
  421. },
  422. dataType: "json",
  423. success: function (data) {
  424. eachItem(data)
  425. }
  426. });
  427. $.ajax({
  428. type: "post",
  429. url: "home_map/map_locat",
  430. data: {
  431. req: "bzy",
  432. },
  433. dataType: "json",
  434. success: function (data) {
  435. eachItem(data)
  436. }
  437. });
  438. $.ajax({
  439. type: "post",
  440. url: "home_map/map_locat",
  441. data: {
  442. req: "xyq",
  443. },
  444. dataType: "json",
  445. success: function (data) {
  446. eachItem(data)
  447. }
  448. });
  449. } else {
  450. // layer.msg("此功能暂未开启!", { time: 2000 });
  451. }
  452. })
  453. //搜索城市
  454. $('#searchCityBtn').on('click', searchCity);
  455. $('#searchCity').on('keyup', function (event) {
  456. if (event.keyCode == 13) {
  457. searchCity();
  458. }
  459. })
  460. function searchCity() {
  461. var local = new BMap.LocalSearch(map, {
  462. renderOptions: { map: map, panel: "r-result" },
  463. pageCapacity: 5
  464. });
  465. local.search($('#searchCity').val());
  466. }
  467. //搜索imei
  468. $('#searchBtn').on('click', searchImei);
  469. $('#searchImei').on('keyup', function (event) {
  470. if (event.keyCode == 13) {
  471. searchImei();
  472. }
  473. })
  474. function searchImei() {
  475. var imei = $('#searchImei').val();
  476. if (imei != '') {
  477. $.ajax({
  478. type: "post",
  479. url: "home_map/map_locat",
  480. data: {
  481. req: "imei",
  482. equip_id: imei
  483. },
  484. dataType: "json",
  485. success: function (data) {
  486. if (data == '0') {
  487. layer.msg("没有找到该设备,请核对设备id!", { time: 2000 });
  488. map.clearOverlays();//清除全部
  489. }
  490. else {
  491. map.clearOverlays();//清除全部
  492. eachItem(data)
  493. }
  494. }
  495. });
  496. } else {
  497. layer.msg("请输入imei!", { time: 2000 });
  498. }
  499. }
  500. var as = [{ "equip_id": "11111111", "equip_type": 3, "equip_name": "", "lng": "113.66080475001185", "lat": "34.81039429", "equip_location": "" }]
  501. function gotoManageDetial(imei, orgType) {
  502. var sidebar = $('#sidebar', parent.document);
  503. var menuLi = sidebar.find('.nav-list.nav').children();
  504. if (orgType == 3 || orgType == 2) {
  505. menuLi.each(function (idx, val) {
  506. $(val).removeClass('active');
  507. if ($(val).children('a').find('.menu-text').html() == '报表管理') {
  508. $(val).addClass('active');
  509. $(val).addClass('open');
  510. $(val).children('ul').removeClass('nav-hide').addClass('nav-show').show();
  511. if (orgType == 3) {
  512. $(val).children('ul').children().each(function (index, obj) {
  513. if ($(obj).find('.menu-text').html() == '虫情测报') {
  514. $(obj).addClass('active');
  515. }
  516. })
  517. } else if (orgType == 2) {
  518. $(val).children('ul').children().each(function (index, obj) {
  519. if ($(obj).find('.menu-text').html() == '杀虫灯') {
  520. $(obj).addClass('active');
  521. }
  522. })
  523. }
  524. }
  525. })
  526. }
  527. if (orgType == 3) {
  528. location.href = 'cbd_report_detail?id=' + imei;
  529. } else if (orgType == 2) {
  530. location.href = 'scd_report_detail?id=' + imei;
  531. }
  532. }