$(function() { const $testsList = $("#tests-list"); $(document).on("click", "[data-jump-button]", event => { $("#tests-list > .list-group-item").removeClass("list-group-item-primary"); event.preventDefault(); const $button = $(event.currentTarget); const id = $button.data("id"); const target = `#test-${id}`; const $listGroupItem = $(target); $listGroupItem.addClass("list-group-item-primary"); const top = $listGroupItem.offset().top - 56 - 45; $("html, body").animate({ scrollTop: top }, "fast") }); }); 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) { if(!tests.hasOwnProperty(i)) continue; 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}
Find in List` ); infoWindow.open(map, marker); }); } map.fitBounds(bounds); }); }