Location reporting with OsmAnd

Page content

Is it possible to report your location from OsmAnd?

Instead of using dedicated equipment for navigation such as a Garmin eTrex or something comparable, I use a smartphone. A phone I will have with me anyways, so it saves me bringing another piece of equipment. Also a phone usually has a much better interface than the Garmins, it integrates better with other navigation stuff such as websites where I download tracks or Google KML files that I get via email.

True, a phone has disadvantages. If you drop your phone, most likely it will break. Most phones don’t like humidity, so you have to make sure it stays dry. Also the batteries are crap, as in: they don’t last. Therefore I use a phone that has a replaceable battery, and I replace the battery with a 7800 mAh supersize battery. Makes my smartphone run navigation software for three days continuously without a problem.

Apart from navigating, you can use your smartphone to regularly phone home and tell the world where you are. Relatives and friends can follow you on a map, and actually this is rather easy to do. No Garmin will do that for you.

There are several ways to put yourself on a map on a website so that others can follow you. The easiest way is to create an account with a dedicated service, for instance at www.followmee.com (note the double e). Very simple: you download and install an app through the Google Playstore, you create an account, and you put a little piece of code in a Wordpress website. Bingo: the whole world can now see where you are. You decide on the update frequency (once a minute, or once per hour) and when you don’t want people to see where you are, you can switch it off on your phone. Simple.

But since so many people use OsmAnd for navigation, I thought it would be nice to have OsmAnd update a location to our own server, and not use an external service. Would that be possible?

Yes! And it’s easy!

And it is not too complicated, but you need to be a little bit of a nerd to get it working. As it happens, many bikers are also a little nerdy, so there’s a good chance some of you can do what I did. Let me explain how I did it.

You need a LAMP-server

LAMP, yes, as in Linux Apache MySQL PHP. If you don’t know what that is, you can stop reading here, the rest won’t make sense. Actually the MySQL you don’t need, so a LAP-server would be enough. On your LAP server you create a page that has a PHP-scripts and some html with the following code:

Code written by Hervé Renault

Code written by Hervé Renault

Now to be honest I did not write this code myself, because I am not a PHP-guy, I just copied/lent/stole it from Hervé Renault from France. You can find his original source here on GitHub (edit: could, not can. Hervé removed his code from GitHub, so now the link point to a local copy on my server). Myself I use a slightly modified version that keeps history, but that’s not necessary and Hervé’s code runs just fine.

Settings In OsmAnd

When that works, you must instruct OsmAnd to send a position to the server every now and then. This is how you do that:

  1. Open the menu, click Plugins and activate the Trip recording plugin

  2. Open the menu, click Settings, click Trip recording

  3. select your profile, then somewhere near the bottom you see “Online tracking (GPX required)“. Here you can set the Online tracking web address.

Now the magic. Set the tracking address to: http://your.superserver.com/gpstracker/gps.php?lat={0}&lon={1}

And bingo… OsmAnd now sends location updates to your gps.php script, and your position is visible at your.superserver.com.

Supercool! Thanks to Hervé Renault!