Source code of a graphical tool for drawing and computing distances over Google maps.
Run Tool | index.html | main.css | formatters.js | geoCircle.js | geoCode.js | geo.js | index.js | mapControls.js | tableManager.js | util.js | wayPoint.js | wayPointsManager.js
// Copyright 2006-2008 (c) Paul Demers <paul@acscdg.com> // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA., or visit one // of the links here: // http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt // http://www.acscdg.com/LICENSE.txt ////////////////////////////////////////////////////////////////// // Web site with this code running: http://www.acscdg.com/ // //// function tableManagerAddWayPointList() { var courseNumber = this.wayPointsManagerList.length + this.circlesList.length + 1; var wayPointsManager = new WayPointsManager(courseNumber, this.tableBodyElement); this.wayPointsManagerList.push(wayPointsManager); return wayPointsManager; } // //// function tableManagerAddCircle(map, centerPoint, distanceUnits) { var circleNumber = this.wayPointsManagerList.length + this.circlesList.length + 1; var geoCircle = new GeoCircle(map, circleNumber, centerPoint); this.circlesList.push(geoCircle); this.tableBodyElement.appendChild(geoCircle.tableRowElement); return geoCircle; } // //// function tableManagerRemoveLastCircle() { var geoCircle = this.circlesList.pop(); if ((geoCircle != null) && (geoCircle.tableRowElement != null)) this.tableBodyElement.removeChild(geoCircle.tableRowElement); return geoCircle; } // //// Called after a units change. function tableManagerRedrawPointsTable(distanceUnits) { for (var c = 0; c < this.circlesList.length; c++) { var geoCircle = this.circlesList[c]; geoCircle.updateElement(distanceUnits); } for (var w = 0; w < this.wayPointsManagerList.length; w++) { var wayPointManager = this.wayPointsManagerList[w]; wayPointManager.updateElement(distanceUnits); } } // //// Sets all data structures to the empty table settings. function tableManagerInitTable() { this.circlesList = new Array(); // Needed to redraw and clear. this.wayPointsManagerList = new Array(); // Needed to redraw and clear. } // //// Clears the points table. function tableManagerClearTable() { this.initTable(); // TODO: Is there a clear all children in JavaScript? for (var i = this.tableBodyElement.childNodes.length-1; i >= 0; i--) this.tableBodyElement.removeChild(this.tableBodyElement.childNodes[i]); } // //// function tableManagerBuildHeader() { var tHead = document.createElement("thead"); var trElement = document.createElement("tr"); tHead.appendChild(trElement); trElement.className = "ptshdr"; var thElement; thElement = document.createElement("th"); thElement.appendChild(document.createTextNode("Course/ Circle #")); thElement.className = "numcol"; trElement.appendChild(thElement); thElement = document.createElement("th"); thElement.appendChild(document.createTextNode("Point #")); thElement.className = "numcol"; trElement.appendChild(thElement); thElement = document.createElement("th"); thElement.appendChild(document.createTextNode("Pt./Cntr. Latitude")); thElement.className = "llcol"; trElement.appendChild(thElement); thElement = document.createElement("th"); thElement.appendChild(document.createTextNode("Pt./Cntr. Longitude")); thElement.className = "llcol"; trElement.appendChild(thElement); thElement = document.createElement("th"); thElement.appendChild(document.createTextNode("Distance/ Radius")); thElement.className = "distcol"; trElement.appendChild(thElement); thElement = document.createElement("th"); thElement.appendChild(document.createTextNode("Azimuth (Deg)")); thElement.className = "distcol"; trElement.appendChild(thElement); thElement = document.createElement("th"); thElement.appendChild(document.createTextNode("Total Dist/ Circumference")); thElement.className = "distcol"; trElement.appendChild(thElement); return tHead; } // //// function TableManager() { this.initTable = tableManagerInitTable; this.addWayPointList = tableManagerAddWayPointList; this.redrawPointsTable = tableManagerRedrawPointsTable; this.clearTable = tableManagerClearTable; this.addCircle = tableManagerAddCircle; this.removeLastCircle = tableManagerRemoveLastCircle; this.initTable(); // Build header here because the widths aren't right otherwise. this.tableElement = document.getElementById("pointsTable"); //this.tableBodyElement = document.getElementById("pointsTableBody"); this.tableElement.appendChild(tableManagerBuildHeader()); this.tableBodyElement = document.createElement("tbody"); this.tableElement.appendChild(this.tableBodyElement); }