How do I make my app only send location data if it is different (lat and long)

So far I have gotten my app to send the users location data to a google docs sheet and record that data and put it on google maps, the problem i have is that. If i stay in the same place it keeps filling up my google docs with the same long and lat data which I don’t need until the User moves.

I am thinking something which will detect if the Lat and Long are the same and if so don’t send that data, but i am unsure how I would be able to do this.

Any help would be greatly appreciated.

Here are some screenshots of what i have so far.

1 Like

When you get the user’s location, store the lat and long as variables (or join them into a single text string in a variable). If the current location from the sensor does not equal the stored variable location, then store it in the spreadsheet.

Or if you want to avoid extra variables, check the last row of the spreadsheet against the current sensor values and if it’s different, store it in the spreadsheet.

Can you send me a screenshot of how you would do that please.
Many Thanks, Levi

I don’t have that all set up but basically you would add a condition to your “create row” block that says if app variable lastLat ≠ [green latitude block] AND app variable lastLong ≠ [green longitude block] then… create row. Inside the “create row” block’s “do” section, set app variable lastLat to [green latitude block] and set app variable lastLong to [green longitude block].

If that doesn’t work, post a screenshot of your blocks and someone can help you fix them.

Thanks I will test this out.

I have created this for you in another post

Basically check if it is the same user. If true, update the same row, if a different user then create a row for that user.

1 Like

Sorry I can’t get it to work can you send a screenshot of what you did, this would be greatly appreciated.

Sorry for the back and forth but I expect you to post what you’ve tried. Otherwise, I’m just doing all the work for you. I assume you’ve spent time on this so why ask me to spend time to make the same thing? I can probably see pretty quickly what’s wrong if I can see your blocks.

2 Likes

you should also consider this in your calcuation.

that’s why i’m surprised at your google sheet - if it shows the exact same coordinates, the thing you are tracking must be absolutely still. if you’re using thunkable’s location sensor (i don’t know it’s accuracy), you should be getting different coordinates in the 6th digit after the decimal position everytime you move around 4 inches!
i suggest you use the absolute value of the difference between the truncated values (to the 4th digit) of the latitudes and longitudes and if both values are zero, the object you’re tracking hasn’t “moved” outside 11.1x11.1 meter area.

hence these 2 points are considered the “same location”
-26.6807999 153.0837111 to
-26.6807000 153.0837876

EDIT - you better change that precision to 3rd digit after the decimal point.
i wrote a little “exerciser” of the location sensor

and found out that even turning 90 degrees while i’m on my swivel chair gives me a big enough difference:

here’s a link to my exerciser (see screen 6)
https://x.thunkable.com/copy/b27c41fcbe4f3c3eb31d52afd71910bc

2 Likes

I don’t really understand your first post about Setting up the rows etc.

Sorry, I am not trying to make you do all the work I’m just new to Thunkable.

This is what I have so far.

Mant Thanks Levi

1 Like

Here’s how I would set it up:

Note that my create row block is using a table that doesn’t have UserLat and UserLong values but you would attach the green latitude and longitude blocks to those just as in your screenshot above.

There’s a chance that you might have to initialize the two variables to actual values (e.g. 0) but I think it will work the way I have it here.

2 Likes

Thank you so much, really appreciated

This now works thanks for your help.

2 Likes

You’re welcome! You can mark my post as the solution so others know that solved it.

1 Like

Ok sounds Good.

1 Like

Ok Sounds Good, Thanks For your Help.

1 Like