Adding turf to monitor
authorBrian Flowers <git-admn@bsflowers.net>
Fri, 7 Feb 2025 05:03:02 +0000 (00:03 -0500)
committerBrian Flowers <git-admn@bsflowers.net>
Fri, 7 Feb 2025 05:03:02 +0000 (00:03 -0500)
js/canvassing.js

index 1066ba2..5224668 100644 (file)
@@ -206,7 +206,7 @@ function loadTurfs(research = false) {
           var button = document.createElement("input");
           button.setAttribute("type", "button");
           button.value = "Monitor";
-          button.onclick = monitorCanvass.bind(null, turfs[i].canvasses[j]);
+                                       button.onclick = monitorCanvass.bind(null, turfs[i].canvasses[j], turfs[i]);
           cell.appendChild(button);
         }
         row.appendChild(cell);
@@ -988,7 +988,7 @@ function reduceCacheBug() {
   document.getElementById("cacheBug").removeClass("expanded");
 }
 
-function monitorCanvass(canvass) {
+function monitorCanvass(canvass, turf) {
   console.log(canvass);
 //  fetch("api.php?get=canvassMonitor&id="+canvass).then(data => data.json())
 //    .then(output => {
@@ -1000,26 +1000,26 @@ function monitorCanvass(canvass) {
       // Pop-up on updates
     debug("monitorCanvass(..., ...)");
     debug(canvass);
-//  debug(turf);
+    debug(turf);
     setLoading(1);
                map.on("moveend", loadCanvassers.bind(null, false, canvass));
 //  loadTurfs();
-/*  var json = turf.json;
-  var turfPoints = JSON.parse(json).geometry.coordinates[0];
-  var latTot = 0;
-  var lonTot = 0;
-  var i = 0;
-  for(i = 0; i < turfPoints.length; i++) {
-    latTot += turfPoints[i][1];
-    lonTot += turfPoints[i][0];
-  }
-*/
+    var json = turf.json;
+    var turfPoints = JSON.parse(json).geometry.coordinates[0];
+    var latTot = 0;
+    var lonTot = 0;
+    var i = 0;
+    for(i = 0; i < turfPoints.length; i++) {
+      latTot += turfPoints[i][1];
+      lonTot += turfPoints[i][0];
+    }
+
     map.setZoom(19);
     map.setView([latTot/i, lonTot/i]);
     enableCanvassControls();
     currentCanvass = canvass;
-//  turfLayer = turf;
-//  setTimeout(toggleTurf.bind(null, turf, true), 1000);
+    turfLayer = turf;
+    setTimeout(toggleTurf.bind(null, turf, true), 1000);
     viewCanvass(canvass);
 
 /*  var options = {