OSMand Online Tracking

Discussion in 'Mapping & Navigation' started by FishDiver, Dec 25, 2017.

  1. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA
    I just discovered the the latest version of the app will upload GPX tracks automatically when a cell signal is available, allowing riders to send positions and routes similar to a SPOT device. I tried to set this up using the instructions on the Help pag and I can't get it to function.

    Android
    You can set up your phone to track its location. To do that, go to Plugins - Trip recording and tap Settings, then choose Online Tracking. To make it possible, you also have to provide a valid link.

    Make a Google Spreadsheet and name it. Then go to Tools - Scrip Editor - Create script for - Blank project. In your spreadsheet, copy the key from the URL field. It is a set of numbers like this:

    https://docs.google.com/spreadsheets/d/1ev_1UaENcl7ukWsE-tnO6ixVxFdn0OlNhTHKAHUHjEg/edit#gid=0

    Go back to the script.

    Delete everything. Insert this code:

    This is some text! function doGet(e) { var app = UiApp.createApplication(); var sp = SpreadsheetApp.openById("0Ana......"); sp.insertRowBefore(1); if(e) { var d = new Date( Date( e.parameter.timestamp)); sp.getRange( "A1").setValue( parseFloat( e.parameter.lat)); sp.getRange( "B1").setValue( parseFloat( e.parameter.lon)); sp.getRange( "F1").setValue( Math.round(( parseFloat( e.parameter.speed / 1000 * 60 *60))) + " km/h"); sp.getRange( "D1").setValue( parseFloat( e.parameter.altitude)); sp.getRange( "E1").setValue( parseFloat( e.parameter.hdop)); sp.getRange( "C1").setValue( d); } return app; }
    Paste your Spreadsheet key instead of 0Ana......

    Save and go to Publish - Deploy as web app - set access as Anyone, even anonymous.

    Now your movements will be exported to that spreadsheet as coordinates. You'll find speed information in the document. You can also set tracking interval.

    I did all that and entered the URL of the Google doc into my phone under "online tracking web address". It is not working. Anyone done this successfully and able to tell me what is wrong?
    #1
    vmfpg likes this.
  2. Bozze

    Bozze n00b

    Joined:
    Apr 14, 2012
    Oddometer:
    7
    Yes, I have it working. Although for how long remains to be seen, because when the script is executed in the script editor there's a message that reads "UiApp API is deprecated".

    Anyway, make sure you have the correct URL, it's the one pointing to the script itself not the spreadsheet. It's visible under Current web app URL when you publish it. So the URL in OsmAnd should be like this:
    Code:
    https://script.google.com/macros/s/RaNd0mSTr1nGbyG0ogL3/exec?lat={0}&lon={1}&timestamp={2}&hdop={3}&altitude={4}&speed={5}
    You could copy/paste the URL directly in the browser address bar and substitute the parameters, ie. {0}, with some values and if the script is correct it should immediately be visible in the spreadsheet.
    #2
  3. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA
    Bozze, i think I entered the URL for the spreadsheet into Osmand. This is the code from my published script:

    function doGet(e) {
    var app = UiApp.createApplication();
    var sp = SpreadsheetApp.openById(" https://docs.google.com/spreadsheets/d/1ymYcs84bMJxvo42R6RYYkwSBaoRbVRZxLfcl48NmAgw/edit#gid=0");
    sp.insertRowBefore(1);
    if(e) {
    var d = new Date( Date( e.parameter.timestamp));
    sp.getRange( "A1").setValue( parseFloat( e.parameter.lat));
    sp.getRange( "B1").setValue( parseFloat( e.parameter.lon));
    sp.getRange( "F1").setValue( Math.round(( parseFloat( e.parameter.speed / 1000 * 60 *60))) + " km/h");
    sp.getRange( "D1").setValue( parseFloat( e.parameter.altitude));
    sp.getRange( "E1").setValue( parseFloat( e.parameter.hdop));
    sp.getRange( "C1").setValue( d);
    }
    return app;
    }

    Whe I click "run" on the script editor I get "Bad value on line 3". This is line 3:

    var sp = SpreadsheetApp.openById("https://docs.google.com/spreadsheets/d/1ymYcs84bMJxvo42R6RYYkwSBaoRbVRZxLfcl48NmAgw/edit#gid=0");
    #3
  4. Bozze

    Bozze n00b

    Joined:
    Apr 14, 2012
    Oddometer:
    7
    #4
  5. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA
    #5
  6. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA
    Google also informed me during the dubugging process that one line was deprecated. Can it be undeprecated or is this some Google ruling.
    #6
  7. Bozze

    Bozze n00b

    Joined:
    Apr 14, 2012
    Oddometer:
    7
    The URL in your OsmAnd should be:
    Code:
    https://script.google.com/macros/s/AKfycbze66I2oGNbM-BkchNcy9rUBIn5g4H0KOmtlSpQudLGaB-rkh2M/exec?lat={0}&lon={1}&timestamp={2}&hdop={3}&altitude={4}&speed={5}
    Once you've got it working you should consider making a copy of the working script and publish that one. That way you'll get a new unique id (ie. this part: AKfycbze66I2oGNbM-BkchNcy9rUBIn5g4H0KOmtlSpQudLGaB-rkh2M). Since the published web app is public anyone who knows the URL can use it (and now the whole world knows). Not that'll do anyone any good since they can't access the spreadsheet itself, but you might end up with a spreadsheet filled with bot spam.

    Nothing much you can do about the UiApp API being deprecated other than finding another Google API which can do the same. Some years ago with the old Google Maps you could also use a script to plot the route on a map with coordinates from the spreadsheet, but that too got deprecated and stopped working once they moved to the new Google Maps version. So in the end I stopped using the spreadsheet approach and decided to write my own php-script to take care of the task instead of depending on any Google API that may or may not work a week/month/year from now.
    #7
  8. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA
    Thanks, I entered the URL into Osmand and took a brief ride. Still not seeing anything on the google doc. I may give up since it will get deprecated at some point. Is there any online service I can use that will not deprecate the API and will allow others to view my tracks as a map overlay? My goal is to send a web link to technically unsophisticated friends and family so they can monitor my location offroad.
    #8
  9. Bozze

    Bozze n00b

    Joined:
    Apr 14, 2012
    Oddometer:
    7
    The easy way is to use the location sharing features in Google Maps or WhatsApp. There are also dedicated apps, like Glympse, that do the same thing. Those won't probably show the entire track, only your current location (or last known).
    #9
  10. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA
    Can you walk me through this or point to an info source?
    #10
  11. Bozze

    Bozze n00b

    Joined:
    Apr 14, 2012
    Oddometer:
    7
    #11
  12. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA
    #12
  13. Bozze

    Bozze n00b

    Joined:
    Apr 14, 2012
    Oddometer:
    7
    Yes, those are independent so they're not integrated with OsmAnd in any way.

    In order to use OsmAnd to achieve what you want, you would need a web service that:
    a) receives the data sent by OsmAnd
    b) plots the route on a map layer

    Such solutions do exist but most of them require that you have some means of hosting the server side scripts yourself and knowledge in how to install/setup these scripts. https://www.traccar.org/ is probably the closest you'll get to an out-of-box solution when it comes to OsmAnd. They have some demo servers you can use in case you don't want to setup your own.

    The process is pretty straight forward:
    1. go to http://demo4.traccar.org/
    2. register a new account & log in
    3. once the interface has loaded add a device by clicking the + sign
    4. give the device a name (e.g. MyTestDevice) and an identifier (e.g. MySecretId1234)
    5. enter the the following url in OsmAnd: http://demo4.traccar.org:5055/?id=MySecretId1234&lat={0}&lon={1}&timestamp={2}&hdop={3}&altitude={4}&speed={5}
    Replace the MySecretId1234 string with whatever you chose in step 4
    #13
  14. worwig

    worwig Long timer

    Joined:
    Nov 30, 2009
    Oddometer:
    1,716
    Location:
    Hog Mountain
    I have had Google location sharing on my phone for a few years. I can tell you where the lunch stop was on a cross country ride in 2014. It is really handy. Paranoid people are not going to like it. The only time I had trouble on that 5000 mile ride, wa in Yellowstone. No cell towers there, so no record of that. But the rest of the two week trip is pretty accurate. I suspect it would not be good for people wanting to create a detailed track of a path deep in a forest somewhere.

    Also, Google location sharing uses low accuracy when the phone screen is off to save power. But if the phone is on and you you use the phone GPS, it is very accurate.
    #14
    ohgood likes this.
  15. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA

    I used Google location sharing on a ride today. It just shows straight lines between stops rather than the actual route. For some reason, it feels more "Big Brother" that the Osmand system. Maybe because Osmand is so difficult to program and doesn't sell my personal data to everyone on Planet Earth.

    BTW, thanks for all your help.
    #15
  16. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA
    Did Google show our actual route or just line between stops? I often ride in areas with very poor cell reception.
    #16
  17. worwig

    worwig Long timer

    Joined:
    Nov 30, 2009
    Oddometer:
    1,716
    Location:
    Hog Mountain
    If I am using the GPS on my phone, and keep the phone on, the track is pretty detailed and follows the curve of the road. If the phone is not being used, it only updates occasionally, and you get pretty jagged lines. As I mentioned, I used the phone as a GPS on a cross country trip, and have very detailed tracks every day. But, even Verizon dropped the signal near Yellowstone. There are some big holes in the track there.

    Basically, it is great for what I want. And my family knows where I am when I ride. But if I needed a detailed track through a forest to share with someone later, I would be recording offline with an app.
    #17
  18. FishDiver

    FishDiver Adventurer

    Joined:
    May 27, 2016
    Oddometer:
    28
    Location:
    Sacramento, CA
    When you say the phone was on and used as a GPS, do you mean that the screen was on and visible too? I often use the phone that way with Osmand and no cell signal. For my experiment with Google Locations I rode around an area with good cell reception with Google Maps open and the screen dimmed and phone in pocket. The Google recorded every place I stopped for more than 1/2 hour and showed a straight line between stops.

    Better than nothing for an emergency situation but not nearly as accurate as I hoped.
    #18
  19. worwig

    worwig Long timer

    Joined:
    Nov 30, 2009
    Oddometer:
    1,716
    Location:
    Hog Mountain
    This is a screen cap from the other day on a trip. It is recording about every 10 seconds. I likely was using Waze at the time.
    [​IMG]

    Sent from my SM-N950U using Tapatalk
    #19
  20. pckopp

    pckopp Aged Adventurer

    Joined:
    Feb 25, 2003
    Oddometer:
    1,359
    Location:
    Seattle, WA
    Sounds like some kind of buffer or memory would solve this. The tracking gps software would keep recording during times with no cell signal and upload the whole track when there is cell service.

    My Android phone (LG V10) has location sharing:
    Settings - Location - Google Location Sharing

    Then you can select who to share with and any number of ways, including most social media.
    #20