How does it work?
Generally, there are three requirements for my location tracking:
- it must be automatic (no need for me to manually update my location),
- it should use very little power (so that my battery is not drained immediately),
- my location should be uploaded to my blog.
For requirements 1-2, there are several apps that do exactly that (one example is the app LD-Log). However, uploading my location to this blog was not possible with any of these apps, so I programmed one myself to do exactly that.
On my smartphone (Samsung S4 mini), I put together a small script in Tasker (best app ever made for Android). The scrip runs every 20 minutes. It enables the GPS module and then tries to find a GPS signal. If GPS coordinates are obtained, they are saved to a file. Otherwise the script waits for 5 minutes and then tries to obtain the coordinates again (in case I’m currently in a building and there is no GPS signal). Afterwards, it tries to upload the file to my server, which – of course – only works in case my smartphone has a working internet connection. If no internet connection is available, the file remains in the local storage and the script tries to upload it the next time.
On my server (where this blog is also located), I have a SQL database. I programmed a php-script that handles the upload of the coordinates from my phone and inserts the uploaded coordinates into the database.
The visualization of the actual route (all coordinates connected chronologically by a red line) is done with the GoogleMaps JS API (and some help from my friends over at wdj.ac).