alarm_map.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. {% load staticfiles %}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <title>地图预警</title>
  6. <meta charset="UTF-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  8. <link rel="stylesheet" href="{% static '/css/matrix-style2.css' %}" />
  9. <link rel="stylesheet" href="{% static '/css/matrix-media.css' %}" />
  10. <link rel="stylesheet" href="{% static '/css/page.css' %}" />
  11. <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=TcRPmrsiZUqdUBWoELrUArRkCRC36KMx"></script>
  12. <style type="text/css">
  13. body {
  14. overflow: hidden;
  15. }
  16. .line1 {
  17. margin-top: 20px;
  18. color: #C23531;
  19. }
  20. .line1 div {
  21. float: left;
  22. height: 20px;
  23. background-color: #C23531;
  24. width: 174px;
  25. }
  26. .line2 {
  27. margin-top: 20px;
  28. color: #2F4554;
  29. }
  30. .line2 div {
  31. float: left;
  32. background-color: #2F4554;
  33. width: 123px;
  34. height: 20px;
  35. }
  36. .line3 {
  37. margin-top: 20px;
  38. color: #61A0A8;
  39. }
  40. .line3 div {
  41. float: left;
  42. background-color: #61A0A8;
  43. width: 0px;
  44. height: 20px;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <div class="content">
  50. <div id="content-header">
  51. <h1 class="tb-fpsb" style="display: inline-block;">
  52. 预警
  53. </h1>
  54. <span id="">
  55. > 地图预警
  56. </span>
  57. </div>
  58. <div class="warning-box">
  59. <div class="warning-map" id="warning-map"></div>
  60. <div id="bing" style=" width:50%;height:300px; float: left;"></div>
  61. <div style="float: left;width: 30%;margin: 3% 3%;">
  62. <p style="font-size: 20px;text-align: center;margin-bottom: 60px; ">预警百分比</p>
  63. <div class="line1">
  64. <div></div>
  65. <span style="margin-left: 10px;">气象设备预警58%</span>
  66. </div>
  67. <div class="line2">
  68. <div></div>
  69. <span style="margin-left: 10px;">杀虫灯预警41%</span>
  70. </div>
  71. <div class="line3">
  72. <div></div>
  73. <span style="margin-left: 10px;">虫情测报预警0%</span>
  74. </div>
  75. </div>
  76. </div>
  77. <!-- <div class="container-fluid">
  78. <div class="row-fluid">
  79. <div class="span12">
  80. <div class="pie-type-box">
  81. <div class="widget-title"> <span class="icon"> <i class="icon-signal"></i> </span>
  82. <h5>Bar chart</h5>
  83. </div>
  84. <div class="widget-content">
  85. <div class="chart"></div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div> -->
  91. </div>
  92. <!-- <script src="{% static 'js/bootstrap.min.js' %}"></script>
  93. <script src="{% static 'js/jquery.flot.min.js' %}"></script>
  94. <script src="{% static 'js/jquery.flot.pie.min.js' %}"></script>
  95. <script src="{% static 'js/matrix.charts.js' %}"></script>
  96. <script src="{% static 'js/matrix.js' %}"></script> -->
  97. <script src="{% static '/lib/js/jquery-2.1.4.min.js' %}"></script>
  98. <script src="{% static '/lib/js/echarts.min.js' %}"></script>
  99. <script type="text/javascript">
  100. if ($('.content').height() > 750) {
  101. $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
  102. } else {
  103. $('#iframe-main', parent.document).css('height', '750px')
  104. }
  105. var chart = echarts.init(document.getElementById('bing'));
  106. option = {
  107. title: {
  108. x: 'center'
  109. },
  110. tooltip: {
  111. trigger: 'item',
  112. formatter: "{a} <br/>{b} : {c} ({d}%)"
  113. },
  114. legend: {
  115. },
  116. series: [
  117. {
  118. name: '预警百分比',
  119. type: 'pie',
  120. radius: '55%',
  121. center: ['50%', '60%'],
  122. data: [
  123. { value: 58, name: '气象设备' },
  124. { value: 41, name: '杀虫灯' },
  125. { value: 0, name: '虫情测报' },
  126. ],
  127. itemStyle: {
  128. emphasis: {
  129. shadowBlur: 10,
  130. shadowOffsetX: 0,
  131. shadowColor: 'rgba(0, 0, 0, 0.5)'
  132. }
  133. }
  134. }
  135. ]
  136. };
  137. chart.setOption(option);
  138. </script>
  139. <script type="text/javascript">
  140. //百度地图API功能
  141. var map = new BMap.Map("warning-map"); // 创建地图实例
  142. var point = new BMap.Point(116.404, 39.915); // 创建点坐标
  143. map.centerAndZoom(point, 13); // 初始化地图,设置中心点坐标和地图级别
  144. map.enableScrollWheelZoom(true);
  145. map.addControl(new BMap.MapTypeControl()); //添加地图类型控件
  146. map.addControl(new BMap.ScaleControl()); // 添加比例尺控件
  147. var geolocation = new BMap.Geolocation();
  148. geolocation.getCurrentPosition(function (r) {
  149. if (this.getStatus() == BMAP_STATUS_SUCCESS) {
  150. var mk = new BMap.Marker(r.point);
  151. map.addOverlay(mk);
  152. map.panTo(r.point);
  153. }
  154. else {
  155. alert('failed' + this.getStatus());
  156. }
  157. }, { enableHighAccuracy: true });
  158. //关于状态码
  159. //BMAP_STATUS_SUCCESS 检索成功。对应数值“0”。
  160. //BMAP_STATUS_CITY_LIST 城市列表。对应数值“1”。
  161. //BMAP_STATUS_UNKNOWN_LOCATION 位置结果未知。对应数值“2”。
  162. //BMAP_STATUS_UNKNOWN_ROUTE 导航结果未知。对应数值“3”。
  163. //BMAP_STATUS_INVALID_KEY 非法密钥。对应数值“4”。
  164. //BMAP_STATUS_INVALID_REQUEST 非法请求。对应数值“5”。
  165. //BMAP_STATUS_PERMISSION_DENIED 没有权限。对应数值“6”。(自 1.1 新增)
  166. //BMAP_STATUS_SERVICE_UNAVAILABLE 服务不可用。对应数值“7”。(自 1.1 新增)
  167. //BMAP_STATUS_TIMEOUT 超时。对应数值“8”。(自 1.1 新增)
  168. // 添加带有定位的导航控件
  169. var navigationControl = new BMap.NavigationControl({
  170. // 靠左上角位置
  171. anchor: BMAP_ANCHOR_TOP_LEFT,
  172. // LARGE类型
  173. type: BMAP_NAVIGATION_CONTROL_LARGE,
  174. // 启用显示定位
  175. enableGeolocation: true
  176. });
  177. map.addControl(navigationControl);
  178. // 添加定位控件
  179. var geolocationControl = new BMap.GeolocationControl();
  180. geolocationControl.addEventListener("locationSuccess", function (e) {
  181. // 定位成功事件
  182. var address = '';
  183. address += e.addressComponent.province;
  184. address += e.addressComponent.city;
  185. address += e.addressComponent.district;
  186. address += e.addressComponent.street;
  187. address += e.addressComponent.streetNumber;
  188. });
  189. geolocationControl.addEventListener("locationError", function (e) {
  190. // 定位失败事件
  191. alert(e.message);
  192. });
  193. map.addControl(geolocationControl);
  194. function getBoundary() {
  195. }
  196. getBoundary();
  197. </script>
  198. </body>
  199. </html>