Thursday, August 04, 2016

Tasker Hacking: Automatically Publish Your Location To A Google Map

Matt, is an ultra hiker who wanted to publish his location for all to see, yet mask some of the details (such as timestamp). His solution, which he describes here, makes use of a clever service: mapalist. Mapalist monitors a Google Spreadsheet and converts the data published there to flags on a map.

Matt's solution for sharing controlled waypoints involves manually editing a Google Doc on his phone and then having Mapalist publish this data. That's certainly a workable solution, but of course, my first thought was: how can I automate this?

The answer: Tasker! What makes this so easy to do is the existence of a Tasker plugin to update Google Spreadsheets. I installed the plugin, signed up with mapalist, and created a skeleton Google Spreadsheet. All that was left to do was to use Tasker to glue everything together.

First, I had to figure out what event I wanted to trigger logging my location. I could have done it based on time of day, which for a multi-day hike, makes quite a bit of sense. Another option: I could have wired this into my Pebble watch, so points are saved whenever I click a button on my watch. For my little test, I hooked it into the Steps Taken event in Tasker.

For testing purposes, I choose 50 as the step interval. In a real hiking scenario, I'd probably set it to five or ten thousand steps, depending on how frequently I wanted the points to be published.

Next, I had to write the actual Tasker action to grab the location, tweak the format a bit and push the data to the Spreadsheet plugin. Here's that code:

Profile: Map My Location
  Event: Steps Taken [ Number:50 ]

Enter: Map My Location
  A1: Get Location [ Source:GPS ... ] 
  A2: Variable Set [ 
    Name:%data
    To:%LOC;My Location within %LOCACC  meters Do
  ] 
  A3: Variable Search Replace [
    Variable:%data Search:,
    Replace With:; 
  ] 
  A4: Spreadsheet Update [
    Configuration:Update Where was I?
    Timeout (Seconds):20
  ] 

I then turned on the event during a walk and logged a few points. You'll notice that the points are sort of all over the place. That's due to the limitation in GPS accuracy and the fact that I was logging points so close together. I'll replace this example with data from my next run or hike, and the map should be more informative. Here's an example of a run I captured and published:

If I were using this data for more than testing purposes, I'd update the above action to also store the data in a text file locally. That way, even if there were internet issues along the trail, I'd know I would have a reliable stash of data regardless.

As a visualization tool, it's hard to beat mapalist. And with Tasker integration, the only thing limiting the data you publish is your imagination. Fun stuff! Thanks Matt!

Update: I've temporarily disabled the map above until I get a better data set.

Update: I've got a real example map above in place, and have published version 2.0 of this solution, which supports offline publishing.

No comments:

Post a Comment