$(function() {
});
var infoWindow = false;
function initialiseMarkers() {
if(infoWindow == false) {
infoWindow = new google.maps.InfoWindow();
}
$.get(window.location, {
action: "get-tests"
}, function(response) {
if(!response.success) return;
let tests = response.tests;
let map = maps["map"];
let bounds = new google.maps.LatLngBounds();
for(let i in tests) {
let test = tests[i];
let latLng = {
lat: test.geolocation[0],
lng: test.geolocation[1]
};
bounds.extend(latLng);
let markerOptions = {
position: latLng,
map: map,
title: test.name
};
if(test.icon) {
markerOptions.icon = "/img/markers/" + test.icon + ".png";
}
let marker = new google.maps.Marker(markerOptions);
marker.addListener("click", function() {
infoWindow.setContent("" + test.name + " " + "" + test.status + "" + "
" +
"" + test.address + ""
);
infoWindow.open(map, marker);
});
}
map.fitBounds(bounds);
});
}