Posted: 3/13/2010 3:19:17 PM EDT
|
I am using the Big Brother GPS software on my droid to send my current position to a server I have running at home. The script works find but it doesn't pin point my location on the map with a marker. Below is the script, is it possible to do what I want to do? <?php $name = "Scott"; $f = fopen("/tmp/position.cur", "r"); $p = fgets($f); $p = explode(":", $p); $time = $p[0]; $lat = $p[1]; $lon = $p[2]; $acc = $p[3]; $acc = (int)$acc; $pos = "$lat,$lon"; $time = strftime("%Y-%m-%d %H:%M:%S", $time); $utime = urlencode($time); $uname = urlencode($name); ?> <p> Latitude: <?=$lat?> <br /> Longitude: <?=$lon?> <br /> Accuracy: <?=$acc?> m<br /> Updated: <?=$time?> <br /> </p> <iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="<a href="http://maps.google.com/?ie=UTF8&q=Last+Update:+<?=$utime?><br>Accuracy:+<?=$acc?>m(<?=$uname?>)@<?=$pos?>&ll=<?=$pos?>&z=13&output=embed">http://maps.google.com/?ie=UTF8&q=Last+Update:+<?=$utime?><br>Accuracy:+<?=$acc?>m(<?=$uname?>)@<?=$pos?>&ll=<?=$pos?>&z=13&output=embed</a>"> </iframe> |
|
Quoted: Post the contents of /tmp/position.cur so someone can test the script.z Sorry, I get the rest of the data posted here. There is another script that the droid contacts to upload, that is posted below. <?php /* Get the position data from the POST parameters */ $lat = $_POST["latitude"]; $lon = $_POST["longitude"]; $acc = $_POST["accuracy"]; /* Write the position data to a file for the map script */ if ($lat && $lon && $acc) { $fcur = fopen("/tmp/position.cur", "w"); $time = time(); $out = "$time:$lat:$lon:$acc\n"; fputs($fcur, $out); fclose($fcur); } ?> Here is what's odd. The scripts didn't work until i created a tmp folder. After creating the tmp folder the map started showing my local area along with all the lat, long, time, speed etc. However, there is nothing ever in the tmp folder. I update the location from the device and then check the folder immediately afterwards and there is nothing there. I'm not expert but I don't see anything in the script that deletes the position.cur file. |
|
Quoted: Quoted: Quoted: ![]() <–– PHP ninja. Tag, for when I'm sober. DOH! Come on man! Get some coffee in you! :) I have a Droid, too. This looks cool, and kind of fun. I'll check back tomorrow. Right now, I just want to get drunk and listen to music. ![]() I figured you would like it. I was using another piece of software but I didn't like the fact that my position was being sent to someone else's server. I like having it go to a server that I control. |
|
Quoted: When you upload files with php, it uploads to a temp file. If you don't then copy/move the temp file to another location, (move_uploaded_file) it disappears. Thank you for the info. I'll have to dig up some code to do that. After I figure out the marker on the map I wanted to figure out how to keep a few of the position.cur files in another directory. |
|
function getMapCoordinates($mapDataRendered){
$url="http://maps.google.com/maps/geo?sensor=false&output=csv&key=".G_MAP_KEY."&q=".$mapDataRendered; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); curl_close ($ch); return($data); } This is my own snipet for pulling coords from formatted addresses. UPDATE: reread the question so not sure if this will help, we do have pinpoints on our displays so I can get you a example page with it up and running to examine the method. |
|
Thanks for the info. I'll have to look at it closely and see if I can figure it out. I really need to run and grab a PHP book. Quoted: function getMapCoordinates($mapDataRendered){ $url="http://maps.google.com/maps/geo?sensor=false&output=csv&key=".G_MAP_KEY."&q=".$mapDataRendered; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); curl_close ($ch); return($data); } This is my own snipet for pulling coords from formatted addresses. UPDATE: reread the question so not sure if this will help, we do have pinpoints on our displays so I can get you a example page with it up and running to examine the method. |
|
More than anything, I think it comes down to the formatting of this link to Google Maps src="http://maps.google.com/?ie=UTF8&q=Last+Update:+<?=$utime?><br>Accuracy:+<?=$acc?>m(<?=$uname?>)@<?=$pos?>&ll=<?=$pos?>&z=13&output=embed"> Also, I think that Java may need to be involved but I'm not positive. |
|
Quoted:
The scripts didn't work until i created a tmp folder. What? Every UNIX system should already have a /tmp directory. Even my Apple laptops have one. Something is seriously wrong with your system if /tmp was missing. Also, make sure /tmp has the correct permissions. You may need to do a "chmod 777 /tmp" then "chmod +t /tmp". Also, make sure you don't have safe_mode on: http://www.php.net/manual/en/features.safe-mode.php Even though I don't think that's the problem, it's something that will cause you headaches.z |
|
Quoted: Quoted: The scripts didn't work until i created a tmp folder. What? Every UNIX system should already have a /tmp directory. Even my Apple laptops have one. Something is seriously wrong with your system if /tmp was missing. Also, make sure /tmp has the correct permissions. You may need to do a "chmod 777 /tmp" then "chmod +t /tmp". Also, make sure you don't have safe_mode on: http://www.php.net/manual/en/features.safe-mode.php Even though I don't think that's the problem, it's something that will cause you headaches.cd LOL, your post helped me pull my head out of my butt. I had the script in /var/www/gps. It wasn't working at first so I added a tmp folder to this location. Everything started working after that so I moved on. However, after reading your post I face palmed and realized that when the script said /tmp is was looking at the root of the filesystem and not the root of the folder where the script was executed. The contents of position.cur is below though modified to not give away my current position :) 1268599476:46.178200866666664:-1094451365:64.0 Time: Lat: Long: Accuracy |
|
Here are the current scripts that I have running if anyone is interested. I was able to get the battery percentage up and am now working on the charging state. bbg_recv.php <?phpbbg_map.php <META HTTP-EQUIV=Refresh CONTENT="30">Contents of position.cur Formatted in, Time: Latitude: Longitude: Accuracy In Meters: Battery Life Percentage 1268606543:48.17820163333333:-101.84451631666667:24.0:30My goals
|
|
Well I had a few other things come along and this project was moved to the back burner. This morning I was able to take a fresh look at it and was able to knock it out fairly easily. The main problem was that I was improperly calling the variables into the Google Maps link. If you want to track your phone or allow others to track you and want the privacy of your own server this is the way to go. If you have any questions don't hesitate to ask. I've included the code for both pages below.
<meta http-equiv="content-type" content="text/html; charset=utf-8"></meta> bbg_recv.php <?php bbg_map.php <META HTTP-EQUIV=Refresh CONTENT="30"> |

