bigScreenMap.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. var currVal = '';
  2. // cbdchange
  3. $('#cbdList').on('select2:opening', function () {
  4. var id = $(this).val()
  5. currVal = id;
  6. })
  7. $('#cbdList').on('change', function () {
  8. var id = $(this).val()
  9. layui.use('layer', function () {
  10. var layer = layui.layer;
  11. layer.confirm('是否切换当前测报灯设备', {
  12. title: false,
  13. closeBtn: 0,
  14. btn: ['确定', '取消'] //按钮
  15. }, function () {
  16. getCbdInfo(id);
  17. layer.close(layer.index)
  18. }, function () {
  19. $('#cbdList').val(currVal).select2({width: '55%'});
  20. });
  21. })
  22. })
  23. // jkchange
  24. $('#jkList').on('select2:opening', function () {
  25. var id = $(this).val()
  26. currVal = id;
  27. })
  28. $('#jkList').on('change', function () {
  29. var id = $(this).val()
  30. layui.use('layer', function () {
  31. var layer = layui.layer;
  32. layer.confirm('是否切换当前显示监控', {
  33. title: false,
  34. closeBtn: 0,
  35. btn: ['确定', '取消'] //按钮
  36. }, function () {
  37. getjkPath(id);
  38. layer.close(layer.index)
  39. }, function () {
  40. $('#jkList').val(currVal).select2({width: '55%'});
  41. });
  42. })
  43. })
  44. // bzychange
  45. $('#bzyList').on('select2:opening', function () {
  46. var id = $(this).val()
  47. currVal = id;
  48. })
  49. $('#bzyList').on('change', function () {
  50. var id = $(this).val()
  51. layui.use('layer', function () {
  52. var layer = layui.layer;
  53. layer.confirm('是否切换当前孢子仪设备', {
  54. title: false,
  55. closeBtn: 0,
  56. btn: ['确定', '取消'] //按钮
  57. }, function () {
  58. getBzyInfo(id);
  59. layer.close(layer.index)
  60. }, function () {
  61. $('#bzyList').val(currVal).select2({width: '55%'});
  62. });
  63. })
  64. })
  65. // qxzchange
  66. $('#qxzList').on('select2:opening', function () {
  67. var id = $(this).val()
  68. currVal = id;
  69. })
  70. $('#qxzList').on('change', function () {
  71. var id = $(this).val()
  72. layui.use('layer', function () {
  73. var layer = layui.layer;
  74. layer.confirm('是否切换当前环境监测设备', {
  75. title: false,
  76. closeBtn: 0,
  77. btn: ['确定', '取消'] //按钮
  78. }, function () {
  79. getQxzInfo(id);
  80. layer.close(layer.index)
  81. }, function () {
  82. $('#qxzList').val(currVal).select2({width: '55%'});
  83. });
  84. })
  85. })
  86. // 查看设备分布
  87. $('.equipTotal').on('click',function(){
  88. var url = 'display_map?type='+$(this).attr('type');
  89. if($(this).attr('type') == 3 || $(this).attr('type') == 7 || $(this).attr('type') == 'all'){
  90. layui.use('layer', function () {
  91. var layer = layui.layer;
  92. layer.open({
  93. type: 2,
  94. title: '',
  95. shadeClose: true,
  96. shade: 0.5,
  97. area: ['1100px', '90%'],
  98. skin: 'layer-test', //自定义class
  99. content: url //iframe的url
  100. })
  101. })
  102. }else{
  103. layui.use('layer', function () {
  104. var layer = layui.layer;
  105. layer.msg('定位功能暂未开启', {time: 2000, icon:4});
  106. })
  107. }
  108. console.log($(this).attr('type'))
  109. })
  110. var map = new AMap.Map('container', {
  111. resizeEnable: true
  112. });
  113. if($('#userCurrCity').val()){
  114. onComplete($('#userCurrCity').val())
  115. }else{
  116. AMap.plugin('AMap.Geolocation', function () {
  117. var geolocation = new AMap.Geolocation({
  118. enableHighAccuracy: true,//是否使用高精度定位,默认:true
  119. timeout: 10000, //超过10秒后停止定位,默认:5s
  120. buttonPosition: 'RB', //定位按钮的停靠位置
  121. buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
  122. zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点
  123. });
  124. map.addControl(geolocation);
  125. geolocation.getCurrentPosition(function (status, result) {
  126. if (status == 'complete') {
  127. onComplete(result.addressComponent.city)
  128. } else {
  129. onComplete('郑州市')
  130. }
  131. });
  132. });
  133. }
  134. //解析定位结果
  135. function onComplete(data) {
  136. var city = data;
  137. AMap.plugin('AMap.Weather', function () {
  138. var weather = new AMap.Weather();
  139. //未来4天天气预报
  140. weather.getForecast(data, function (err, data) {
  141. if (err) { return; }
  142. var str = '';
  143. dayWeather = data.forecasts[0];
  144. str += '<div class="weathericon"><img src="../static/bigData/image/weatherIcon/' + weatherIcon[dayWeather.dayWeather] + '" width="30" alt="">' +
  145. '</div><div class="weatherval"><p>' + city + '</p><p>' + dayWeather.nightTemp + '~' + dayWeather.dayTemp + '℃</p></div><div><P>' + dayWeather.dayWeather + '</P></div>'
  146. $('.weatherInner').html(str)
  147. });
  148. });
  149. }