app-tests-tester-list.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. $(function() {
  2. });
  3. var infoWindow = false;
  4. function initialiseMarkers() {
  5. if(infoWindow == false) {
  6. infoWindow = new google.maps.InfoWindow();
  7. }
  8. $.get(window.location, {
  9. action: "get-tests"
  10. }, function(response) {
  11. if(!response.success) return;
  12. let tests = response.tests;
  13. let map = maps["map"];
  14. let bounds = new google.maps.LatLngBounds();
  15. for(let i in tests) {
  16. let test = tests[i];
  17. let latLng = {
  18. lat: test.geolocation[0],
  19. lng: test.geolocation[1]
  20. };
  21. bounds.extend(latLng);
  22. let markerOptions = {
  23. position: latLng,
  24. map: map,
  25. title: test.name
  26. };
  27. if(test.icon) {
  28. markerOptions.icon = "/img/markers/" + test.icon + ".png";
  29. }
  30. let marker = new google.maps.Marker(markerOptions);
  31. marker.addListener("click", function() {
  32. infoWindow.setContent("<strong>" + test.name + "</strong> " + "<span class=\"badge badge-" + test.statusClass + "\">" + test.status + "</span>" + "<br />" +
  33. "<small>" + test.address + "</small>"
  34. );
  35. infoWindow.open(map, marker);
  36. });
  37. }
  38. map.fitBounds(bounds);
  39. });
  40. }