2021 기업연계프로젝트_컴퓨터소프트웨어공학 2조 팀 Sper
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.6 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Gps </title>
  5. <meta charset="utf-8">
  6. <title>지도 생성하기</title>
  7. <script src="/socket.io/socket.io.js"></script>
  8. </head>
  9. <body>
  10. <div id="map" style="width:100%;height:700px;"></div>
  11. <script type="text/javascript" src="//dapi.kakao.com/v2/maps/sdk.js?appkey= 6f7fabc77f1bff2334bd5521889a7b35"></script>
  12. <style>
  13. table { border-collapse: collapse; }
  14. th, td { border: 1px solid black; padding: 50px; }
  15. </style>
  16. </head>
  17. <body>
  18. <table>
  19. <caption>ㅇ센서</caption>
  20. <tr>
  21. <td></td>
  22. <th scope="col">lat(위도)</th>
  23. <th scope="col">lng(경도)</th>
  24. <th scope="col">wear(착용여부)</tH>
  25. </tr>
  26. <tr>
  27. <th scope="row">GPS/Pressure</th>
  28. <td rowspan="1"><p id = 'lat'></p></td>
  29. <td rowspan="2"><p id = 'lng'></p></td>
  30. <td rowspan="3"><div id = 'Pressure'></div></td>
  31. </tr>
  32. <tr>
  33. </table>
  34. <td> </div> </td>
  35. <script>
  36. var socket = io();
  37. var d;
  38. var c;
  39. var z=0;
  40. socket.on('data', function(data,count){
  41. if(count==1){
  42. d= data;
  43. console.log(data);
  44. document.getElementById('lat').innerHTML=d;
  45. }
  46. else if(count==2){
  47. c= data;
  48. console.log(c);
  49. document.getElementById('lng').innerHTML=c;
  50. }
  51. else if(count==0){
  52. if(data[1] == 'o'){
  53. document.getElementById('Pressure').innerHTML = data.toString();
  54. z=0;
  55. }
  56. else if(z != data[1]) {
  57. z = data[1];
  58. document.getElementById('Pressure').innerHTML = data.toString();
  59. alert("사용자가 헬멧을 착용하고 있지 않습니다. 킥보드를 멈춤");
  60. }
  61. }
  62. });
  63. var mapContainer = document.getElementById('map'), // 지도를 표시할 div
  64. mapOption = {
  65. center: new kakao.maps.LatLng( 35.97043362952654,126.95478849952511), // 지도의 중심좌표
  66. level: 3 // 지도의 확대 레벨
  67. };
  68. var map = new kakao.maps.Map(mapContainer, mapOption); // 지도를 생성합니다
  69. // 지도에 표시될 객체를 가지고 있을 배열입니다
  70. const locations = [
  71. { place:"원광대학교1", lat: d, lng: c}
  72. //{ place:"비교 주소 ", lat: 35.97043362952654, lng: 126.95478849952511 },
  73. ];
  74. for (var i = 0; i < locations.length; i++) {
  75. var marker = new kakao.maps.Marker({
  76. map: map,
  77. position: new kakao.maps.LatLng(locations[i].lat, locations[i].lng)
  78. });
  79. }
  80. </script>
  81. </body>
  82. </html>