map.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Aisky-Sixth</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  8. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  9. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  10. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  11. <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
  12. <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  13. <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
  14. <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  15. <!--可用來建立使用者小圖示-->
  16. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  17. <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>
  18. <style>
  19. body {
  20. margin:0;
  21. }
  22. .navbar-dark .navbar-nav .nav-link {
  23. color: white;
  24. cursor: pointer;
  25. text-decoration:none;
  26. width: 110px;
  27. height: 46px;
  28. }
  29. .nav-top {
  30. line-height:40px;
  31. background-color: #C4C4C4;
  32. }
  33. .website_title{
  34. font-family: Roboto;
  35. font-style: normal;
  36. font-weight: normal;
  37. font-size: 30px;
  38. color: #000000;
  39. }
  40. .navbar-nav > li{
  41. float: none;
  42. display: inline-block;
  43. width: 110px;
  44. margin: 0 auto;
  45. text-align: center;
  46. }
  47. .navbar-nav > li a{
  48. font-size: 20px;
  49. }
  50. .main-page {
  51. margin-top: 200px;
  52. }
  53. .page-title {
  54. font-family: Roboto;
  55. font-style: normal;
  56. font-weight: bold;
  57. font-size: 36px;
  58. }
  59. .flex {
  60. display: flex;
  61. flex-direction: row;
  62. flex-wrap: wrap;
  63. justify-content: center;
  64. }
  65. .set-link {
  66. display: inline-block;
  67. width: 350px;
  68. height: 100px;
  69. line-height: 100px;
  70. background: #008CBA;
  71. border: 1px solid #CFCFCF;
  72. box-sizing: border-box;
  73. color: #FFFFFF;
  74. border-radius: 10px;
  75. font-size: 36px;
  76. }
  77. .fa{
  78. display: inline-block;
  79. font: normal normal normal 14px/1 FontAwesome;
  80. font-size: inherit;
  81. text-rendering: auto;
  82. -webkit-font-smoothing: antialiased;
  83. }
  84. .fa-user-o:before{
  85. content: "\f2c0";
  86. }
  87. .abc {background:lightgreen;border:1px #000 solid;cursor:move;padding:10px 5px;}
  88. .draggable {min-width:50px;height:45px;display:inline-block;font-size:.9em;z-index:1;text-align:center;}
  89. @media(max-width:373px){
  90. .card {
  91. margin-right: 0px;
  92. }
  93. }
  94. @media(max-width:577px){
  95. }
  96. @media(min-width:576px){
  97. }
  98. @media(min-width:768px){
  99. .navbar-nav > li {
  100. margin-left: 0px;
  101. }
  102. .navbar-nav .li-block {
  103. display:none;
  104. }
  105. }
  106. @media(min-width:991px){
  107. .navbar-nav > li {
  108. margin-left: 20px;
  109. }
  110. .navbar-nav .li-block {
  111. display:none;
  112. }
  113. }
  114. @media(min-width:1200px){
  115. .navbar-nav > li {
  116. margin-left: 35px;
  117. }
  118. .navbar-nav .li-block {
  119. display: inline-block;
  120. width: 100px;
  121. }
  122. }
  123. @media(min-width:1400px){
  124. .navbar-nav .li-block {
  125. display: inline-block;
  126. width: 200px;
  127. }
  128. }
  129. @media(min-width:1689px) {
  130. .navbar-nav > li {
  131. margin-left: 50px;
  132. }
  133. .navbar-nav .li-block {
  134. display: inline-block;
  135. width: 500px;
  136. }
  137. }
  138. </style>
  139. <style>
  140. html, body, #map-canvas{
  141. width:100%;
  142. height: 100%;
  143. }
  144. </style>
  145. <script>
  146. var img_id = 0;
  147. $(function(){
  148. //判斷客戶如果是上傳圖片
  149. {% if params.path %}
  150. var path = '..' + '{{params.path}}'.substring(3);
  151. $("#farm_img").attr('src', path);
  152. $("#map-canvas").css('display', 'none');
  153. img_id = "#farm_img";
  154. var node_div = document.getElementById('node-list');
  155. var i = 1;
  156. var num = 0;
  157. {% for node in params.nodes %}
  158. if(i < 10){
  159. i = "0" + i
  160. };
  161. if(i > 1){
  162. num = num + 50;
  163. };
  164. var div = document.createElement('div');
  165. var html = '';
  166. html += '<p style="font-weight: bold;">' + '{{node.node_name}}' + '</p>';
  167. <!--html += '<input type="hidden" name="lat' + i + '" id="a' + i + '-1" value="' + '{{node.pos_lat}}' + '"></input>';-->
  168. <!--html += '<input type="hidden" name="lng' + i + '" id="a' + i + '-2" value="' + '{{node.pos_lng}}' + '"></input>';-->
  169. div.innerHTML = html;
  170. div.setAttribute('id', 'a' + i);
  171. div.setAttribute('class', 'draggable abc');
  172. div.style.position = 'relative';
  173. div.style.inset = '{{node.pos_lng}}px' + ' auto auto ' + (Number({{node.pos_lat}})-15-num) + 'px';
  174. node_div.appendChild(div);
  175. i ++;
  176. {% endfor %}
  177. //判斷用戶如果是輸入地址
  178. {% else %}
  179. $("#farm_img").css('display', 'none');
  180. img_id = "#map-canvas";
  181. function initialize() {
  182. var a = -1;
  183. var mapOptions = {
  184. center: { lat: {{params.lat}}, lng: {{params.lng}}},
  185. <!--center: { lat: 22.707340, lng: 120.531000},-->
  186. zoom: 19,
  187. mapTypeId: 'satellite',
  188. };
  189. var map = new google.maps.Map(
  190. document.getElementById('map-canvas'),
  191. mapOptions);
  192. var i = 1;
  193. {% for node in params.nodes %}
  194. if(i < 10){
  195. i = "0" + i
  196. };
  197. var defineStr = "var position" + i.toString();
  198. var defineStr2 = "var marker" + i.toString();
  199. //使用eval()函數執行字串
  200. eval(defineStr);
  201. eval(defineStr2);
  202. //為position賦值
  203. eval("position" + i.toString() + " = " + "{lat:" + {{node.pos_lat}} + ",lng:" + {{node.pos_lng}} + "};");
  204. //為marker賦值
  205. eval("marker" + i.toString() + " = " + "new google.maps.Marker({position:" + ("position" + i.toString()) + ",map:map,label:'" + i + "'});");
  206. i ++;
  207. {% endfor %}
  208. };
  209. google.maps.event.addDomListener(
  210. window, 'load', initialize);
  211. {% endif %}
  212. });
  213. function img_error() {
  214. //this.src='./inimage/psfi.jpg';
  215. document.getElementById("" + img_id).src="../static/img/psfi.jpg";
  216. $('#a01').draggable('option','disabled', true);
  217. $('#a01').css('background-color', 'red');
  218. $('#a02').draggable('option','disabled', true);
  219. $('#a02').css('background-color', 'red');
  220. $('#a03').draggable('option','disabled', true);
  221. $('#a03').css('background-color', 'red');
  222. $('#a04').draggable('option','disabled', true);
  223. $('#a04').css('background-color', 'red');
  224. $('#a05').draggable('option','disabled', true);
  225. $('#a05').css('background-color', 'red');
  226. $('#a06').draggable('option','disabled', true);
  227. $('#a06').css('background-color', 'red');
  228. };
  229. //-------------------------------------------------------
  230. var inputVal = document.getElementById("filename");
  231. var OK = document.getElementById("OK");
  232. if (inputVal.value == "") {
  233. inputVal.style.backgroundColor = "#e67300";
  234. document.getElementById("" + img_id).src="";
  235. }
  236. else{
  237. inputVal.style.backgroundColor = "";
  238. };
  239. //---------------------------------------------------------
  240. function refreshPage(){
  241. //window.location.reload(true); //error in safari
  242. $('#rq').submit();
  243. };
  244. </script>
  245. </head>
  246. <body>
  247. <nav class="fixed-top">
  248. <nav class="navbar navbar-expand-md nav-top justify-content-center">
  249. <div>
  250. <span class="website_title">操作主介面</span>
  251. </div>
  252. </nav>
  253. <nav class="navbar navbar-expand-md bg-dark navbar-dark nav-bottom">
  254. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
  255. <span class="navbar-toggler-icon"></span>
  256. </button>
  257. <div class="collapse navbar-collapse" id="collapsibleNavbar">
  258. <ul class="navbar-nav">
  259. <li class="nav-item">
  260. <a class="nav-link" href="/">首頁</a>
  261. </li>
  262. <li class="nav-item">
  263. <a class="nav-link" href="#">關於我們</a>
  264. </li>
  265. <li class="nav-item">
  266. <a class="nav-link" href="#">案場資訊</a>
  267. </li>
  268. <li class="nav-item">
  269. <a class="nav-link" href="#">聯絡方法</a>
  270. </li>
  271. <li class="nav-item">
  272. <a class="nav-link" href="/map">案場地圖</a>
  273. </li>
  274. <li class="nav-item">
  275. <a class="nav-link" href="/system_status">環境資訊</a>
  276. </li>
  277. <li class="li-block"></li>
  278. <li class="nav-item">
  279. <a class="nav-link" href="#"><i class="fa fa-user-o"></i> {{params.username}}</a>
  280. </li>
  281. <li class="nav-item">
  282. <a class="nav-link" href="/logout">Logout</a>
  283. </li>
  284. </ul>
  285. </div>
  286. </nav>
  287. </nav>
  288. <div class="main-page">
  289. <form method="" action="">
  290. <div class="container">
  291. <div class="row">
  292. <div id="node-list" class="col-12" style="width:100%;"></div>
  293. <div class="col-12">
  294. <img id="farm_img" src="" style='width:1080px;height:650px;' onError="img_error()" ondragstart="return false;">
  295. </div>
  296. <div id="map-canvas" class="col-12" style="text-align:center;background-color:#f2f2f2;padding:280px;border:1px;border-radius: 35px;"></div>
  297. </div>
  298. </div>
  299. </form>
  300. </div>
  301. </body>
  302. </html>