bug fixes and clean up
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 26 May 2013 11:27:35 +0000 (11:27 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 26 May 2013 11:27:35 +0000 (11:27 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1277 01035d8c-6547-0410-b346-abe4f91aad63

foxy/foxy.html

index 10bbcedfa1a4dabb0eb69cda407f736f828644a9..9575a295f46af9f2ee11e5061a087edc4e0c3a23 100644 (file)
@@ -47,7 +47,7 @@
   var bearing = 0.0;
 
   var bearings  = []; // database of bearings we keep in memory
-                      // mirrors breaings.txt
+                      // mirrors bearings.txt
 
 
   // Called when we load page
     //  newMarker.setAnimation(google.maps.Animation.BOUNCE);
     //}
 
-    // add to bearings array
-    // idea: add time stamp to info window?  Signal strength? Order
-
     var newInfoWindow = new google.maps.InfoWindow(
       { content: "put some info here"
       });
-    var newBearing = {marker : newMarker, 
-                      bearing: newBearing, 
-                      infowindow: newInfoWindow};
-    bearings.push(newBearing); 
 
-    // draw bearing as polyline 
+    // creat bearing line coords
 
     var location2 =  bearingToLocation(location, bearing, 100000);
     var coords = [
       location,
       location2
     ];
-    var path = new google.maps.Polyline({
+
+    // draw line
+
+    var newPath = new google.maps.Polyline({
             path: coords,
             strokeColor: "#080000",
             strokeOpacity: 0.5,
             strokeWeight: 5
     });
-    path.setMap(map);
+    newPath.setMap(map);
+
+    // add to bearings array
+    // idea: add time stamp to info window?  Signal strength? Order
+
+    var newBearing = {marker :    newMarker, 
+                      bearing:    newBearing, 
+                      infowindow: newInfoWindow,
+                      path:       newPath};
+    bearings.push(newBearing); 
 
     google.maps.event.addListener(newMarker, "click", function() {
 
         if (bearings[j].marker.position != newMarker.position) {
           new_bearings.push(bearings[j]);
         }
+        else
+          bearings[j].path.setMap(null);
       }
       bearings = new_bearings;
 
         lat = parseFloat(bits[0]);
         lng = parseFloat(bits[1]);
         myzoom = parseInt(bits[2]);
-        debug_enable = parseInt(bits[6]);
+        debug_enable = parseInt(bits[3]);
       }
     } 
   }
     // call CGI to rm bearings.txt
 
     downloadUrl("/cgi-bin/cleardb.cgi",function(doc){});
+
+    // delete all existing bearings
+      
+    if (bearings) {
+      for (j in bearings) {
+        bearings[j].marker.setMap(null);
+        bearings[j].path.setMap(null);
+      }
+    }
+    bearings = [];
   }
 
   function debugClicked() {
       <form name="control_panel">
         <table>
        <tr>
-          <td width="5%">
           <td>Bearing</td>
-          <td colspan="2"><input type="text" name="bearing" value="0" size="15"></td>
+          <td><input type="text" name="bearing" value="0" size="15"></td>
         </tr>
         <tr>
-          <td></td>
          <td>Clear Database</td>
-          <td></td>
-          <td width="30%"></td>
           <td width="60"><input type="button" value="Clear" onclick="clearDatabase()"></td>
         </tr>
         <tr>
-         <td></td>
           <td>Debug Messages</td>
           <td><input type="checkbox" name="debug_enable" onclick="debugClicked()"></td>
         </tr>