warningMap.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 href="../css/mui.min.css" rel="stylesheet" />
  8. <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
  9. <link href="../css/common.css" rel="stylesheet" />
  10. <style type="text/css">
  11. .mui-content {
  12. position: absolute;
  13. left: 0;
  14. top: 0;
  15. bottom: 0;
  16. right: 0;
  17. }
  18. .mapCover {
  19. position: absolute;
  20. left: 0;
  21. top: 50px;
  22. bottom: 0;
  23. right: 0;
  24. }
  25. #map {
  26. width: 100%;
  27. height: 100%;
  28. }
  29. /*预警按钮*/
  30. .warningRatio {
  31. position: fixed;
  32. left: 0;
  33. right: 0;
  34. bottom: 30px;
  35. text-align: center;
  36. z-index: 2;
  37. }
  38. .warningRatio button {
  39. border-radius: 18px;
  40. background: #21b2e7;
  41. color: #fff;
  42. border: none;
  43. }
  44. .warningRatio i {
  45. margin-right: 5px;
  46. }
  47. /*预警详情*/
  48. .warningEchart {
  49. position: fixed;
  50. left: 0;
  51. right: 0;
  52. bottom: 0;
  53. }
  54. .echartInner {
  55. position: absolute;
  56. left: 0;
  57. right: 0;
  58. bottom: 0;
  59. height: 0;
  60. width: 100%;
  61. background: #fff;
  62. border-radius: 20px 20px 0 0;
  63. /*padding: 25px 15px;*/
  64. }
  65. #pie-chart {
  66. width: 100%;
  67. height: 300px;
  68. }
  69. .mui-col-xs-6 {
  70. position: absolute;
  71. left: 0;
  72. right: 0;
  73. top: 0;
  74. bottom: 0;
  75. }
  76. .echartInner .closeBtn{
  77. position: absolute;
  78. right: 14px;
  79. top: 12px;
  80. border-radius: 50%;
  81. padding: 0;
  82. width: 28px;
  83. height: 28px;
  84. background: #d1d1d1;
  85. border: none;
  86. z-index: 3;
  87. }
  88. .closeBtn i{
  89. color: #fff;
  90. }
  91. </style>
  92. </head>
  93. <body>
  94. <header class="mui-bar mui-bar-nav">
  95. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  96. <h1 class="mui-title">地图预警</h1>
  97. </header>
  98. <div class="mui-content">
  99. <div class="mapCover">
  100. <div id="map"></div>
  101. </div>
  102. <!--预警按钮-->
  103. <div class="warningRatio">
  104. <button id="warningRatioBtn">
  105. <i class="fa fa-pie-chart" aria-hidden="true"></i>预警百分比
  106. </button>
  107. </div>
  108. <!--预警详情-->
  109. <div class="warningEchart">
  110. <div class="echartInner mui-row">
  111. <button class="closeBtn">
  112. <i class="fa fa-close" aria-hidden="true"></i>
  113. </button>
  114. <!--<div class="mui-col-xs-6">-->
  115. <div id="pie-chart"></div>
  116. <!--</div>
  117. <div class="mui-col-xs-6">
  118. </div>-->
  119. </div>
  120. </div>
  121. <!--<div class="mui-row">
  122. <div class="mui-col-xs-6">s</div>
  123. <div class="mui-col-xs-6">s</div>
  124. </div>-->
  125. </div>
  126. <script src="../js/jquery-2.1.0.js"></script>
  127. <script src="../js/mui.min.js"></script>
  128. <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=La58N63t7hPhafQ7Eror2kon"></script>
  129. <script src="https://cdn.bootcss.com/echarts/3.8.5/echarts.js"></script>
  130. <script type="text/javascript">
  131. mui.init();
  132. //百度地图获取坐标
  133. var map = new BMap.Map("map"); // 创建地图实例
  134. map.centerAndZoom(new BMap.Point(113.64964385, 34.75661006), 13); // 创建点坐标
  135. map.enableScrollWheelZoom(true);
  136. map.addControl(new BMap.ScaleControl()); // 添加比例尺控件
  137. map.addControl(new BMap.NavigationControl()); //为地图添加鱼骨(默认)
  138. map.addEventListener("tilesloaded", function() {
  139. $(".BMap_cpyCtrl").hide();
  140. // $(".anchorBL").hide();
  141. }); //地图加载完毕后 隐藏百度图标
  142. //图表
  143. var pieChart = echarts.init(document.getElementById('pie-chart'));
  144. var pieoption = {
  145. tooltip: {
  146. trigger: 'item',
  147. formatter: "{a} <br/>{b} : {c} ({d}%)"
  148. },
  149. // legend: {
  150. // orient: 'horizontal',
  151. // left: 'left',
  152. // data: ['杀虫灯', '虫情测报', '气象设备']
  153. // },
  154. series: [{
  155. name: '访问来源',
  156. type: 'pie',
  157. radius: [0, '50%'],
  158. // center: ['50%', '50%'],
  159. data: [{
  160. value: 335,
  161. name: '杀虫灯'
  162. },
  163. {
  164. value: 310,
  165. name: '虫情测报'
  166. },
  167. {
  168. value: 234,
  169. name: '气象设备'
  170. }
  171. ],
  172. itemStyle: {
  173. normal: {
  174. label: {
  175. show: true,
  176. formatter: '{b} : {c} \n ({d}%)'
  177. },
  178. labelLine: {
  179. show: true
  180. }
  181. },
  182. emphasis: {
  183. shadowBlur: 10,
  184. shadowOffsetX: 0,
  185. shadowColor: 'rgba(0, 0, 0, 0.5)'
  186. }
  187. }
  188. }],
  189. color: ['#9cddff', '#0e86c3', '#42b9f6']
  190. };
  191. pieChart.setOption(pieoption);
  192. //查看预警详情
  193. document.getElementById('warningRatioBtn').addEventListener('tap',function(){
  194. $('.warningEchart').css('z-index','3');
  195. $('.echartInner').animate({
  196. 'height':'300'
  197. })
  198. })
  199. //关闭预警详情
  200. document.querySelector('.closeBtn').addEventListener('tap',function(){
  201. $('.echartInner').animate({
  202. 'height':'0'
  203. },500)
  204. setTimeout(function(){
  205. $('.warningEchart').css('z-index','0');
  206. },500)
  207. })
  208. </script>
  209. </body>
  210. </html>