diff --git a/phoneClients/ios/GpsTracker/WSViewController.m b/phoneClients/ios/GpsTracker/WSViewController.m index 8ab8ad1..cabaa70 100644 --- a/phoneClients/ios/GpsTracker/WSViewController.m +++ b/phoneClients/ios/GpsTracker/WSViewController.m @@ -47,8 +47,8 @@ locationManager = [[CLLocationManager alloc] init]; locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; locationManager.distanceFilter = 0; // meters - locationManager.pausesLocationUpdatesAutomatically = NO; // YES is default - // locationManager.activityType = CLActivityTypeAutomotiveNavigation; + //locationManager.pausesLocationUpdatesAutomatically = NO; // YES is default + locationManager.activityType = CLActivityTypeAutomotiveNavigation; locationManager.delegate = self; guid = [NSUUID UUID]; @@ -114,7 +114,11 @@ } else { CLLocationDistance distance = [location distanceFromLocation:previousLocation]; totalDistanceInMeters += distance; + + } + + previousLocation = location; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd%20HH:mm:ss"]; // mysql format @@ -132,8 +136,6 @@ lastWebsiteUpdateTime = [NSDate date]; // new timestamp - previousLocation = location; - } else if (!increasedAccuracy) { [self increaseTrackingAccuracy]; } @@ -169,6 +171,9 @@ - (void)updateWebsiteWithLatitde:(NSString *)latitude longitude:(NSString *)longitude speed:(NSString *)speed date:(NSString *)date distance:(NSString *)distance sessionID:(NSString *)sessionID accuracy:(NSString *)accuracy extraInfo:(NSString *)extraInfo direction:(NSString *)direction { + // NSString *defaultWebSite = @"http://www.websmithing.com/gpstracker2/getgooglemap3.php"; + NSString *defaultWebSite = @"http://192.168.1.19/GpsTracker/UpdateLocation.aspx"; + AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; @@ -178,14 +183,14 @@ @"date": date, @"locationmethod": @"n/a", @"distance": distance, - @"phonenumber": @"iosUser", + @"phonenumber": @"iosUser1", @"sessionid": sessionID, @"extrainfo": extraInfo, @"accuracy": accuracy, @"eventtype": @"ios", @"direction": direction}; - [manager POST:@"http://www.websmithing.com/gpstracker2/getgooglemap3.php" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { + [manager POST:defaultWebSite parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"location sent to website."); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"AFHTTPRequestOperation Error: %@", [error description]); diff --git a/servers/dotNet/App_Code/DbWriter.cs b/servers/dotNet/App_Code/DbWriter.cs new file mode 100755 index 0000000..2632b97 --- /dev/null +++ b/servers/dotNet/App_Code/DbWriter.cs @@ -0,0 +1,79 @@ + +using System; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; + + +/// +/// Inserts or updates MSSQL using stored procedure. +/// Returns new identity column ID if successful or 0 if not. +/// +public class DbWriter +{ + public DbWriter() + { + } + + /// + /// This method takes an optional list of parameters. + /// + public string updateDB(string storedProcedureName, params SqlParameter[] spParameterList) + { + string identityColumnID = "0"; + SqlDataReader sqlDataReader = null;; + SqlConnection sqlConnection = null; + + try + { + + sqlConnection = new SqlConnection(); + sqlConnection.ConnectionString = GetConnectionString(); + + SqlCommand cmd = new SqlCommand(); + cmd.Connection = sqlConnection; + cmd.CommandText = storedProcedureName; + cmd.CommandType = CommandType.StoredProcedure; + + // optional list of parameters for stored procedure + if (spParameterList.Length > 0) + { + for (int i = 0; i < spParameterList.Length; i++) + { + cmd.Parameters.Add(spParameterList[i]); + } + } + + sqlConnection.Open(); + sqlDataReader = cmd.ExecuteReader(); + + // if we have successfully executed the stored procedure then + // get the identityColumnID from the DB + if (sqlDataReader.Read()) + { + identityColumnID = sqlDataReader.GetInt32(0).ToString(); + } + } catch (Exception e) { + Console.WriteLine("updateDB error: " + e.Message); + } finally { + if (sqlConnection != null) + { + sqlConnection.Close(); + } + if (sqlDataReader != null) + { + sqlDataReader.Close(); + } + } + + return identityColumnID; + } + + private string GetConnectionString() + { + return ConfigurationManager.ConnectionStrings + ["MSSQLConnectionString"].ConnectionString; + } +} + + diff --git a/servers/dotNet/App_Code/DbXmlReader.cs b/servers/dotNet/App_Code/DbXmlReader.cs new file mode 100755 index 0000000..0e2f871 --- /dev/null +++ b/servers/dotNet/App_Code/DbXmlReader.cs @@ -0,0 +1,82 @@ + +using System; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Xml; + + +public class DbXmlReader +{ + /// + /// Gets xml from MSSQL Server and returns it as a string. + /// + public DbXmlReader() + { + } + + /// + /// This method takes an optional list of paramters. + /// + public string getXmlString(string storedProcedureName, params SqlParameter[] spParameterList) + { + SqlConnection sqlConnection = null; + XmlReader xmlReader = null; + string xmlString = ""; + + try + { + sqlConnection = new SqlConnection(); + sqlConnection.ConnectionString = GetConnectionString(); + + SqlCommand cmd = new SqlCommand(); + cmd.Connection = sqlConnection; + cmd.CommandText = storedProcedureName; + cmd.CommandType = CommandType.StoredProcedure; + + // optional list of parameters for stored procedure + if (spParameterList.Length > 0) + { + for (int i = 0; i < spParameterList.Length; i++) + { + cmd.Parameters.Add(spParameterList[i]); + } + } + + sqlConnection.Open(); + xmlReader = cmd.ExecuteXmlReader(); + xmlReader.Read(); + + // we are getting XML straight from the stored procedure, so add it to + // our XML string + while (xmlReader.ReadState != ReadState.EndOfFile) + { + xmlString = xmlReader.ReadOuterXml(); + } + } + catch (Exception e) + { + Console.WriteLine("updateDB error: " + e.Message); + } + finally + { + if (sqlConnection != null) + { + sqlConnection.Close(); + } + if (xmlReader != null) + { + xmlReader.Close(); + } + } + + return xmlString; + } + + private string GetConnectionString() // stored in web.config + { + return ConfigurationManager.ConnectionStrings + ["MSSQLConnectionString"].ConnectionString; + } +} + diff --git a/servers/dotNet/DeleteRoute.aspx b/servers/dotNet/DeleteRoute.aspx new file mode 100755 index 0000000..84ffd51 --- /dev/null +++ b/servers/dotNet/DeleteRoute.aspx @@ -0,0 +1,2 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DeleteRoute.aspx.cs" Inherits="DeleteRoute" %> + diff --git a/servers/dotNet/DeleteRoute.aspx.cs b/servers/dotNet/DeleteRoute.aspx.cs new file mode 100755 index 0000000..49503d8 --- /dev/null +++ b/servers/dotNet/DeleteRoute.aspx.cs @@ -0,0 +1,23 @@ + +using System; +using System.Data.SqlClient; + +public partial class DeleteRoute : System.Web.UI.Page +{ + protected void Page_Load(object sender, EventArgs e) + { + string sessionID = Request.QueryString["sessionID"]; + string phoneNumber = Request.QueryString["phoneNumber"]; + + // our helper class to get data + DbXmlReader reader = new DbXmlReader(); + + Response.AppendHeader("Content-Type", "text/xml"); + + // actually we are getting a response back here, but the result will be a deleted route on the webpage + Response.Write(reader.getXmlString("prcDeleteRoute", + new SqlParameter("@sessionID", sessionID), + new SqlParameter("@phoneNumber", phoneNumber))); + + } +} diff --git a/servers/dotNet/DisplayMap.aspx b/servers/dotNet/DisplayMap.aspx new file mode 100755 index 0000000..c4b4fea --- /dev/null +++ b/servers/dotNet/DisplayMap.aspx @@ -0,0 +1,101 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DisplayMap.aspx.cs" Inherits="DisplayMap" %> + + + + + Google Map GPS Cell Phone Tracker + + + + + + + + + +
+
GPS Tracker
+
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/servers/dotNet/DisplayMap.aspx.cs b/servers/dotNet/DisplayMap.aspx.cs new file mode 100755 index 0000000..fbe8eb4 --- /dev/null +++ b/servers/dotNet/DisplayMap.aspx.cs @@ -0,0 +1,26 @@ + +using System; +using System.Configuration; +using System.Web.UI; + +public partial class DisplayMap : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + // the application uses the Google map key on 2 different pages so the key is stored in + // web.config. the code below gets the key and then injects this javascript code onto the + // web page. It will be used to get the Google javascript library for maps. The reason we + // go through all this is so that we can store the Google key in one location. + + string url = "http://maps.google.com/maps?file=api&v=2.x&key=" + GetGoogleMapKey(); + + if (!ClientScript.IsClientScriptBlockRegistered("googleKey")) { + String scriptString = ""; + ClientScript.RegisterClientScriptBlock(this.GetType(), "googleKey", scriptString); + } + } + + private string GetGoogleMapKey() { // stored in web.config + return ConfigurationManager.AppSettings["GoogleMapKey"]; + } +} diff --git a/servers/dotNet/GetRouteForMap.aspx b/servers/dotNet/GetRouteForMap.aspx new file mode 100755 index 0000000..4c8da4a --- /dev/null +++ b/servers/dotNet/GetRouteForMap.aspx @@ -0,0 +1,2 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetRouteForMap.aspx.cs" Inherits="GetRouteForMap" %> + diff --git a/servers/dotNet/GetRouteForMap.aspx.cs b/servers/dotNet/GetRouteForMap.aspx.cs new file mode 100755 index 0000000..81cbf3b --- /dev/null +++ b/servers/dotNet/GetRouteForMap.aspx.cs @@ -0,0 +1,24 @@ + +using System; +using System.Data.SqlClient; + +public partial class GetRouteForMap : System.Web.UI.Page +{ + protected void Page_Load(object sender, EventArgs e) + { + string sessionID = Request.QueryString["sessionID"]; + string phoneNumber = Request.QueryString["phoneNumber"]; + + // our helper class to get data + DbXmlReader reader = new DbXmlReader(); + + Response.AppendHeader("Content-Type", "text/xml"); + + // sessionID and phoneNumber are the unique identifiers for routes if the phoneNumber is unique. + // the phoneNumber field is a string field and anything can be put in that field, but for + // uniqueness, the actual phone number should be used + Response.Write(reader.getXmlString("prcGetRouteForMap", + new SqlParameter("@sessionID", sessionID), + new SqlParameter("@phoneNumber", phoneNumber))); + } +} diff --git a/servers/dotNet/GetRoutes.aspx b/servers/dotNet/GetRoutes.aspx new file mode 100755 index 0000000..299e118 --- /dev/null +++ b/servers/dotNet/GetRoutes.aspx @@ -0,0 +1,2 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetRoutes.aspx.cs" Inherits="GetRoutes" %> + diff --git a/servers/dotNet/GetRoutes.aspx.cs b/servers/dotNet/GetRoutes.aspx.cs new file mode 100755 index 0000000..7e6a4cd --- /dev/null +++ b/servers/dotNet/GetRoutes.aspx.cs @@ -0,0 +1,15 @@ + +using System; + +public partial class GetRoutes : System.Web.UI.Page +{ + protected void Page_Load(object sender, EventArgs e) + { + // our helper class to get data + DbXmlReader reader = new DbXmlReader(); + + Response.AppendHeader("Content-Type", "text/xml"); + + Response.Write(reader.getXmlString("prcGetRoutes")); + } +} diff --git a/servers/dotNet/README.md b/servers/dotNet/README.md index 2e38db7..7fe199e 100644 --- a/servers/dotNet/README.md +++ b/servers/dotNet/README.md @@ -1 +1,3 @@ -this is the .Net server using sql server for gpstracker. +The .NET server stack has been fully updated and tested. The gpstracker.bak file is the database backup file created with sql server 2012. + +Please note that this is an asp.net website, not a web application. Its means you need to put source files directly onto an asp.net web server like IIS and it will be compiled on the fly. To open this project in visual studio for web (2012), you need to go to the file menu and open website, then select you iis web server and open the gpstracker website that you created there. diff --git a/servers/dotNet/UpdateLocation.aspx b/servers/dotNet/UpdateLocation.aspx new file mode 100755 index 0000000..018518b --- /dev/null +++ b/servers/dotNet/UpdateLocation.aspx @@ -0,0 +1,2 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpdateLocation.aspx.cs" Inherits="UpdateLocation" %> + diff --git a/servers/dotNet/UpdateLocation.aspx.cs b/servers/dotNet/UpdateLocation.aspx.cs new file mode 100755 index 0000000..8902987 --- /dev/null +++ b/servers/dotNet/UpdateLocation.aspx.cs @@ -0,0 +1,59 @@ + +using System; +using System.IO; +using System.Net; +using System.Text; +using System.Data.SqlClient; + +public partial class UpdateLocation : System.Web.UI.Page { + + protected void Page_Load(object sender, EventArgs e) { + string latitude = Request.Form["latitude"]; + string longitude = Request.Form["longitude"]; + string speed = Request.Form["speed"]; + string direction = Request.Form["direction"]; + string distance = Request.Form["distance"]; + string date = Server.UrlDecode(Request.Form["date"]); + + // convert to DateTime format + date = convertFromMySqlDate(date); + + string locationMethod = Server.UrlDecode(Request.Form["locationmethod"]); + string phoneNumber = Request.Form["phonenumber"]; + string sessionID = Request.Form["sessionid"]; + string accuracy = Request.Form["accuracy"]; + string eventType = Request.Form["eventtype"]; + string extraInfo = Request.Form["extrainfo"]; + + // our helper class to update the database + DbWriter dbw = new DbWriter(); + + try { + + // update the database with our GPS data from the phone + dbw.updateDB("prcSaveGPSLocation", + new SqlParameter("@latitude", latitude), + new SqlParameter("@longitude", longitude), + new SqlParameter("@speed", speed), + new SqlParameter("@direction", direction), + new SqlParameter("@distance", distance), + new SqlParameter("@date", date), + new SqlParameter("@locationMethod", locationMethod), + new SqlParameter("@phoneNumber", phoneNumber), + new SqlParameter("@sessionID", sessionID), + new SqlParameter("@accuracy", accuracy), + new SqlParameter("@eventType", eventType), + new SqlParameter("@extraInfo", extraInfo)); + } + catch (Exception ex) { + Response.Write(ex.Message); + } + } + + // convert to datetime string + private string convertFromMySqlDate(string date) { + DateTime dt = DateTime.ParseExact(date, "yyyy-MM-dd HH:mm:ss", + System.Globalization.CultureInfo.InvariantCulture); + return dt.ToString(); + } +} diff --git a/servers/dotNet/Web.Debug.config b/servers/dotNet/Web.Debug.config new file mode 100755 index 0000000..a657981 --- /dev/null +++ b/servers/dotNet/Web.Debug.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/servers/dotNet/Web.config b/servers/dotNet/Web.config new file mode 100755 index 0000000..5a236cc --- /dev/null +++ b/servers/dotNet/Web.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/servers/dotNet/gpstracker.bak b/servers/dotNet/gpstracker.bak new file mode 100755 index 0000000..13878d6 --- /dev/null +++ b/servers/dotNet/gpstracker.bak Binary files differ diff --git a/servers/dotNet/images/ajax-loader.gif b/servers/dotNet/images/ajax-loader.gif new file mode 100755 index 0000000..3c2f7c0 --- /dev/null +++ b/servers/dotNet/images/ajax-loader.gif Binary files differ diff --git a/servers/dotNet/images/compassE.jpg b/servers/dotNet/images/compassE.jpg new file mode 100755 index 0000000..e7ef937 --- /dev/null +++ b/servers/dotNet/images/compassE.jpg Binary files differ diff --git a/servers/dotNet/images/compassN.jpg b/servers/dotNet/images/compassN.jpg new file mode 100755 index 0000000..03f4998 --- /dev/null +++ b/servers/dotNet/images/compassN.jpg Binary files differ diff --git a/servers/dotNet/images/compassNE.jpg b/servers/dotNet/images/compassNE.jpg new file mode 100755 index 0000000..fd8d380 --- /dev/null +++ b/servers/dotNet/images/compassNE.jpg Binary files differ diff --git a/servers/dotNet/images/compassNW.jpg b/servers/dotNet/images/compassNW.jpg new file mode 100755 index 0000000..6ef421d --- /dev/null +++ b/servers/dotNet/images/compassNW.jpg Binary files differ diff --git a/servers/dotNet/images/compassS.jpg b/servers/dotNet/images/compassS.jpg new file mode 100755 index 0000000..841f24c --- /dev/null +++ b/servers/dotNet/images/compassS.jpg Binary files differ diff --git a/servers/dotNet/images/compassSE.jpg b/servers/dotNet/images/compassSE.jpg new file mode 100755 index 0000000..1253e8b --- /dev/null +++ b/servers/dotNet/images/compassSE.jpg Binary files differ diff --git a/servers/dotNet/images/compassSW.jpg b/servers/dotNet/images/compassSW.jpg new file mode 100755 index 0000000..62ddf3d --- /dev/null +++ b/servers/dotNet/images/compassSW.jpg Binary files differ diff --git a/servers/dotNet/images/compassW.jpg b/servers/dotNet/images/compassW.jpg new file mode 100755 index 0000000..f694a4d --- /dev/null +++ b/servers/dotNet/images/compassW.jpg Binary files differ diff --git a/servers/dotNet/images/coolblue_small.png b/servers/dotNet/images/coolblue_small.png new file mode 100755 index 0000000..597a53e --- /dev/null +++ b/servers/dotNet/images/coolblue_small.png Binary files differ diff --git a/servers/dotNet/images/coolred_small.png b/servers/dotNet/images/coolred_small.png new file mode 100755 index 0000000..47384e2 --- /dev/null +++ b/servers/dotNet/images/coolred_small.png Binary files differ diff --git a/servers/dotNet/images/coolshadow_small.png b/servers/dotNet/images/coolshadow_small.png new file mode 100755 index 0000000..3a89759 --- /dev/null +++ b/servers/dotNet/images/coolshadow_small.png Binary files differ diff --git a/servers/dotNet/images/cooltransparent_small.png b/servers/dotNet/images/cooltransparent_small.png new file mode 100755 index 0000000..ba7ed91 --- /dev/null +++ b/servers/dotNet/images/cooltransparent_small.png Binary files differ diff --git a/servers/dotNet/javascript/maps.js b/servers/dotNet/javascript/maps.js new file mode 100755 index 0000000..3a42928 --- /dev/null +++ b/servers/dotNet/javascript/maps.js @@ -0,0 +1,299 @@ + +function loadRoutes(data, responseCode) { + if (data.length == 0) { + showMessage('There are no routes available to view.'); + map.innerHTML = ''; + } + else { + // get list of routes + var xml = GXml.parse(data); + + var routes = xml.getElementsByTagName("route"); + + // create the first option of the dropdown box + var option = document.createElement('option'); + option.setAttribute('value', '0'); + option.innerHTML = 'Select Route...'; + routeSelect.appendChild(option); + + // iterate through the routes and load them into the dropdwon box. + for (i = 0; i < routes.length; i++) { + var option = document.createElement('option'); + option.setAttribute('value', '?sessionID=' + routes[i].getAttribute("sessionID") + + '&phoneNumber=' + routes[i].getAttribute("phoneNumber")); + option.innerHTML = routes[i].getAttribute("phoneNumber") + " " + routes[i].getAttribute("times"); + routeSelect.appendChild(option); + } + + // need to reset this for firefox + routeSelect.selectedIndex = 0; + + hideWait(); + showMessage('Please select a route below.'); + } + +} + +// this will get the map and route, the route is selected from the dropdown box +function getRouteForMap() { + if (hasMap()) { + showWait('Getting map...'); + var url = 'GetRouteForMap.aspx' + routeSelect.options[routeSelect.selectedIndex].value; + GDownloadUrl(url, loadGPSLocations); + } + else { + alert("Please select a route before trying to refresh map."); + } +} + +// check to see if we have a map loaded, don't want to autorefresh or delete without it +function hasMap() { + if (routeSelect.selectedIndex == 0) { // means no map + return false; + } + else { + return true; + } +} + +function loadGPSLocations(data, responseCode) { + if (data.length == 0) { + showMessage('There is no tracking data to view.'); + map.innerHTML = ''; + } + else { + if (GBrowserIsCompatible()) { + + // create list of GPS data locations from our XML + var xml = GXml.parse(data); + + // markers that we will display on Google map + var markers = xml.getElementsByTagName("locations"); + + // get rid of the wait gif + hideWait(); + + // create new map and add zoom control and type of map control + var map = new GMap2(document.getElementById("map")); + map.addControl(new GSmallMapControl()); + map.addControl(new GMapTypeControl()); + + var length = markers.length; + + // center map on last marker so we can see progress during refreshes + map.setCenter(new GLatLng(parseFloat(markers[length-1].getAttribute("latitude")), + parseFloat(markers[length-1].getAttribute("longitude"))), zoomLevel); + + // interate through all our GPS data, create markers and add them to map + for (var i = 0; i < length; i++) { + var point = new GLatLng(parseFloat(markers[i].getAttribute("latitude")), + parseFloat(markers[i].getAttribute("longitude"))); + + var marker = createMarker(i, length, point, + markers[i].getAttribute("speed"), + markers[i].getAttribute("direction"), + markers[i].getAttribute("distance"), + markers[i].getAttribute("locationMethod"), + markers[i].getAttribute("gpsTime"), + markers[i].getAttribute("phoneNumber"), + markers[i].getAttribute("sessionID"), + markers[i].getAttribute("accuracy"), + markers[i].getAttribute("eventType"), + markers[i].getAttribute("extraInfo")); + + // add markers to map + map.addOverlay(marker); + } + } + + // show route name + showMessage(routeSelect.options[routeSelect.selectedIndex].innerHTML); + } +} + +function createMarker(i, length, point, speed, direction, distance, locationMethod, gpsTime, + phoneNumber, sessionID, accuracy, eventType, extraInfo) { + var icon = new GIcon(); + + // make the most current marker red + if (i == length - 1) { + icon.image = "images/coolred_small.png"; + } + else { + icon.image = "images/coolblue_small.png"; + } + + icon.shadow = "images/coolshadow_small.png"; + icon.iconSize = new GSize(12, 20); + icon.shadowSize = new GSize(22, 20); + icon.iconAnchor = new GPoint(6, 20); + icon.infoWindowAnchor = new GPoint(5, 1); + + var marker = new GMarker(point,icon); + + // this describes how we got our location data, either by satellite or by cell phone tower + var lm = ""; + if (locationMethod == "8") { + lm = "Cell Tower"; + } else if (locationMethod == "327681") { + lm = "Satellite"; + } else { + lm = locationMethod; + } + + var str = ""; + + // when a user clicks on last marker, let them know it's final one + if (i == length - 1) { + str = " Final location"; + } + + // this creates the pop up bubble that displays info when a user clicks on a marker + GEvent.addListener(marker, "click", function() { + marker.openInfoWindowHtml( + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + + "
  " + + "/" + + str + + "
Speed:" + speed + " mph
Distance:" + distance + " mi 
Time:" + gpsTime + "
Method:" + lm + " 
Phone #:" + phoneNumber + " 
Session ID:" + sessionID + " 
Accuracy:" + accuracy + " ft 
Event Type:" + eventType + " 
Extra Info:" + extraInfo + " 
" + ); + }); + + return marker; +} + +// this chooses the proper image for our litte compass in the popup window +function getCompassImage(azimuth) { + if ((azimuth >= 337 && azimuth <= 360) || (azimuth >= 0 && azimuth < 23)) + return "compassN"; + if (azimuth >= 23 && azimuth < 68) + return "compassNE"; + if (azimuth >= 68 && azimuth < 113) + return "compassE"; + if (azimuth >= 113 && azimuth < 158) + return "compassSE"; + if (azimuth >= 158 && azimuth < 203) + return "compassS"; + if (azimuth >= 203 && azimuth < 248) + return "compassSW"; + if (azimuth >= 248 && azimuth < 293) + return "compassW"; + if (azimuth >= 293 && azimuth < 337) + return "compassNW"; + + return ""; +} + +function deleteRoute() { + if (hasMap()) { + var answer = confirm("This will permanently delete this route\n from the database. Do you want to delete?") + if (answer){ + showWait('Deleting route...'); + var url = 'DeleteRoute.aspx' + routeSelect.options[routeSelect.selectedIndex].value; + GDownloadUrl(url, deleteRouteResponse); + } + else { + return false; + } + } + else { + alert("Please select a route before trying to delete."); + } +} + +function deleteRouteResponse(data, responseCode) { + map.innerHTML = ''; + routeSelect.length = 0; + GDownloadUrl('GetRoutes.aspx', loadRoutes); +} + +// auto refresh the map. there are 3 transitions (shown below). transitions happen when a user +// selects an option in the auto refresh dropdown box. an interval is an amount of time in between +// refreshes of the map. for instance, auto refresh once a minute. in the method below, the 3 numbers +// in the code show where the 3 transitions are handled. setInterval turns on a timer that calls +// the getRouteForMap() method every so many seconds based on the value of newInterval. +// clearInterval turns off the timer. if newInterval is 5, then the value passed to setInterval is +// 5000 milliseconds or 5 seconds. +function autoRefresh() { + /* + 1) going from off to any interval + 2) going from any interval to off + 3) going from one interval to another + */ + + if (hasMap()) { + newInterval = refreshSelect.options[refreshSelect.selectedIndex].value; + + if (currentInterval > 0) { // currently running at an interval + + if (newInterval > 0) { // moving to another interval (3) + clearInterval(intervalID); + intervalID = setInterval("getRouteForMap();", newInterval * 1000); + currentInterval = newInterval; + } + else { // we are turning off (2) + clearInterval(intervalID); + newInterval = 0; + currentInterval = 0; + } + } + else { // off and going to an interval (1) + intervalID = setInterval("getRouteForMap();", newInterval * 1000); + currentInterval = newInterval; + } + + // show what auto refresh action was taken and after 5 seconds, display the route name again + showMessage(refreshSelect.options[refreshSelect.selectedIndex].innerHTML); + setTimeout('showRouteName();', 5000); + } + else { + alert("Please select a route before trying to refresh map."); + refreshSelect.selectedIndex = 0; + } +} + +function changeZoomLevel() { + if (hasMap()) { + zoomLevel = zoomLevelSelect.selectedIndex + 1; + + getRouteForMap(); + + // show what zoom level action was taken and after 5 seconds, display the route name again + showMessage(zoomLevelSelect.options[zoomLevelSelect.selectedIndex].innerHTML); + setTimeout('showRouteName();', 5000); + } + else { + alert("Please select a route before selecting zoom level."); + zoomLevelSelect.selectedIndex = zoomLevel - 1; + } +} + +function showMessage(message) { + messages.innerHTML = 'Gps Tracker: ' + message + ''; +} + +function showRouteName() { + showMessage(routeSelect.options[routeSelect.selectedIndex].innerHTML); +} + +function showWait(theMessage) { + map.innerHTML = ''; + showMessage(theMessage); +} + +function hideWait() { + map.innerHTML = ''; + messages.innerHTML = 'Gps Tracker'; +} + diff --git a/servers/dotNet/styles/styles.css b/servers/dotNet/styles/styles.css new file mode 100755 index 0000000..ed7f8d8 --- /dev/null +++ b/servers/dotNet/styles/styles.css @@ -0,0 +1,71 @@ +/* +Please leave the link below with the source code, thank you. +http://www.websmithing.com/portal/Programming/tabid/55/articleType/ArticleView/articleId/6/Google-Map-GPS-Cell-Phone-Tracker-Version-2.aspx +*/ + +* { + margin: 0; + padding: 0; +} +body { + font-family: arial, helvetica, sans-serif; +} +#messages +{ + position:absolute; + left: 10px; + top: 10px; + width:700px; +} +#map +{ + position:absolute; + left: 10px; + top: 40px; + width:700px; + height:450px; + border:1px; + border-style:solid; + background-color:#FFF; +} + +#selectRoute +{ + position:absolute; + left: 10px; + top: 510px; + width: 575px; +} + +#selectRefresh +{ + position:absolute; + left: 10px; + top: 550px; + width: 250px; +} + +#selectZoomLevel +{ + position:absolute; + left: 335px; + top: 550px; + width: 250px; +} + +#delete +{ + position:absolute; + left: 625px; + top: 510px; + width: 75px; +} + +#refresh +{ + position:absolute; + left: 625px; + top: 550px; + width: 75px; +} +