Friday, April 8, 2011: A Simple GPS Tracker is Too Simple. My GPS Tracking Webapp. « from the old blog archive »
I was looking for a free GPS tracker to record trips from my school to my university on my iPad.
One that does the simplest things that a GPS tracker can do: record the coordinates and let me get these data out to do stuff with it.
I Haven't Found Any Which Works for Me
Many GPS trackers are not free (and has a lot of features I don't really want), or relies heavily on their own server.
I prefer to have full control over my data. I would like to only send them when I want, and have full access to them.
My Simplest GPS Tracking Webapp
This is the simplest GPS tracking webapp that works for me.
What it does: It logs your location and time in localStorage and submits them to any URL when you click "Submit". That's it.
Without much talking, let's see the code (or the live version).
It has got no map display, speedometer, or whatever. It just logs your coordinates locally into the textarea and localStorage and submits to the URL specified at the top.
This app won't communicate with the server (the URL specified at the top) unless you click the submit button.
Usage (for GPS-equipped iDevices)
- Turn off "Auto-Lock" in the Settings app (set it to Never). This app won't track your location when your device is off or locked.
- Open Safari and navigate to the web app's URL.
- Specify the server's URL.
- Tap the "Start Tracking" button.
- When tracking, no connection to the Internet is needed.
- Once finished, tap the "Submit" button to submit them to the server.
Receiving The Log
My GPS tracker sends the log (contents of the textarea) to the URL specified at the top by using the coords
POST variable.
Your script should be able to handle it easily. Here is the script that runs on my server:
<?php file_put_contents('/path/to/gps.log', $_POST['coords']);
Parsing The Log Format
There are 4 kinds of line. A comment line, a start line, a coordinate line, or the failing line.
A comment line starts with --
. Your log parser should ignore these lines. For example:
-- this is a comment
A start line indicates the time that the user pressed the "Start Tracking" button. The format is [time] // start
. For example:
1302263615830 // start
A coordinate line looks like [time] // [lat] // [lng]
. A example of this line:
1302263698765 // 13.797455945576084 // 100.61361547747381
Finally, a failure line indicates that the tracker wasn't able to track the position at a specified time. For example,
1302263678901 // fail
Have Fun With Your Data
Use it with Google Maps API or whatever. Have fun!
add / view all comments
Responses