diff --git a/servers/php/deleteroute.php b/servers/php/deleteroute.php index c7cf8fa..af0cf0c 100644 --- a/servers/php/deleteroute.php +++ b/servers/php/deleteroute.php @@ -1,7 +1,10 @@ multi_query($query)) { diff --git a/servers/php/displaymap.php b/servers/php/displaymap.php index e9b80aa..e0d60a3 100644 --- a/servers/php/displaymap.php +++ b/servers/php/displaymap.php @@ -2,12 +2,12 @@ Google Map GPS Cell Phone Tracker - + - - - - + + + + - -
GPS Tracker
+ +
GpsTracker
@@ -84,10 +92,20 @@ - - - - +

Please note that phoneNumber (ie. androidUser) and sessionID are being displayed in the dropdown box below the map. You can change "androidUser" to anything you want. It will make it easier to identify your route during testing.

+  
+

It's line 148 in GpsTrackerActivity.java of the Android Studio project. This is the line:
+  
+ requestParams.put("phonenumber", "androidUser");

+change it to: + 

+requestParams.put("phonenumber", "anythingElse");

+please. :o) +

+
diff --git a/servers/php/getgpslocations.php b/servers/php/getgpslocations.php index 6af1b43..e096c17 100644 --- a/servers/php/getgpslocations.php +++ b/servers/php/getgpslocations.php @@ -1,8 +1,11 @@ '; diff --git a/servers/php/images/gpstracker.png b/servers/php/images/gpstracker.png new file mode 100644 index 0000000..bc3c543 --- /dev/null +++ b/servers/php/images/gpstracker.png Binary files differ diff --git a/servers/php/javascript/maps.js b/servers/php/javascript/maps.js index 3ce6c68..26e1982 100644 --- a/servers/php/javascript/maps.js +++ b/servers/php/javascript/maps.js @@ -1,37 +1,31 @@  -function loadRoutes(data, responseCode) { - if (data.length == 0) { +function loadRoutes(xml) { + if (xml.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++) { + // iterate through the routes and load them into the dropdwon box. + $(xml).find('route').each(function(){ 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"); + option.setAttribute('value', '?sessionID=' + $(this).attr('sessionID') + + '&phoneNumber=' + $(this).attr('phoneNumber')); + option.innerHTML = $(this).attr('phoneNumber') + " " + $(this).attr('sessionID') + " " + $(this).attr('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 @@ -41,8 +35,15 @@ var url = 'getgpslocations.php' + routeSelect.options[routeSelect.selectedIndex].value; //alert("testing route: " + routeSelect.options[routeSelect.selectedIndex].value); - - GDownloadUrl(url, loadGPSLocations); + + $.ajax({ + url: url, + type: 'GET', + dataType: 'xml', + success: function(data) { + loadGPSLocations(data); + } + }); } else { alert("Please select a route before trying to refresh map."); @@ -59,135 +60,123 @@ } } -function loadGPSLocations(data, responseCode) { - if (data.length == 0) { +function loadGPSLocations(xml) { + if (xml.length == 0) { showMessage('There is no tracking data to view.'); map.innerHTML = ''; } else { - if (GBrowserIsCompatible()) { + // get rid of the wait gif + hideWait(); - // create list of GPS data locations from our XML - var xml = GXml.parse(data); + var map = new google.maps.Map( + document.getElementById('map'), { + zoom: zoomLevel, + mapTypeId: google.maps.MapTypeId.ROADMAP + }); - // 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.setUIToDefault(); - - - // note: replace this publisher ID with your own. + // note: replace this adsense publisher ID and channel with your own. var publisherID = 'pub-7095775186404141'; + var channel = '6961715451'; + var adUnitDiv = document.createElement('div'); + var adUnitOptions = { + format: google.maps.adsense.AdFormat.HALF_BANNER, + position: google.maps.ControlPosition.TOP_CENTER, + backgroundColor: '#c4d4f3', + borderColor: '#e5ecf9', + titleColor: '#0000cc', + textColor: '#000000', + urlColor: '#009900', + publisherId: publisherID, + channelNumber: channel, + map: map, + visible: true + }; + var adUnit = new google.maps.adsense.AdUnit(adUnitDiv, adUnitOptions); - var adsManagerOptions = { - maxAdsOnMap : 2, - style: 'adunit', - // The channel field is optional - replace this field with a channel number - // of your own for Google AdSense tracking - channel: '2332912476' - }; + var finalLocation = false; - adsManager = new GAdsManager(map, publisherID, adsManagerOptions); - adsManager.enable(); + // iterate through the locations and create map markers for each location + $(xml).find('locations').each(function(){ + + // want to set the map center on the last location + if ($(this).is(':last-child')) { + map.setCenter(new google.maps.LatLng($(this).attr('latitude'),$(this).attr('longitude'))); + finalLocation = true; + } - 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("extraInfo")); - - // add markers to map - map.addOverlay(marker); - } + var marker = createMarker( + $(this).attr('latitude'), + $(this).attr('longitude'), + $(this).attr('speed'), + $(this).attr('direction'), + $(this).attr('distance'), + $(this).attr('locationMethod'), + $(this).attr('gpsTime'), + $(this).attr('phoneNumber'), + $(this).attr('sessionID'), + $(this).attr('accuracy'), + $(this).attr('extraInfo'), + map, finalLocation); + }); } - // show route name + // display route name above map showMessage(routeSelect.options[routeSelect.selectedIndex].innerHTML); - } } -function createMarker(i, length, point, speed, direction, distance, locationMethod, gpsTime, - phoneNumber, sessionID, accuracy, extraInfo) { - var icon = new GIcon(); +function createMarker(latitude, longitude, speed, direction, distance, locationMethod, gpsTime, + phoneNumber, sessionID, accuracy, extraInfo, map, finalLocation) { + var iconUrl; - // 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"; + if (finalLocation) { + iconUrl = 'images/coolred_small.png'; } else { - lm = locationMethod; + iconUrl = 'images/coolblue_small.png'; } + + var markerImage = { + url: iconUrl, + size: new google.maps.Size(12, 20), + origin: new google.maps.Point(0,0), + anchor: new google.maps.Point(6, 30) + }; + + var marker = new google.maps.Marker({ + position: new google.maps.LatLng(latitude, longitude), + map: map, + icon: markerImage + }); var lastMarker = ""; // when a user clicks on last marker, let them know it's final one - if (i == length - 1) { + if (finalLocation) { lastMarker = " Final location"; } // convert from meters to feet accuracy = parseInt(accuracy * 3.28); - - // this creates the pop up bubble that displays info when a user clicks on a marker - GEvent.addListener(marker, "click", function() { - marker.openInfoWindowHtml( - "" + + var contentString = "
" + "" + "" + "" - + "" + + "" + "" + "" + "" - + "" - - + "
  " - + "/" - + lastMarker + + "/" + lastMarker + "
Speed:" + speed + " mph
Distance:" + distance + " mi 
Time:" + gpsTime + "
Method:" + lm + " 
Method:" + locationMethod + " 
Phone #:" + phoneNumber + " 
Session ID:" + sessionID + " 
Accuracy:" + accuracy + " ft 
Extra Info:" + extraInfo + " 
" - ); - }); - - return marker; + + "Extra Info:" + extraInfo + " "; + + var infowindow = new google.maps.InfoWindow({ + content: contentString + }); + + google.maps.event.addListener(marker, 'click', function() { + infowindow.open(map, marker); + }); } // this chooses the proper image for our litte compass in the popup window @@ -218,7 +207,14 @@ if (answer){ showWait('Deleting route...'); var url = 'deleteroute.php' + routeSelect.options[routeSelect.selectedIndex].value; - GDownloadUrl(url, deleteRouteResponse); + + $.ajax({ + url: url, + type: 'GET', + success: function() { + deleteRouteResponse(); + } + }); } else { return false; @@ -229,10 +225,17 @@ } } -function deleteRouteResponse(data, responseCode) { +function deleteRouteResponse() { map.innerHTML = ''; routeSelect.length = 0; - GDownloadUrl('getroutes.php', loadRoutes); + + $.ajax({ + url: 'getroutes.php', + type: 'GET', + success: function(data) { + loadRoutes(data); + } + }); } // auto refresh the map. there are 3 transitions (shown below). transitions happen when a user @@ -297,7 +300,7 @@ } function showMessage(message) { - messages.innerHTML = 'GPS Tracker: ' + message + ''; + messages.innerHTML = 'GpsTracker: ' + message + ''; } function showRouteName() { @@ -305,13 +308,12 @@ } function showWait(theMessage) { - map.innerHTML = ''; + map.innerHTML = ''; showMessage(theMessage); } function hideWait() { map.innerHTML = ''; - messages.innerHTML = 'GPS Tracker'; + messages.innerHTML = 'GpsTracker'; } diff --git a/servers/php/styles/styles.css b/servers/php/styles/styles.css index 7c31ecc..f3fd485 100644 --- a/servers/php/styles/styles.css +++ b/servers/php/styles/styles.css @@ -1,8 +1,4 @@ -/* -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; @@ -11,15 +7,19 @@ font-family: arial, helvetica, sans-serif; font-size: 17px; } -#messages -{ +#test { + position:absolute; + left: 750px; + top: 50px; + width:400px; +} +#messages { position:absolute; left: 10px; top: 10px; - width:700px; + width:950px; } -#map -{ +#map { position:absolute; left: 10px; top: 40px; @@ -29,43 +29,33 @@ border-style:solid; background-color:#FFF; } - -#selectRoute -{ +#selectRoute { position:absolute; left: 10px; top: 510px; - width: 575px; + width: 600px; } - -#selectRefresh -{ +#selectRefresh { position:absolute; left: 10px; top: 550px; width: 250px; } - -#selectZoomLevel -{ +#selectZoomLevel { position:absolute; - left: 335px; + left: 360px; top: 550px; width: 250px; } - -#delete -{ +#delete { position:absolute; - left: 625px; + left: 637px; top: 510px; width: 75px; } - -#refresh -{ +#refresh { position:absolute; - left: 625px; + left: 637px; top: 550px; width: 75px; } diff --git a/servers/php/updatelocation.php b/servers/php/updatelocation.php index 46115d8..dce506e 100644 --- a/servers/php/updatelocation.php +++ b/servers/php/updatelocation.php @@ -6,20 +6,23 @@ //die(); // from the phone - $latitude = $_POST['latitude']; - $longitude = $_POST['longitude']; - $speed = $_POST['speed']; - $direction = $_POST['direction']; - $distance = $_POST['distance']; - $date = urldecode($_POST['date']); - $locationMethod = urldecode($_POST['locationmethod']); - $phoneNumber = $_POST['phonenumber']; - $sessionID = $_POST['sessionid']; - $accuracy = $_POST['accuracy']; - $extraInfo = $_POST['extrainfo']; - $eventType = $_POST['eventtype']; + isset($_POST['latitude']) ? $latitude = $_POST['latitude'] : $latitude = '0'; + isset($_POST['longitude']) ? $longitude = $_POST['longitude'] : $longitude = '0'; + isset($_POST['speed']) ? $speed = $_POST['speed'] : $speed = '0'; + isset($_POST['direction']) ? $direction = $_POST['direction'] : $direction = '0'; + isset($_POST['distance']) ? $distance = $_POST['distance'] : $distance = '0'; + isset($_POST['date']) ? $date = $_POST['date'] : $date = $_POST['date']; + $date = urldecode($date); + isset($_POST['locationmethod']) ? $locationMethod = $_POST['locationmethod'] : $locationMethod = '0'; + $locationMethod = urldecode($locationMethod); + isset($_POST['phonenumber']) ? $phoneNumber = $_POST['phonenumber'] : $phoneNumber = '0'; + isset($_POST['sessionid']) ? $sessionID = $_POST['sessionid'] : $sessionID = '0'; + isset($_POST['accuracy']) ? $accuracy = $_POST['accuracy'] : $accuracy = '0'; + isset($_POST['extrainfo']) ? $extraInfo = $_POST['extrainfo'] : $extraInfo = '0'; + isset($_POST['eventtype']) ? $eventType = $_POST['eventtype'] : $eventType = '0'; // save the gps location to the database + // i'm not to worried about sql injection here since i'm calling a stored procedure here $query = 'CALL prcSaveGPSLocation(\'' . $latitude . '\',\'' . $longitude . '\',\''