forestFireproofing.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. {% load staticfiles %}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8" />
  6. <link href="{% static '/lib/bootstrap-3.3.7/css/bootstrap.css' %}" rel="stylesheet">
  7. <link rel="stylesheet" href="{% static '/lib/font-awesome/4.5.0/css/font-awesome.css' %}">
  8. <link rel="stylesheet" href="{% static '/lib/css/ace.min.css' %}" />
  9. <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
  10. <!-- <link rel="stylesheet" href="{% static '/lib/css/ace-skins.min.css' %}"> -->
  11. <!-- <link rel="stylesheet" href="{% static '/lib/css/ace-rtl.min.css' %}"> -->
  12. <title>森林防火</title>
  13. <style>
  14. body {
  15. background: #fff;
  16. }
  17. /* 打开窗体自定义 */
  18. .openWindow{
  19. position: relative;
  20. border: solid 1px silver;
  21. background-color: #fff;
  22. border-radius: 5px;
  23. width: 300px;
  24. }
  25. .openWindow .title{
  26. line-height: 30px;
  27. border-bottom: solid 1px silver;
  28. padding-left: 15px;
  29. }
  30. .openWindow .title img{
  31. position: absolute;
  32. top: 10px;
  33. right: 10px;
  34. transition-duration: 0.25s;
  35. cursor: pointer;
  36. }
  37. .openWindow .title.error{
  38. color: red;
  39. }
  40. .openWindow .area{
  41. font-size: 12px;
  42. color: #646464;
  43. padding: 10px 15px;
  44. }
  45. .openWindow .elementUl{
  46. display: flex;
  47. justify-content: space-around;
  48. margin: 0px 10px;
  49. }
  50. .openWindow .elementUl li{
  51. text-align: center;
  52. }
  53. .openWindow .lookJkDiv{
  54. text-align: center;
  55. margin: 10px;
  56. }
  57. .openWindow .lookJkDiv button{
  58. border: none;
  59. background: #55b0ff;
  60. color: #fff;
  61. padding: 4px 10px;
  62. border-radius: 11px;
  63. font-size: 12px;
  64. letter-spacing: 1px;
  65. }
  66. .bottom-center .amap-info-sharp{
  67. bottom: 1px;
  68. }
  69. </style>
  70. <body>
  71. <div class="content">
  72. <!-- <div class="page-header">
  73. <h1>
  74. <font style="vertical-align: inherit;">
  75. <font style="vertical-align: inherit;">
  76. 无人机
  77. </font>
  78. </font>
  79. </h1>
  80. </div> -->
  81. <div id="map"></div>
  82. </div>
  83. <script src="{% static '/lib/js/jquery-2.1.4.min.js' %}"></script>
  84. <script src="{% static '/lib/bootstrap-3.3.7/js/bootstrap.js' %}"></script>
  85. <script type="text/javascript" src='//webapi.amap.com/maps?v=1.4.15&key=a223a998dc112437cb32afb43a8b2c24'></script>
  86. <!-- UI组件库 1.0 -->
  87. <!-- <script src="//webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script> -->
  88. <script src="{% static '/js/common.js' %}?versions=0.5.0"></script>
  89. <script>
  90. $.ajaxSetup({
  91. data: {
  92. csrfmiddlewaretoken: '{{ csrf_token }}'
  93. },
  94. });
  95. </script>
  96. <script>
  97. getHeight()
  98. //创建地图
  99. var map = new AMap.Map('map', {
  100. zoom: 8
  101. });
  102. map.add(new AMap.TileLayer.Satellite());
  103. var dataArr = [
  104. {
  105. title:'监测点一',
  106. random:2,
  107. position:[114.342379,34.847584]
  108. },
  109. {
  110. title:'监测点二',
  111. random:1,
  112. position:[114.117159,35.029959]
  113. },
  114. {
  115. title:'监测点三',
  116. random:3,
  117. position:[113.235506,34.901663]
  118. },
  119. {
  120. title:'监测点四',
  121. random:5,
  122. position:[114.323153,34.47709]
  123. },
  124. {
  125. title:'监测点五',
  126. random:8,
  127. position:[114.142379,34.847584]
  128. },
  129. ]
  130. var markers = [];
  131. for(var i = 0 ;i<dataArr.length;i++){
  132. // 创建一个 Marker 实例:
  133. if(dataArr[i].random % 2 == 0){
  134. var image = "../static/bigData/imgs/icon5.svg";
  135. }else{
  136. var image = "../static/bigData/imgs/icon4.svg";
  137. }
  138. var marker = new AMap.Marker({
  139. position: dataArr[i].position, // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
  140. icon: new AMap.Icon({
  141. image: image,
  142. size: new AMap.Size(32,32), //图标大小
  143. imageSize: new AMap.Size(32,32)
  144. }),
  145. extData:dataArr[i]
  146. });
  147. marker.on('click',function(e){
  148. console.log(e.target.getExtData())
  149. openInfo(e,e.target.getExtData())
  150. })
  151. markers.push(marker);
  152. if(i == dataArr.length-1){
  153. console.log(markers)
  154. map.add(markers);
  155. }
  156. }
  157. //在指定位置打开信息窗体
  158. function openInfo(e,infoMsg) {
  159. //构建信息窗体中显示的内容
  160. if(infoMsg.random % 2 == 0){
  161. var className = "error";
  162. }else{
  163. var className = "";
  164. }
  165. var info = '<div class="openWindow">';
  166. info += '<div class="title '+className+'">'+infoMsg.title+'<img onclick="closeInfoWindow()" src="https://webapi.amap.com/images/close2.gif"></div>';
  167. info += '<div class="area">详细地址:河南省郑州市金水区瀚海北金B座</div>';
  168. info += '<ul class="elementUl"><li><div>20°C</div><p>空气温度</p></li><li><div>70%</div><p>空气湿度</p></li><li><div>西南偏北</div><p>风向</p></li><li><div>0</div><p>降雨量</p></li></ul>';
  169. info += '<div class="lookJkDiv"><button onclick="getJkPage('+infoMsg.random+')">查看监控</button></div></div><div class="amap-info-sharp"></div>'
  170. infoWindow = new AMap.InfoWindow({
  171. isCustom: true, //使用自定义窗体
  172. content: info, //使用默认信息窗体框样式,显示信息内容
  173. offset: new AMap.Pixel(8, -28)
  174. });
  175. infoWindow.open(map, e.target.getPosition());
  176. }
  177. function getHeight() {
  178. var width = $('#map').css('width').replace("px", "");
  179. var height = width * (9 / 16)
  180. console.log(width)
  181. console.log(height)
  182. $('#map').css('height', height)
  183. scrollBar()
  184. }
  185. function getJkPage(id){
  186. window.location.href = 'equipmanage_jk'
  187. }
  188. //关闭信息窗体
  189. function closeInfoWindow() {
  190. map.clearInfoWindow();
  191. }
  192. window.onresize = function () {
  193. getHeight()
  194. }
  195. </script>
  196. </body>
  197. </html>