From 191dd4a70a33f9fab8b9da97b3295b9b19e5cb22 Mon Sep 17 00:00:00 2001
From: Ray Liu <rayliu109@gmail.com>
Date: Tue, 3 Apr 2018 16:45:29 -0400
Subject: [PATCH] Added cluster.js

---
 tomcat/webapps/Trawl/cluster.js | 44 +++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 tomcat/webapps/Trawl/cluster.js

diff --git a/tomcat/webapps/Trawl/cluster.js b/tomcat/webapps/Trawl/cluster.js
new file mode 100644
index 0000000..2fe3a0b
--- /dev/null
+++ b/tomcat/webapps/Trawl/cluster.js
@@ -0,0 +1,44 @@
+//*This code references the info window google maps API
+//https://developers.google.com/maps/documentation/javascript/infowindows
+
+// Displays markers on a map centred at the Laurentian Great Lakes 
+// When the user clicks the marker, an info window opens
+var openWindow;
+
+function initCluster(lati, longi,n,  individualCount) {
+    // Generate map centred at Great Lakes
+    var map = new google.maps.Map(document.getElementById('map'), {
+        zoom: 5.5,
+        center: {lat: 45.0349575, lng: -88.6941305}
+    });
+    console.log("Gened info map");
+    setClusters(map, lati, longi,n, individualCount);
+}
+
+
+		  // Set info window contents to input string
+function setCluster(map, lati, longi,n, individualCount) {
+	for (var i = 0; i < lati.length; i++)
+	{
+        var marker = new google.maps.Marker({position: new google.maps.LatLng(lati[i], longi[i]), map: map});
+        // var content = "point numero" + i;
+        var content = '<div>' +
+			'Name:' + name[i] +
+            '<br>Cluster Count: ' + n[i]+
+            '<br>Individual Count:' + individualCount[i] + '</div></div>';
+		var infowindow = new google.maps.InfoWindow();
+
+        google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){
+            return function() {
+                console.log("Clicked!!!!");
+                if (openWindow)
+                    openWindow.close();
+                infowindow.setContent(content);
+				openWindow = infowindow;
+                infowindow.open(map,marker);
+            };
+        })(marker,content,infowindow));
+        console.log(i);
+	}
+}
+
-- 
GitLab