function popup_ticket($id, $print = 'false', $search = FALSE) { /* 7/9/09 - show specified ticket */ global $istest, $iw_width; if ($istest) { print "GET<br />\n"; dump($_GET); print "POST<br />\n"; dump($_POST); } if ($id == '' or $id <= 0 or !check_for_rows("SELECT * FROM `{$GLOBALS['mysql_prefix']}ticket` WHERE id='{$id}'")) { /* sanity check */ print "Invalid Ticket ID: '{$id}'<BR />"; return; } $restrict_ticket = get_variable('restrict_user_tickets') == 1 && !is_administrator() ? " AND owner={$_SESSION['user_id']}" : ""; $query = "SELECT *,UNIX_TIMESTAMP(problemstart) AS problemstart,UNIX_TIMESTAMP(problemend) AS problemend,UNIX_TIMESTAMP(date) AS date,UNIX_TIMESTAMP(updated) AS updated, `{$GLOBALS['mysql_prefix']}ticket`.`description` AS `tick_descr` FROM `{$GLOBALS['mysql_prefix']}ticket` WHERE ID='{$id}' {$restrict_ticket}"; // 8/12/09 $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); if (!mysql_num_rows($result)) { //no tickets? print "error" or "restricted user rights" print "<FONT CLASS=\"warn\">No such ticket or user access to ticket is denied</FONT>"; exit; } $row = stripslashes_deep(mysql_fetch_assoc($result)); ?> <TABLE BORDER="0" ID = "outer" ALIGN="left"> <?php print "<TD ALIGN='left'>"; print "<TABLE ID='theMap' BORDER=0><TR CLASS='odd' ><TD ALIGN='center'>\n\t\t<DIV ID='map' STYLE='WIDTH:" . get_variable('map_width') . "px; HEIGHT: " . get_variable('map_height') . "PX'></DIV>\n\t\t</TD></TR>"; // 11/29/08 print "<FORM NAME='sv_form' METHOD='post' ACTION=''><INPUT TYPE='hidden' NAME='frm_lat' VALUE=" . $row['lat'] . ">"; // 2/11/09 print "<INPUT TYPE='hidden' NAME='frm_lng' VALUE=" . $row['lng'] . "></FORM>"; print "<TR ID='pointl1' CLASS='print_TD' STYLE = 'display:none;'>\n\t\t<TD ALIGN='center'><B>Range:</B> <SPAN ID='range'></SPAN> <B>Brng</B>: \n\t\t\t<SPAN ID='brng'></SPAN></TD></TR>\n\n\t\t<TR ID='pointl2' CLASS='print_TD' STYLE = 'display:none;'>\n\t\t\t<TD ALIGN='center'><B>Lat:</B> <SPAN ID='newlat'></SPAN>\n\t\t\t <B>Lng:</B> <SPAN ID='newlng'></SPAN> <B>NGS:</B> <SPAN ID = 'newusng'></SPAN></TD></TR>\n"; print "</TABLE>\n"; print "</TD></TR>"; print "<TR CLASS='odd' ><TD COLSPAN='2' CLASS='print_TD'>"; $lat = $row['lat']; $lng = $row['lng']; print "</TABLE>\n"; ?> <SCRIPT SRC='../js/usng.js' TYPE='text/javascript'></SCRIPT> <SCRIPT SRC="../js/graticule.js" type="text/javascript"></SCRIPT> <SCRIPT> function isNull(val) { // checks var stuff = null; return val === null; } var the_grid; var grid = false; function doGrid() { if (grid) { map.removeOverlay(the_grid); grid = false; } else { the_grid = new LatLonGraticule(); map.addOverlay(the_grid); grid = true; } } String.prototype.trim = function () { // 9/14/08 return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); }; String.prototype.parseDeg = function() { if (!isNaN(this)) return Number(this); // signed decimal degrees without NSEW var degLL = this.replace(/^-/,'').replace(/[NSEW]/i,''); // strip off any sign or compass dir'n var dms = degLL.split(/[^0-9.,]+/); // split out separate d/m/s for (var i in dms) if (dms[i]=='') dms.splice(i,1); // remove empty elements (see note below) switch (dms.length) { // convert to decimal degrees... case 3: // interpret 3-part result as d/m/s var deg = dms[0]/1 + dms[1]/60 + dms[2]/3600; break; case 2: // interpret 2-part result as d/m var deg = dms[0]/1 + dms[1]/60; break; case 1: // decimal or non-separated dddmmss if (/[NS]/i.test(this)) degLL = '0' + degLL; // - normalise N/S to 3-digit degrees var deg = dms[0].slice(0,3)/1 + dms[0].slice(3,5)/60 + dms[0].slice(5)/3600; break; default: return NaN; } if (/^-/.test(this) || /[WS]/i.test(this)) deg = -deg; // take '-', west and south as -ve return deg; } Number.prototype.toRad = function() { // convert degrees to radians return this * Math.PI / 180; } Number.prototype.toDeg = function() { // convert radians to degrees (signed) return this * 180 / Math.PI; } Number.prototype.toBrng = function() { // convert radians to degrees (as bearing: 0...360) return (this.toDeg()+360) % 360; } function brng(lat1, lon1, lat2, lon2) { lat1 = lat1.toRad(); lat2 = lat2.toRad(); var dLon = (lon2-lon1).toRad(); var y = Math.sin(dLon) * Math.cos(lat2); var x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon); return Math.atan2(y, x).toBrng(); } distCosineLaw = function(lat1, lon1, lat2, lon2) { var R = 6371; // earth's mean radius in km var d = Math.acos(Math.sin(lat1.toRad())*Math.sin(lat2.toRad()) + Math.cos(lat1.toRad())*Math.cos(lat2.toRad())*Math.cos((lon2-lon1).toRad())) * R; return d; } var km2feet = 3280.83; var thisMarker = false; var map; var icons=[]; // note globals - 1/29/09 icons[<?php print $GLOBALS['SEVERITY_NORMAL']; ?> ] = "./our_icons/blue.png"; // normal icons[<?php print $GLOBALS['SEVERITY_MEDIUM']; ?> ] = "./our_icons/green.png"; // green icons[<?php print $GLOBALS['SEVERITY_HIGH']; ?> ] = "./our_icons/red.png"; // red icons[<?php print $GLOBALS['SEVERITY_HIGH']; ?> +1] = "./our_icons/white.png"; // white - not in use var baseIcon = new GIcon(); baseIcon.shadow = "./markers/sm_shadow.png"; baseIcon.iconSize = new GSize(20, 34); baseIcon.iconAnchor = new GPoint(9, 34); baseIcon.infoWindowAnchor = new GPoint(9, 2); map = new GMap2($("map")); // create the map <?php $maptype = get_variable('maptype'); // 08/02/09 switch ($maptype) { case "1": break; case "2": ?> map.setMapType(G_SATELLITE_MAP);<?php break; case "3": ?> map.setMapType(G_PHYSICAL_MAP);<?php break; case "4": ?> map.setMapType(G_HYBRID_MAP);<?php break; default: print "ERROR in " . basename(__FILE__) . " " . __LINE__ . "<BR />"; } ?> map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.addControl(new GOverviewMapControl()); // 12/24/08 <?php if (get_variable('terrain') == 1) { ?> map.addMapType(G_PHYSICAL_MAP); <?php } ?> map.setCenter(new GLatLng(<?php print $lat; ?> , <?php print $lng; ?> ),11); var icon = new GIcon(baseIcon); icon.image = icons[<?php print $row['severity']; ?> ]; var point = new GLatLng(<?php print $lat; ?> , <?php print $lng; ?> ); // 1147 map.addOverlay(new GMarker(point, icon)); map.enableScrollWheelZoom(); // ====================================Add Active Responding Units to Map ========================================================================= var icons=[]; // note globals - 1/29/09 icons[1] = "./our_icons/white.png"; // normal icons[2] = "./our_icons/black.png"; // green var baseIcon = new GIcon(); baseIcon.shadow = "./markers/sm_shadow.png"; baseIcon.iconSize = new GSize(20, 34); baseIcon.iconAnchor = new GPoint(9, 34); baseIcon.infoWindowAnchor = new GPoint(9, 2); var unit_icon = new GIcon(baseIcon); unit_icon.image = icons[1]; function createMarker(unit_point, number) { var unit_marker = new GMarker(unit_point, unit_icon); // Show this markers index in the info window when it is clicked var html = number; GEvent.addListener(unit_marker, "click", function() {unit_marker.openInfoWindowHtml(html);}); return unit_marker; } <?php $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}assigns` WHERE ticket_id='{$id}'"; $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); while ($row = mysql_fetch_array($result)) { $responder_id = $row['responder_id']; if ($row['clear'] == NULL) { $query_unit = "SELECT * FROM `{$GLOBALS['mysql_prefix']}responder` WHERE id='{$responder_id}'"; $result_unit = mysql_query($query_unit) or do_error($query_unit, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); while ($row_unit = mysql_fetch_array($result_unit)) { $unit_id = $row_unit['id']; $mobile = $row_unit['mobile']; if (my_is_float($row_unit['lat']) && my_is_float($row_unit['lng'])) { if ($mobile == 1) { echo "var unit_icon = new GIcon(baseIcon);\n"; echo "var unit_icon_url = \"./our_icons/gen_icon.php?blank=0&text=RU\";\n"; // 4/18/09 echo "unit_icon.image = unit_icon_url;\n"; echo "var unit_point = new GLatLng(" . $row_unit['lat'] . "," . $row_unit['lng'] . ");\n"; echo "var unit_marker = createMarker(unit_point, '" . addslashes($row_unit['name']) . "', unit_icon);\n"; echo "map.addOverlay(unit_marker);\n"; echo "\n"; } else { echo "var unit_icon = new GIcon(baseIcon);\n"; echo "var unit_icon_url = \"./our_icons/gen_icon.php?blank=4&text=RU\";\n"; // 4/18/09 echo "unit_icon.image = unit_icon_url;\n"; echo "var unit_point = new GLatLng(" . $row_unit['lat'] . "," . $row_unit['lng'] . ");\n"; echo "var unit_marker = createMarker(unit_point, '" . addslashes($row_unit['name']) . "', unit_icon);\n"; echo "map.addOverlay(unit_marker);\n"; echo "\n"; } // end if/else ($mobile) } // end ((my_is_float()) - responding units } // end outer if } // end inner while } // end outer while // =====================================End of functions to show responding units======================================================================== // ====================================Add Facilities to Map 8/1/09================================================ ?> var icons=[]; var g=0; var fmarkers = []; var baseIcon = new GIcon(); baseIcon.shadow = "./markers/sm_shadow.png"; baseIcon.iconSize = new GSize(30, 30); baseIcon.iconAnchor = new GPoint(15, 30); baseIcon.infoWindowAnchor = new GPoint(9, 2); var fac_icon = new GIcon(baseIcon); fac_icon.image = icons[1]; function createfacMarker(fac_point, fac_name, id, fac_icon) { var fac_marker = new GMarker(fac_point, fac_icon); // Show this markers index in the info window when it is clicked var fac_html = fac_name; fmarkers[id] = fac_marker; GEvent.addListener(fac_marker, "click", function() {fac_marker.openInfoWindowHtml(fac_html);}); return fac_marker; } <?php $query_fac = "SELECT *,UNIX_TIMESTAMP(updated) AS updated, `{$GLOBALS['mysql_prefix']}facilities`.id AS fac_id, `{$GLOBALS['mysql_prefix']}facilities`.description AS facility_description, `{$GLOBALS['mysql_prefix']}fac_types`.name AS fac_type_name, `{$GLOBALS['mysql_prefix']}facilities`.name AS facility_name FROM `{$GLOBALS['mysql_prefix']}facilities` LEFT JOIN `{$GLOBALS['mysql_prefix']}fac_types` ON `{$GLOBALS['mysql_prefix']}facilities`.type = `{$GLOBALS['mysql_prefix']}fac_types`.id LEFT JOIN `{$GLOBALS['mysql_prefix']}fac_status` ON `{$GLOBALS['mysql_prefix']}facilities`.status_id = `{$GLOBALS['mysql_prefix']}fac_status`.id ORDER BY `{$GLOBALS['mysql_prefix']}facilities`.type ASC"; $result_fac = mysql_query($query_fac) or do_error($query_fac, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); while ($row_fac = mysql_fetch_array($result_fac)) { $eols = array("\r\n", "\n", "\r"); // all flavors of eol while ($row_fac = stripslashes_deep(mysql_fetch_array($result_fac))) { // $fac_name = $row_fac['facility_name']; // 10/8/09 $fac_temp = explode("/", $fac_name); $fac_index = substr($fac_temp[count($fac_temp) - 1], -6, strlen($fac_temp[count($fac_temp) - 1])); // 3/19/11 print "\t\tvar fac_sym = '{$fac_index}';\n"; // for sidebar and icon 10/8/09 $fac_id = $row_fac['id']; $fac_type = $row_fac['icon']; $f_disp_name = $row_fac['facility_name']; // 10/8/09 $f_disp_temp = explode("/", $f_disp_name); $facility_display_name = $f_disp_temp[0]; if (my_is_float($row_fac['lat']) && my_is_float($row_fac['lng'])) { $fac_tab_1 = "<TABLE CLASS='infowin' width='{$iw_width}' >"; $fac_tab_1 .= "<TR CLASS='even'><TD COLSPAN=2 ALIGN='center'><B>" . addslashes(shorten($facility_display_name, 48)) . "</B></TD></TR>"; $fac_tab_1 .= "<TR CLASS='odd'><TD COLSPAN=2 ALIGN='center'><B>" . addslashes(shorten($row_fac['fac_type_name'], 48)) . "</B></TD></TR>"; $fac_tab_1 .= "<TR CLASS='even'><TD ALIGN='right'>Description: </TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row_fac['facility_description'])) . "</TD></TR>"; $fac_tab_1 .= "<TR CLASS='odd'><TD ALIGN='right'>Status: </TD><TD ALIGN='left'>" . addslashes($row_fac['status_val']) . " </TD></TR>"; $fac_tab_1 .= "<TR CLASS='even'><TD ALIGN='right'>Contact: </TD><TD ALIGN='left'>" . addslashes($row_fac['contact_name']) . " Email: " . addslashes($row_fac['contact_email']) . "</TD></TR>"; $fac_tab_1 .= "<TR CLASS='odd'><TD ALIGN='right'>Phone: </TD><TD ALIGN='left'>" . addslashes($row_fac['contact_phone']) . " </TD></TR>"; $fac_tab_1 .= "<TR CLASS='even'><TD ALIGN='right'>As of: </TD><TD ALIGN='left'>" . format_date($row_fac['updated']) . "</TD></TR>"; $fac_tab_1 .= "</TABLE>"; $fac_tab_2 = "<TABLE CLASS='infowin' width='{$iw_width}' >"; $fac_tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Security contact: </TD><TD ALIGN='left'>" . addslashes($row_fac['security_contact']) . " </TD></TR>"; $fac_tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Security email: </TD><TD ALIGN='left'>" . addslashes($row_fac['security_email']) . " </TD></TR>"; $fac_tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Security phone: </TD><TD ALIGN='left'>" . addslashes($row_fac['security_phone']) . " </TD></TR>"; $fac_tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Access rules: </TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row_fac['access_rules'])) . "</TD></TR>"; $fac_tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Security reqs: </TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row_fac['security_reqs'])) . "</TD></TR>"; $fac_tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Opening hours: </TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row_fac['opening_hours'])) . "</TD></TR>"; $fac_tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Prim pager: </TD><TD ALIGN='left'>" . addslashes($row_fac['pager_p']) . " </TD></TR>"; $fac_tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Sec pager: </TD><TD ALIGN='left'>" . addslashes($row_fac['pager_s']) . " </TD></TR>"; $fac_tab_2 .= "</TABLE>"; ?> // var fac_sym = (g+1).toString(); var myfacinfoTabs = [ new GInfoWindowTab("<?php print nl2brr(addslashes(shorten($row_fac['facility_name'], 10))); ?> ", "<?php print $fac_tab_1; ?> "), new GInfoWindowTab("More ...", "<?php print str_replace($eols, " ", $fac_tab_2); ?> ") ]; <?php if ($row_fac['lat'] == 0.999999 && $row_fac['lng'] == 0.999999) { // check for facilities entered in no maps mode 7/28/10 echo "var fac_icon = new GIcon(baseIcon);\n"; echo "var fac_type = {$fac_type};\n"; echo "var fac_icon_url = \"./our_icons/question1.png\";\n"; echo "fac_icon.image = fac_icon_url;\n"; echo "var fac_point = new GLatLng(" . get_variable('def_lat') . "," . get_variable('def_lng') . ");\n"; echo "var fac_marker = createfacMarker(fac_point, myfacinfoTabs, g, fac_icon);\n"; echo "map.addOverlay(fac_marker);\n"; echo "\n"; } else { echo "var fac_icon = new GIcon(baseIcon);\n"; echo "var fac_type = {$fac_type};\n"; ?> var origin = ((fac_sym.length)>3)? (fac_sym.length)-3: 0; // pick low-order three chars 3/22/11 var iconStr = fac_sym.substring(origin); <?php echo "var fac_icon_url = \"./our_icons/gen_fac_icon.php?blank={$fac_type}&text=\" + (iconStr) + \"\";\n"; echo "fac_icon.image = fac_icon_url;\n"; echo "var fac_point = new GLatLng(" . $row_fac['lat'] . "," . $row_fac['lng'] . ");\n"; echo "var fac_marker = createfacMarker(fac_point, myfacinfoTabs, g, fac_icon);\n"; echo "map.addOverlay(fac_marker);\n"; echo "\n"; } } // end if my_is_float - facilities ?> g++; <?php } // end while } // =====================================End of functions to show facilities======================================================================== do_kml(); // kml functions ?> function lat2ddm(inlat) { // 9/7/08 var x = new Number(inlat); var y = (inlat>0)? Math.floor(x):Math.round(x); var z = ((Math.abs(x-y)*60).toFixed(1)); var nors = (inlat>0.0)? " N":" S"; return Math.abs(y) + '\260 ' + z +"'" + nors; } function lng2ddm(inlng) { var x = new Number(inlng); var y = (inlng>0)? Math.floor(x):Math.round(x); var z = ((Math.abs(x-y)*60).toFixed(1)); var eorw = (inlng>0.0)? " E":" W"; return Math.abs(y) + '\260 ' + z +"'" + eorw; } function do_coords(inlat, inlng) { //9/14/08 if(inlat.toString().length==0) return; // 10/15/08 var str = inlat + ", " + inlng + "\n"; str += ll2dms(inlat) + ", " +ll2dms(inlng) + "\n"; str += lat2ddm(inlat) + ", " +lng2ddm(inlng); alert(str); } function ll2dms(inval) { // lat/lng to degr, mins, sec's - 9/9/08 var d = new Number(inval); d = (inval>0)? Math.floor(d):Math.round(d); var mi = (inval-d)*60; var m = Math.floor(mi) // min's var si = (mi-m)*60; var s = si.toFixed(1); return d + '\260 ' + Math.abs(m) +"' " + Math.abs(s) + '"'; } </SCRIPT> <?php }
function map($mode, $lat, $lng, $icon) { // Facility add, edit, view $have_coords = is_numeric($lat); $the_lat = my_is_float($lat) ? $lat : get_variable('def_lat'); $the_lng = my_is_float($lat) ? $lng : get_variable('def_lng'); ?> <SCRIPT > var mode = "<?php print $mode; ?> "; function writeConsole(content) { top.consoleRef=window.open('','myconsole', 'width=800,height=250' +',menubar=0' +',toolbar=0' +',status=0' +',scrollbars=0' +',resizable=1') top.consoleRef.document.writeln('<html><head><title>Console</title></head>' +'<body bgcolor=white onLoad="self.focus()">' +content +'</body></HTML>' ) // end top.consoleRef.document.writeln() top.consoleRef.document.close(); } // end function writeConsole(content) function map_reset() { map.clearOverlays(); var point = new GLatLng(<?php print $the_lat; ?> , <?php print $the_lng; ?> ); map.setCenter(point, <?php print get_variable('def_zoom'); ?> ); map.addOverlay(new GMarker(point, myIcon)); } function map_cen_reset() { // reset map center icon map.clearOverlays(); } function ReadOnlyCheckBox() { alert("You can't change this value"); return false; } var map = new GMap2($('map')); <?php $maptype = get_variable('maptype'); switch ($maptype) { case "1": break; case "2": ?> map.setMapType(G_SATELLITE_MAP);<?php break; case "3": ?> map.setMapType(G_PHYSICAL_MAP);<?php break; case "4": ?> map.setMapType(G_HYBRID_MAP);<?php break; default: print "ERROR in " . basename(__FILE__) . " " . __LINE__ . "<BR />"; } ?> var gdir = new GDirections(map, $("directions")); G_START_ICON.image = ""; G_END_ICON.image = ""; var bounds = new GLatLngBounds(); // create empty bounding box var geocoder = null; // 7/5/10 var rev_coding_on; // 7/5/10 geocoder = new GClientGeocoder(); // 7/5/10 var myZoom; // note globals var marker; var myIcon = new GIcon(); <?php if ($the_lat == 0.999999 && $the_lng == 0.999999) { // check of Tickets entered in "no maps" mode 7/28/10 ?> myIcon.image = "./our_icons/question1.png"; // 7/28/10 myIcon.iconSize = new GSize(16, 28); myIcon.iconAnchor = new GPoint(8, 28); myIcon.infoWindowAnchor = new GPoint(5, 1); <?php } else { ?> myIcon.image = "./markers/yellow.png"; myIcon.shadow = "./markers/sm_shadow.png"; myIcon.iconSize = new GSize(16, 28); myIcon.shadowSize = new GSize(16, 28); myIcon.iconAnchor = new GPoint(8, 28); myIcon.infoWindowAnchor = new GPoint(5, 1); <?php } // end of check of Tickets entered in "no maps" mode 7/28/10 ?> // map.addControl(new GSmallMapControl()); map.setUIToDefault(); // 8/13/10 map.addControl(new GMapTypeControl()); map.addControl(new GOverviewMapControl()); <?php if (get_variable('terrain') == 1) { ?> map.addMapType(G_PHYSICAL_MAP); <?php } ?> map.enableScrollWheelZoom(); var tab1contents; // info window contents - first/only tab // default point - possible dummy <?php if ($the_lat == 0.999999 && $the_lng == 0.999999) { // check of Tickets entered in "no maps" mode 7/28/10 ?> map.setCenter(new GLatLng(<?php print get_variable('def_lat'); ?> , <?php print get_variable('def_lng'); ?> ), <?php print get_variable('def_zoom'); ?> ); // larger # => tighter zoom <?php } else { ?> map.setCenter(new GLatLng(<?php print $the_lat; ?> , <?php print $the_lng; ?> ), <?php print get_variable('def_zoom'); ?> ); // larger # => tighter zoom <?php } // end of check of Tickets entered in "no maps" mode 7/28/10 if ($icon) { // icon display? if ($the_lat == 0.999999 && $the_lng == 0.999999) { // check of Tickets entered in "no maps" mode 7/28/10 ?> var point = new GLatLng(<?php print get_variable('def_lat') . ", " . get_variable('def_lng'); ?> ); var marker = new GMarker(point, {icon: myIcon, draggable:false}); map.addOverlay(new GMarker(point, myIcon)); <?php } else { ?> var point = new GLatLng(<?php print $the_lat . ", " . $the_lng; ?> ); // 888 var marker = new GMarker(point, {icon: myIcon, draggable:false}); map.addOverlay(new GMarker(point, myIcon)); <?php } // end of check of Tickets entered in "no maps" mode 7/28/10 } else { ?> var baseIcon = new GIcon(); baseIcon.iconSize=new GSize(30,30); baseIcon.iconAnchor=new GPoint(16,16); var cross = new GIcon(baseIcon, "./markers/crosshair.png", null); var center = new GLatLng(<?php print get_variable('def_lat'); ?> , <?php print get_variable('def_lng'); ?> ); map.setCenter(center, <?php print get_variable('def_zoom'); ?> ); var thisMarker = new GMarker(center, {icon: cross, draggable:false} ); map.addOverlay(thisMarker); <?php } // end else if ($mode == "v") { // only in view mode ?> function handleErrors(){ if (gdir.getStatus().code == G_GEO_UNKNOWN_DIRECTIONS ) { alert("501: directions unavailable\n\nClick map point for directions."); } else if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) alert("440: No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) alert("442: A map request could not be processed, reason unknown.\n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) alert("444: Technical error.\n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_BAD_KEY) alert("448: The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) alert("450: A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code); else alert("451: An unknown error occurred."); } // end function handleErrors() function setDirections(fromAddress, toAddress, locale) { var Direcs = gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale, preserveViewport : true }); GEvent.addListener(Direcs, "addoverlay", GEvent.callback(Direcs, cb())); } // end function set Directions() function cb() { // alert(847); // onto floor ?? } GEvent.addListener(map, "click", function(marker, point) { bounds.extend(point); // endpoint to bounding box var the_start = new GLatLng(<?php print $the_lat; ?> , <?php print $the_lng; ?> ); bounds.extend(the_start); // start to bounding box var the_start = "<?php print $the_lat . " " . $the_lng; ?> "; var the_end = point.lat().toFixed(6).toString() + " " + point.lng().toFixed(6).toString(); center = bounds.getCenter(); zoom = map.getBoundsZoomLevel(bounds); map.clearOverlays(); map.setCenter(center,zoom); setDirections(the_start, the_end, "en_US"); }); // end GEvent.add Listener() <?php } else { // disallow if view mode ?> var the_zoom = <?php print get_variable('def_zoom'); ?> ; map.enableScrollWheelZoom(); if ((mode=="a") || (mode=="e")){ the_marker = new GMarker(map.getCenter(), {draggable: true }); GEvent.addListener(map, "click", function(overlay, latlng) { if (latlng) { map.clearOverlays(); marker = new GMarker(latlng, {draggable:true}); map.setCenter(marker.getPoint(), the_zoom); do_lat(marker.getPoint().lat()); // set form values do_lng(marker.getPoint().lng()); do_ngs(); GEvent.addListener(marker, "dragend", function() { map.setCenter(marker.getPoint(), <?php echo get_variable('def_zoom'); ?> ); do_lat (marker.getPoint().lat()); // set form values do_lng (marker.getPoint().lng()); do_ngs(); }); map.addOverlay(marker); } // end if (latlng) switch(mode) { // 7/5/10 added for reverse geocoding of map click case "a": currform="a"; getAddress(overlay, latlng, currform); // 7/5/10 break; case "e": currform="e"; getAddress(overlay, latlng, currform); // 7/5/10 break; default: alert("Invalid Function"); } }); // end GEvent.add Listener() } // end if ((mode=="a") ... <?php } // end if ($mode=="v") do_kml(); // kml functions ?> </SCRIPT> <?php }
function list_tracks($addon = '', $start) { global $source, $evenodd; ?> <SCRIPT> var direcs=new Array("north.png","north_east.png","east.png","south_east.png","south.png","south_west.png","west.png","north_west.png", "north.png"); // 4/8/09 var colors = new Array ('odd', 'even'); function hideGroup(color) { for (var i = 0; i < gmarkers.length; i++) { if (gmarkers[i]) { if (gmarkers[i].id == color) { gmarkers[i].show(); } else { gmarkers[i].hide(); } } // end if (gmarkers[i]) } // end for () elem = document.getElementById("allIcons"); elem.style.visibility = "visible"; } // end function function showAll() { for (var i = 0; i < gmarkers.length; i++) { if (gmarkers[i]) { gmarkers[i].show(); } } // end for () elem = document.getElementById("allIcons"); elem.style.visibility = "hidden"; } // end function // (point, html, node_type, heading) function create_track_Marker(point, html, node_type, heading) { // alert(node_type); switch (node_type){ case 1: // start node // alert(51); var marker = new GMarker(point, starticon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); break; case 0: // end node // alert(57); var marker = new GMarker(point, endicon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); break; default : // in between nodes // alert("65 " + heading); var infoicon = new GIcon(); infoicon.image = "./markers/" + direcs[heading]; infoicon.iconSize = new GSize(15, 15); infoicon.iconAnchor = new GPoint(4, 4); var marker = new GMarker(point, infoicon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); } return marker; } function createMarker(point,tabs, color, id) { // Creates marker and sets up click event infowindow // alert(69); points = true; // at least one var icon = new GIcon(listIcon); icon.image = icons[color] + ((id % 100)+1) + ".png"; // e.g.,marker9.png, 100 icons limit var marker = new GMarker(point, icon); marker.id = color; // for hide/unhide - unused GEvent.addListener(marker, "click", function() { // here for both side bar and icon click map.closeInfoWindow(); which = id; gmarkers[which].hide(); marker.openInfoWindowTabsHtml(infoTabs[id]); var dMapDiv = document.getElementById("detailmap"); var detailmap = new GMap2(dMapDiv); detailmap.addControl(new GSmallMapControl()); detailmap.setCenter(point, 17); // larger # = closer - 7/16/10 detailmap.addOverlay(marker); }); gmarkers[id] = marker; // marker to array for side_bar click function infoTabs[id] = tabs; // tabs to array // bounds.extend(point); // extend the bounding box - removed 5/26/08 return marker; } // end function create Marker() function do_sidebar (sidebar, id) { side_bar_html += "<TR CLASS='" + colors[(id)%2] +"' onClick = myclick(" + id + ");>"; side_bar_html += "<TD CLASS='td_label'>" + sidebar +"</TD></TR>\n"; } function do_sidebar_nm (sidebar, line_no, rcd_id) { // no map - view responder // view_Form side_bar_html += "<TR CLASS='" + colors[(line_no)%2] +"' onClick = myclick_nm(" + rcd_id + ");>"; side_bar_html += "<TD CLASS='td_label'>" + (line_no+1) + ". "+ sidebar +"</TD></TR>\n"; } function myclick_nm(v_id) { // Responds to sidebar click - view responder data document.view_form.id.value=v_id; document.view_form.submit(); } function myclick(id) { // Responds to sidebar click, then triggers listener above - note [id] GEvent.trigger(gmarkers[id], "click"); } function doGrid() { map.addOverlay(new LatLonGraticule()); } function do_lat (lat) { document.forms[0].frm_lat.disabled=false; document.forms[0].frm_lat.value=lat.toFixed(6); document.forms[0].frm_lat.disabled=true; } function do_lng (lng) { document.forms[0].frm_lng.disabled=false; document.forms[0].frm_lng.value=lng.toFixed(6); document.forms[0].frm_lng.disabled=true; } // var icons=[]; // note globals // icons[1] = "./markers/YellowIcons/marker"; //e.g.,marker9.png // icons[2] = "./markers/RedIcons/marker"; // icons[3] = "./markers/BlueIcons/marker"; // icons[4] = "./markers/GreenIcons/marker"; // BlueIcons/GreenIcons/YellowIcons/RedIcons var starticon = new GIcon(); starticon.image = "./markers/start.png"; starticon.iconSize = new GSize(16, 16); starticon.iconAnchor = new GPoint(8, 8); var endicon = new GIcon(); endicon.image = "./markers/end.png"; endicon.iconSize = new GSize(16, 16); endicon.iconAnchor = new GPoint(8, 8); var map; var side_bar_html = "<TABLE border=0 CLASS='sidebar' ID='tbl_responders'>"; side_bar_html +="<TR><TD ALIGN='center' COLSPAN=99>Mouseover for details</TD></TR>"; var gmarkers = []; var infoTabs = []; var which; var i = 0; // sidebar/icon index, track point index var points = false; // none map = new GMap2(document.getElementById("map")); // create the map <?php $maptype = get_variable('maptype'); // 08/02/09 switch ($maptype) { case "1": break; case "2": ?> map.setMapType(G_SATELLITE_MAP);<?php break; case "3": ?> map.setMapType(G_PHYSICAL_MAP);<?php break; case "4": ?> map.setMapType(G_HYBRID_MAP);<?php break; default: print "ERROR in " . basename(__FILE__) . " " . __LINE__ . "<BR />"; } ?> // map.addControl(new GSmallMapControl()); map.setUIToDefault(); // 8/13/10 map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(<?php echo get_variable('def_lat'); ?> , <?php echo get_variable('def_lng'); ?> ), <?php echo get_variable('def_zoom'); ?> ); // <?php echo get_variable('def_lat'); ?> var bounds = new GLatLngBounds(); // create bounding box // map.addControl(new GOverviewMapControl()); map.enableScrollWheelZoom(); var listIcon = new GIcon(); listIcon.image = "./markers/yellow.png"; // yellow.png - 16 X 28 listIcon.shadow = "./markers/sm_shadow.png"; listIcon.iconSize = new GSize(20, 34); listIcon.shadowSize = new GSize(37, 34); listIcon.iconAnchor = new GPoint(8, 28); listIcon.infoWindowAnchor = new GPoint(9, 2); listIcon.infoShadowAnchor = new GPoint(18, 25); var newIcon = new GIcon(); newIcon.image = "./markers/white.png"; // yellow.png - 20 X 34 newIcon.shadow = "./markers/shadow.png"; newIcon.iconSize = new GSize(20, 34); newIcon.shadowSize = new GSize(37, 34); newIcon.iconAnchor = new GPoint(8, 28); newIcon.infoWindowAnchor = new GPoint(9, 2); newIcon.infoShadowAnchor = new GPoint(18, 25); GEvent.addListener(map, "infowindowclose", function() { // re-center after move/zoom map.setCenter(center,zoom); map.addOverlay(gmarkers[which]) }); <?php // $bulls = array(0 =>"",1 =>"red",2 =>"green",3 =>"white",4 =>"black"); $toedit = ""; $query = "SELECT DISTINCT `source`, `latitude`, `longitude` ,`course` ,`speed` ,`altitude` ,`closest_city` ,\n\t\t`status` , `packet_date`, \n\t\tUNIX_TIMESTAMP(updated) AS `updated` \n\t\tFROM `{$GLOBALS['mysql_prefix']}tracks` \n\t\tWHERE `source` = '" . $source . "' \n\t\tORDER BY `packet_date`"; // 6/16/08 $result_tr = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); $sidebar_line = "<TABLE border=0>\n"; if (mysql_affected_rows() > 1) { ?> var j=0; // point counter this unit var ender = <?php print mysql_affected_rows(); ?> ; <?php $last = $day = ""; $i = 0; while ($row_tr = stripslashes_deep(mysql_fetch_array($result_tr))) { if (substr($row_tr['packet_date'], 0, 10) != $day) { $day = substr($row_tr['packet_date'], 0, 10); $sidebar_line .= "<TR CLASS='" . $evenodd[$i % 2] . "'><TD COLSPAN=99><U>" . $day . "</U></TD></TR>\n"; $i++; } $sidebar_line .= "<TR CLASS='" . $evenodd[$i % 2] . "'>"; // 4/8/09 $sidebar_line .= "<TD CLASS = 'text_small' TITLE='" . $row_tr['packet_date'] . "'> " . substr($row_tr['packet_date'], 11, 5) . " </TD>\n"; $sidebar_line .= "<TD CLASS = 'text_small' TITLE='" . $row_tr['latitude'] . ", " . $row_tr['longitude'] . "'> " . shorten($row_tr['latitude'], 8) . "</TD>\n"; $sidebar_line .= "<TD CLASS = 'text_small'> " . $row_tr['speed'] . "@" . $row_tr['course'] . "</TD>\n"; $sidebar_line .= "<TD CLASS = 'text_small' TITLE='" . $row_tr['closest_city'] . "'> " . shorten($row_tr['closest_city'], 16) . "</TD>\n"; $sidebar_line .= "</TR>\n"; ?> j++; var point = new GLatLng(<?php print $row_tr['latitude']; ?> , <?php print $row_tr['longitude']; ?> ); var html = "<b><?php print $row_tr['source']; ?> </b><br /><br /><?php print format_date($row_tr['updated']); ?> "; var heading = Math.round(<?php print intval($row_tr['course']); ?> /45); // 10/4/08 // alert("230 " + heading); if (j== ender) {node_type=0;} // signifies last node 10/4/08 else {node_type=j;}; // other than last var marker = create_track_Marker(point, html, node_type, heading); map.addOverlay(marker); bounds.extend(new GLatLng(<?php print $row_tr['latitude']; ?> , <?php print $row_tr['longitude']; ?> )); // 10/4/08 all points to bounding box <?php if (!empty($last)) { ?> var polyline = new GPolyline([ new GLatLng(<?php print $last['latitude']; ?> , <?php print $last['longitude']; ?> ), // prior point new GLatLng(<?php print $row_tr['latitude']; ?> , <?php print $row_tr['longitude']; ?> ) // current point ], "#FF0000", 2); map.addOverlay(polyline); points++; <?php } // end if (!empty($last)) $last = $row_tr; // either way $i++; } // end while ($row_tr...) $mode = $last['speed'] == 0 ? 1 : 2; if ($last['speed'] >= 50) { $mode = 3; } ?> var point = new GLatLng(<?php print $last['latitude']; ?> , <?php print $last['longitude']; ?> ); // mobile position <?php } // end (mysql_affected_rows()> 1 ) $eols = array("\r\n", "\n", "\r"); // all flavors of eol ?> var do_map = true; // default do_sidebar ("<?php print str_replace($eols, "", $sidebar_line); ?> ", i); // as single string var do_map = false; if (do_map) { var marker = createMarker(point, myinfoTabs,2, i); // (point,tabs, color, id) map.addOverlay(marker); } i++; // zero-based <?php // ?> if (!points) { // any? map.setCenter(new GLatLng(<?php echo get_variable('def_lat'); ?> , <?php echo get_variable('def_lng'); ?> ), <?php echo get_variable('def_zoom'); ?> ); } else { center = bounds.getCenter(); zoom = map.getBoundsZoomLevel(bounds); map.setCenter(center,zoom); } <?php if (!empty($addon)) { print "\n\tside_bar_html +=\"" . $addon . "\"\n"; } ?> side_bar_html +="</TABLE>\n"; document.getElementById("side_bar").innerHTML += side_bar_html; // append the assembled side_bar_html contents to the side_bar div <?php do_kml(); // generate KML JS - added 5/23/08 print "\n</SCRIPT>\n"; }
$("do_sv").style.display = "block"; map.clearOverlays(); do_lat (point.lat().toFixed(6)) // display do_lng (point.lng().toFixed(6)) do_grids(document.add); do_marker(point.lat(), point.lng(), null); // 12/6/08 thePoint = point; if (grid) {map.addOverlay(new LatLonGraticule());} } getAddress(marker, point); }); document.add.show_lat.disabled=document.add.show_lng.disabled=true; <?php do_kml(); ?> } // end if (GBrowserIsCompatible()) } // end function load() function URLEncode(plaintext ) { // The Javascript escape and unescape functions do // NOT correspond with what browsers actually do... var SAFECHARS = "0123456789" + // Numeric "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic "abcdefghijklmnopqrstuvwxyz" + // guess "-_.!~*'()"; // RFC2396 Mark characters var HEX = "0123456789ABCDEF"; var encoded = "";
function list_responders($addon = '', $start) { global $u_types; ?> <SCRIPT> try { parent.frames["upper"].document.getElementById("whom").innerHTML = "<?php print $_SESSION['user']; ?> "; parent.frames["upper"].document.getElementById("level").innerHTML = "<?php print get_level_text($_SESSION['level']); ?> "; parent.frames["upper"].document.getElementById("script").innerHTML = "<?php print LessExtension(basename(__FILE__)); ?> "; } catch(e) { } var color=0; var colors = new Array ('odd', 'even'); var starting = false; function $() { // 1/23/09 var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } function isNull(val) { // checks var stuff = null; return val === null; } function do_aprs_window() { // 6/25/08 // echo '<a href="mycgi?foo=', urlencode($userinput), '">'; // var url = "http://www.openaprs.net?center=" + "<?php print urlencode(get_variable('def_lat') . ',' . get_variable('def_lng')); ?> "; var url = "http://www.openaprs.net?center=" + "<?php print get_variable('def_lat') . ',' . get_variable('def_lng'); ?> "; var spec ="titlebar, resizable=1, scrollbars, height=640,width=640,status=0,toolbar=0,menubar=0,location=0, left=50,top=250,screenX=50,screenY=250"; newwindow=window.open(url, 'openaprs', spec); if (isNull(newwindow)) { alert ("APRS display requires popups to be enabled. Please adjust your browser options."); return; } newwindow.focus(); } // end function function do_track(callsign) { if (parent.frames["upper"].logged_in()) { map.closeInfoWindow(); var width = <?php print get_variable('map_width'); ?> +360; var spec ="titlebar, resizable=1, scrollbars, height=640,width=" + width + ",status=0,toolbar=0,menubar=0,location=0, left=100,top=300,screenX=100,screenY=300"; var url = "track_u.php?source="+callsign; newwindow=window.open(url, callsign, spec); if (isNull(newwindow)) { alert ("Track display requires popups to be enabled. Please adjust your browser options."); return; } // starting = false; newwindow.focus(); } } // end function function hideGroup(color) { for (var i = 0; i < gmarkers.length; i++) { if (gmarkers[i]) { if (gmarkers[i].id == color) { gmarkers[i].show(); } else { gmarkers[i].hide(); } } // end if (gmarkers[i]) } // end for () elem = document.getElementById("allIcons"); elem.style.visibility = "visible"; } // end function function showAll() { for (var i = 0; i < gmarkers.length; i++) { if (gmarkers[i]) { gmarkers[i].show(); } } // end for () elem = document.getElementById("allIcons"); elem.style.visibility = "hidden"; } // end function function create_track_Marker(point,html, mytype, ender, heading) { switch (mytype){ case 1: // alert(99); var marker = new GMarker(point, starticon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); break; case ender: // alert(106); var marker = new GMarker(point, endicon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); break; default : var infoicon = new GIcon(); infoicon.image = "./markers/" + direcs[heading]; infoicon.iconSize = new GSize(15, 15); infoicon.iconAnchor = new GPoint(4, 4); var marker = new GMarker(point, infoicon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); } return marker; } // 1/24/09 function createMarker(point,tabs, color, id) { // Creates marker and sets up click event infowindow points = true; // at least one var letter = String.fromCharCode("A".charCodeAt(0) + id); // start with A - 1/5/09 var icon = new GIcon(listIcon); var icon_url = "./our_icons/gen_icon.php?blank=" + escape(icons[color]) + "&text=" + letter; // 1/5/09 icon.image = icon_url; // ./our_icons/gen_icon.php?blank=4&text=zz" var marker = new GMarker(point, icon); marker.id = color; // for hide/unhide - unused GEvent.addListener(marker, "click", function() { // here for both side bar and icon click map.closeInfoWindow(); which = id; gmarkers[which].hide(); marker.openInfoWindowTabsHtml(infoTabs[id]); // var dMapDiv = document.getElementById("detailmap"); // var detailmap = new GMap2(dMapDiv); // detailmap.addControl(new GSmallMapControl()); // detailmap.setCenter(point, 13); // larger # = closer // detailmap.addOverlay(marker); setTimeout(function() { // wait for rendering complete - 12/17/08 if ($("detailmap")) { var dMapDiv = $("detailmap"); var detailmap = new GMap2(dMapDiv); detailmap.addControl(new GSmallMapControl()); detailmap.setCenter(point, 17); // larger # = closer detailmap.addOverlay(marker); } else { // alert(62); // alert($("detailmap")); } },4000); // end setTimeout(...) }); // end GEvent.addListener() gmarkers[id] = marker; // marker to array for side_bar click function infoTabs[id] = tabs; // tabs to array // bounds.extend(point); // extend the bounding box - removed 5/26/08 return marker; } // end function create Marker() function do_sidebar (sidebar, id, call) { var letter = String.fromCharCode("A".charCodeAt(0) + id); // start with A - 1/5/09 side_bar_html += "<TR CLASS='" + colors[(id)%2] +"' onClick = myclick(" + id + ");>"; side_bar_html += "<TD CLASS='td_label'>" + letter + ". "+ sidebar +"</TD></TR>\n"; // 1/5/09 } function do_sidebar_nm (sidebar, line_no, rcd_id) { // no map - view responder // view_Form var letter = String.fromCharCode("A".charCodeAt(0) + line_no); // start with A - 1/5/09 side_bar_html += "<TR CLASS='" + colors[(line_no)%2] +"' onClick = myclick_nm(" + id + ");>"; side_bar_html += "<TD CLASS='td_label'>" + letter + ". "+ sidebar +"</TD></TR>\n"; // 1/23/09 } function myclick_nm(v_id) { // Responds to sidebar click - view responder data alert("No track data"); } function myclick(id, call) { // Responds to sidebar click, then triggers listener above - note [id] GEvent.trigger(gmarkers[id], "click"); } function doGrid() { map.addOverlay(new LatLonGraticule()); } function do_lat (lat) { document.forms[0].frm_lat.disabled=false; document.forms[0].frm_lat.value=lat.toFixed(6); document.forms[0].frm_lat.disabled=true; } function do_lng (lng) { document.forms[0].frm_lng.disabled=false; document.forms[0].frm_lng.value=lng.toFixed(6); document.forms[0].frm_lng.disabled=true; } // 2/24/09 var direcs=new Array("north.png","north_east.png","east.png","south_east.png","south.png","south_west.png","west.png","north_west.png", "north.png"); // 10/4/08 var icons=[]; // note globals <?php $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}unit_types` ORDER BY `id`"; // types in use $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); $icons = $GLOBALS['icons']; while ($row = stripslashes_deep(mysql_fetch_assoc($result))) { // map type to blank icon id $blank = $icons[$row['icon']]; print "\ticons[" . $row['id'] . "] = " . $row['icon'] . ";\n"; // } unset($result); ?> var starticon = new GIcon(); starticon.image = "./markers/start.png"; starticon.iconSize = new GSize(16, 16); starticon.iconAnchor = new GPoint(8, 8); var endicon = new GIcon(); endicon.image = "./markers/end.png"; endicon.iconSize = new GSize(16, 16); endicon.iconAnchor = new GPoint(8, 8); var map; var side_bar_html = "<TABLE border=0 CLASS='sidebar' ID='tbl_responders'>"; side_bar_html += "<TR class='even'> <TD colspan=99 ALIGN='center'><B>Mobile Units</B></TD></TR>"; side_bar_html += "<TR class='odd'> <TD colspan=99 ALIGN='center'>Click line or icon for information</TD></TR>"; side_bar_html += "<TR class='even'> <TD></TD><TD ALIGN='center'>Name</TD><TD ALIGN='center'>Description</TD><TD ALIGN='center'>Status</TD><TD>M</TD><TD ALIGN='center'>#</TD><TD ALIGN='center'>As of</TD></TR>"; var gmarkers = []; var infoTabs = []; var which; var i = k = 0; // sidebar/icon index, track point index var points = false; // none map = new GMap2(document.getElementById("map")); // create the map // map.addControl(new GSmallMapControl()); map.setUIToDefault(); // 8/13/10 map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(<?php echo get_variable('def_lat'); ?> , <?php echo get_variable('def_lng'); ?> ), <?php echo get_variable('def_zoom'); ?> ); // <?php echo get_variable('def_lat'); ?> var bounds = new GLatLngBounds(); // create bounding box // map.addControl(new GOverviewMapControl()); map.enableScrollWheelZoom(); var listIcon = new GIcon(); listIcon.image = "./markers/yellow.png"; listIcon.shadow = "./markers/sm_shadow.png"; listIcon.iconSize = new GSize(20, 34); listIcon.shadowSize = new GSize(37, 34); listIcon.iconAnchor = new GPoint(8, 28); listIcon.infoWindowAnchor = new GPoint(9, 2); listIcon.infoShadowAnchor = new GPoint(18, 25); GEvent.addListener(map, "infowindowclose", function() { // re-center after move/zoom map.setCenter(center,zoom); map.addOverlay(gmarkers[which]) }); <?php $calls = array(); $calls_nr = array(); $calls_time = array(); $query = "SELECT * , UNIX_TIMESTAMP(updated) AS `updated` FROM `{$GLOBALS['mysql_prefix']}tracks_hh` ORDER BY `id` DESC LIMIT 20"; // 6/17/08 $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), __FILE__, __LINE__); while ($row = mysql_fetch_assoc($result)) { if (isset($calls[$row['source']])) { // array_key_exists ( mixed key, array search ) $calls_nr[$row['source']]++; } else { // array_push ($calls, trim($row['source'])); $calls[trim($row['source'])] = TRUE; $calls_nr[$row['source']] = 1; } $calls_time[$row['source']] = $row['packet_date']; // save latest - note query order } // dump($calls); // dump($calls_nr); // dump($calls_time); $query = "SELECT `id`, `status_val` FROM `{$GLOBALS['mysql_prefix']}un_status`"; // build unit status values array $temp_result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), __FILE__, __LINE__); $status_vals[0] = "TBD"; while ($temp_row = mysql_fetch_assoc($temp_result)) { // build array of values $status_vals[$temp_row['id']] = $temp_row['status_val']; } $query = "SELECT *, UNIX_TIMESTAMP(updated) AS updated FROM `{$GLOBALS['mysql_prefix']}responder` WHERE `mobile` = 1 AND `aprs` = 1 AND `callsign` <> '' ORDER BY `name`"; // 1/24/09 $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); // dump(mysql_affected_rows()); $bulls = array(0 => "", 1 => "red", 2 => "green", 3 => "white", 4 => "black"); // major while ... for mobile RESPONDER data starts here $aprs = FALSE; // legend show/not boolean while ($row = stripslashes_deep(mysql_fetch_assoc($result))) { $toedit = is_guest() ? "" : "<A HREF='units.php?func=responder&edit=true&id=" . $row['id'] . "'><U>Edit</U></A> "; $totrack = empty($row['callsign']) ? "" : " <SPAN onClick = do_track('" . $row['callsign'] . "');><U>Tracks</U></SPAN> "; $temp = $row['un_status_id']; // 2/24/09 $the_status = array_key_exists($temp, $status_vals) ? $status_vals[$temp] : "??"; // 2/2/09 if (!$row['mobile'] == 1) { // for fixed units $mode = $row['lat'] == 0 ? 4 : 0; // toss invalid lat's ?> var point = new GLatLng(<?php print $row['lat']; ?> , <?php print $row['lng']; ?> ); // mobile position <?php } else { // is mobile, do infowin, etc. $query = "SELECT DISTINCT `source`, `latitude`, `longitude` ,`course` ,`speed` ,`altitude` ,`closest_city` ,`status` , UNIX_TIMESTAMP(packet_date) AS `packet_date`, UNIX_TIMESTAMP(updated) AS `updated` FROM `{$GLOBALS['mysql_prefix']}tracks_hh` WHERE `source` = '" . $row['callsign'] . "' ORDER BY `updated`"; // 6/16/08 $result_tr = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__); if (mysql_affected_rows() > 0) { ?> var j=1; // point counter this unit var ender = <?php print mysql_affected_rows(); ?> ; <?php $last = ""; while ($row_tr = stripslashes_deep(mysql_fetch_assoc($result_tr))) { ?> bounds.extend(new GLatLng(<?php print $row_tr['latitude']; ?> , <?php print $row_tr['longitude']; ?> )); // all points to bounding box var point = new GLatLng(<?php print $row_tr['latitude']; ?> , <?php print $row_tr['longitude']; ?> ); var html = "<b><?php print $row_tr['source']; ?> </b><br /><br /><?php print format_date($row['updated']); ?> "; var heading = Math.round(<?php print intval($row_tr['course']); ?> /45); // 10/4/08 var marker = create_track_Marker(point, html, j, ender, heading); map.addOverlay(marker); <?php if (!empty($last)) { ?> var polyline = new GPolyline([ new GLatLng(<?php print $last['latitude']; ?> , <?php print $last['longitude']; ?> ), // prior point new GLatLng(<?php print $row_tr['latitude']; ?> , <?php print $row_tr['longitude']; ?> ) // current point ], "#FF0000", 2); map.addOverlay(polyline); points++; j++;k++; <?php } // end if (!empty($last)) $last = $row_tr; // either way } // end while ($row_tr...) $mode = $last['speed'] == 0 ? 1 : 2; if ($last['speed'] >= 50) { $mode = 3; } ?> var point = new GLatLng(<?php print $last['latitude']; ?> , <?php print $last['longitude']; ?> ); // mobile position <?php } else { // no track data, do sidebar only $mode = 4; } // end if/else (mysql_affected_rows()>0;) - no track data } // end mobile // common to all modes $the_bull = $mode == 0 ? "" : "<FONT COLOR=" . $bulls[$mode] . "><B>•</B></FONT>"; $eols = array("\r\n", "\n", "\r"); // all flavors of eol $sidebar_line = "<TD>" . shorten($row['name'], 30) . "</TD><TD>" . shorten(str_replace($eols, " ", $row['description']), 16) . "</TD>"; // $sidebar_line .= "<TD CLASS='td_data'> " . shorten($status_vals[$row['un_status_id']], 16) . "</TD><TD CLASS='td_data'> " . $the_bull . "</TD>"; $sidebar_line .= "<TD CLASS='td_data'> " . shorten($the_status, 16) . "</TD><TD CLASS='td_data'> " . $the_bull . "</TD>"; $the_count = isset($calls[$row['callsign']]) ? $calls_nr[$row['callsign']] : ""; // track records // $the_time = (isset($calls[$row['callsign']]))? $calls_time[$row['callsign']]: $row['updated']; // latest report time if (isset($calls[$row['callsign']])) { $the_time = $calls_time[$row['callsign']]; $the_class = "aprs"; $aprs = TRUE; // show legend } else { $the_time = $row['updated']; $the_class = "td_data"; } $sidebar_line .= "<TD CLASS='td_data' ALIGN='right'> " . $the_count . "</TD>"; $sidebar_line .= "<TD CLASS='{$the_class}'>" . format_sb_date($the_time) . "</TD>"; ?> var do_map = true; // default <?php $temptype = $u_types[$row['type']]; $the_type = $temptype[0]; // 1/1/09 $tab_1 = "<TABLE CLASS='infowin' width='" . $_SESSION['scr_width'] / 4 . "'>"; // $tab_1 .= "<TR CLASS='even'><TD COLSPAN=2 ALIGN='center'><B>" . shorten($row['name'], 48) . "</B> - " . $types[$row['type']] . "</TD></TR>"; $tab_1 .= "<TR CLASS='even'><TD COLSPAN=2 ALIGN='center'><B>" . shorten($row['name'], 48) . "</B> - " . $the_type . "</TD></TR>"; $tab_1 .= "<TR CLASS='odd'><TD>Description:</TD><TD>" . shorten(str_replace($eols, " ", $row['description']), 32) . "</TD></TR>"; // $tab_1 .= "<TR CLASS='even'><TD>Status:</TD><TD>" . $status_vals[$row['un_status_id']] . " </TD></TR>"; $tab_1 .= "<TR CLASS='odd'><TD>Contact:</TD><TD>" . $row['contact_name'] . " Via: " . $row['contact_via'] . "</TD></TR>"; $tab_1 .= "<TR CLASS='even'><TD>As of:</TD><TD>" . format_date($row['updated']) . "</TD></TR>"; $tab_1 .= "<TR CLASS='odd'><TD COLSPAN=2 ALIGN='center'>Details:" . $totrack . " " . $toedit . "<A HREF='units.php?func=responder&view=true&id=" . $row['id'] . "'><U>View</U></A></TD></TR>"; $tab_1 .= "</TABLE>"; // dump($row['callsign']); switch ($mode) { case 0: // not mobile ?> do_sidebar ("<?php print str_replace($eols, " ", $sidebar_line); ?> ", i, <?php print $row_tr['source']; ?> ); var myinfoTabs = [ new GInfoWindowTab("<?php print nl2brr(shorten($row['name'], 10)); ?> ", "<?php print $tab_1; ?> "), new GInfoWindowTab("Zoom", "<div id='detailmap' class='detailmap'></div>") ]; <?php break; case 1: // stopped // stopped case 2: // moving // moving case 3: // fast ?> do_sidebar ("<?php print str_replace($eols, " ", $sidebar_line); ?> ", i); <?php $tab_2 = "<TABLE CLASS='infowin' width='" . $_SESSION['scr_width'] / 4 . "'>"; $tab_2 .= "<TR CLASS='even'><TD COLSPAN=2 ALIGN='center'><B>" . $last['source'] . "</B></TD></TR>"; $tab_2 .= "<TR CLASS='odd'><TD>Course: </TD><TD>" . $last['course'] . ", Speed: " . $last['speed'] . ", Alt: " . $last['altitude'] . "</TD></TR>"; $tab_2 .= "<TR CLASS='even'><TD>Closest city: </TD><TD>" . $last['closest_city'] . "</TD></TR>"; $tab_2 .= "<TR CLASS='odd'><TD>Status: </TD><TD>" . $last['status'] . "</TD></TR>"; $tab_2 .= "<TR CLASS='even'><TD>As of: </TD><TD>" . format_date($last['packet_date']) . "(UTC)</TD></TR>"; // 6/16/08 $tab_2 .= "</TABLE>"; ?> var myinfoTabs = [ new GInfoWindowTab("<?php print nl2brr(shorten($row['name'], 10)); ?> ", "<?php print $tab_1; ?> "), new GInfoWindowTab("<?php print $last['source']; ?> ", "<?php print $tab_2; ?> "), new GInfoWindowTab("Zoom", "<div id='detailmap' class='detailmap'></div>") ]; <?php break; case 4: // mobile - no track ?> do_sidebar_nm ("<?php print str_replace($eols, " ", $sidebar_line); ?> ", i, <?php print $row['id']; ?> ); // special sidebar link - adds id for view var do_map = false; <?php break; default: echo "mode error: {$mode}"; break; } // end switch ?> if (do_map) { var marker = createMarker(point, myinfoTabs,<?php print $row['type']; ?> , i); // (point,tabs, color, id) map.addOverlay(marker); } i++; // zero-based <?php } // end major while ($row = ...) for each responder $aprs_legend = $aprs ? "<TD CLASS='aprs' ALIGN='center'>APRS time</TD>" : "<TD></TD>"; ?> if (!points) { // any? map.setCenter(new GLatLng(<?php echo get_variable('def_lat'); ?> , <?php echo get_variable('def_lng'); ?> ), <?php echo get_variable('def_zoom'); ?> ); } else { center = bounds.getCenter(); zoom = map.getBoundsZoomLevel(bounds)-1; map.setCenter(center,zoom); } side_bar_html+= "<TR CLASS='" + colors[i%2] +"'><TD COLSPAN=6> </TD></TR>"; side_bar_html+= "<TR CLASS='" + colors[(i+1)%2] +"'><TD COLSPAN=6 ALIGN='center'><B>M</B>obility: stopped: <FONT COLOR='red'><B>•</B></FONT> moving: <FONT COLOR='green'><B>•</B></FONT> fast: <FONT COLOR='white'><B>•</B></FONT> silent: <FONT COLOR='black'><B>•</B></FONT></TD><?php print $aprs_legend; ?> </TR>"; <?php if (!empty($addon)) { print "\n\tside_bar_html +=\"" . $addon . "\"\n"; } // $temp = get_variable('auto_poll'); // $aprs_but = (intval($temp>0))? "<TR><TD COLSPAN=99 ALIGN='center'><INPUT TYPE='button' value= 'APRS' onClick ='do_aprs_window();'></TD></TR>": ""; $aprs_but = ""; ?> side_bar_html += "<?php print $aprs_but; ?> "; document.getElementById("side_bar").innerHTML += side_bar_html; // append the assembled side_bar_html contents to the side_bar div <?php do_kml(); ?> </SCRIPT> <?php }