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.

62 lines
1.8 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  5. <title>Denunction Map</title>
  6. <meta name="viewport" content="initial-scale=1.0">
  7. <meta charset="utf-8">
  8. <style>
  9. #map {
  10. height: 100%;
  11. }
  12. html, body {
  13. height: 100%;
  14. margin: 0;
  15. padding: 0;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <audio id="audio" src="http://www.soundjay.com/button/beep-07.wav" autoplay="false"></audio>
  21. <div id="map"></div>
  22. <script>
  23. var map;
  24. function initMap() {
  25. map = new google.maps.Map(document.getElementById('map'), {
  26. center: {lat: 39.92, lng: 32.85},
  27. zoom: 13
  28. });
  29. }
  30. </script>
  31. <script>
  32. var sound = document.getElementById("audio");
  33. var markers = [];
  34. var denunciation_count = markers.length;
  35. setInterval(function() {
  36. for (var i = 0; i < markers.length; i++) {
  37. markers.pop().setMap(null);
  38. }
  39. $.get("https://127.0.0.1:5000/denunciations", function(data, status){
  40. if (status == "success") {
  41. data.forEach(function(element) {
  42. var marker = new google.maps.Marker({
  43. position: { lat: element["location"]["latitude"], lng: element["location"]["longitude"]},
  44. map: map,
  45. label: element["priority"].toString(),
  46. title: element["info"]
  47. });
  48. markers.push(marker);
  49. });
  50. }
  51. });
  52. if (denunciation_count < markers.length) {
  53. sound.play();
  54. }
  55. denunciation_count = markers.length;
  56. }, 5000);
  57. </script>
  58. <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk&callback=initMap"
  59. async defer></script>
  60. </body>
  61. </html>