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.

69 lines
2.1 KiB

6 years ago
  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(dataStr, status){
  40. data = $.parseJSON(dataStr)
  41. if (status == "success") {
  42. data.forEach(function(element) {
  43. var marker = new google.maps.Marker({
  44. position: { lat: element["location"]["latitude"], lng: element["location"]["longitude"]},
  45. map: map,
  46. label: element["priority"].toString(),
  47. title: element["info"]
  48. });
  49. marker.addListener('click', function() {
  50. window.open(window.location.href.replace("denunciation_map", "denunciation_view") + "&id=" + element["id"]);
  51. });
  52. markers.push(marker);
  53. });
  54. }
  55. });
  56. if (denunciation_count < markers.length) {
  57. sound.play();
  58. }
  59. denunciation_count = markers.length;
  60. }, 5000);
  61. </script>
  62. <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk&callback=initMap"
  63. async defer></script>
  64. </body>
  65. </html>