Parcourir la source

Highlight location when initialising testers. Fit map bounds to available locations.

Alan Lam il y a 8 ans
Parent
commit
7c9ca061a0
1 fichiers modifiés avec 12 ajouts et 1 suppressions
  1. 12 1
      public/js/app-project.js

+ 12 - 1
public/js/app-project.js

@@ -5,6 +5,7 @@ var assignMarkers = [];
 var selectedLocation;
 var selectedTester;
 
+var locationLatLngBounds;
 var assignLatLngBounds;
 
 var map = null;
@@ -41,6 +42,8 @@ function initialiseLocations() {
 
 		$("#tests-tbody").empty();
 
+		locationLatLngBounds = new google.maps.LatLngBounds;
+
 		for(let i in response.locations) {
 			let location = response.locations[i];
 
@@ -49,8 +52,9 @@ function initialiseLocations() {
 				lng: location.longitude
 			};
 
-			let cssClass = location.class;
+			locationLatLngBounds.extend(position);
 
+			let cssClass = location.class;
 
 			let icon = "/img/markers/building-grey.png";
 			if(cssClass == "danger") icon = "/img/markers/building-red.png";
@@ -107,6 +111,8 @@ function initialiseLocations() {
 			$("#tests-tbody").append(tr);
 
 		}
+
+		map.fitBounds(locationLatLngBounds);
 	});
 }
 
@@ -161,6 +167,11 @@ function clearTesters() {
 
 function initialiseTesters() {
 
+	let highlightClass = "table-warning";
+
+	$("#tests-tbody tr").removeClass(highlightClass);
+	$("#tests-tbody tr[data-location-id=" + selectedLocation.id + "]").addClass(highlightClass);
+
 	map = maps["map"];
 
 	$("#tester-list-loading-container").text("Loading available testers...");