Null values returned by Google Distance matrix

The string I am using for testing currently is
https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=51,0&destinations=52,0&key=AIzaSyAYiancwAdNBHcw7Ho7S1o2Xt_OM0WM44k

This is all a bit frustrating. I have used these same blocks in another app without an issue. YEsterday the app was going into a white screen cras as soon as I made the api call but today at least I can see an error message being returned. I would really appreciate all the feedback and insight you can supply.

Many thanks to you all for looking into this.

I’ve seen that message and it usually isn’t an accurate description of the problem. I think that gets sent when an API call either doesn’t contain the correct parameters or when something else happens like being over quota (I made an app that worked perfectly, shared it with my colleagues at work and then quickly went over the API’s stated quota… oops!).

Unless you’ve change it since you posted the link to postcodes (https://x.thunkable.com/projects/5f553e7941fe930bd6970783/5688ede2-4094-4685-8a0a-a375b3b98451/designer), you aren’t checking for the status… you’re only checking for the error block.

If you share a project link and then make any changes to the project, the link only points to the original/old content. So you have to then share another project link. Kind of a pain.

I may not be much help here. I only develop on Mac and test on iPhone. Sorry!

Chech it

https://x.thunkable.com/projects/5f5c627733142a64f7cb93ed/project/properties/designer/

all input is welcome sir :slight_smile:

New link to the problem app is here where the report of the error and the blank status is returned.
https://x.thunkable.com/projects/5f59e6096f239bf97b8157da/5688ede2-4094-4685-8a0a-a375b3b98451/blocks

Doesnt work! No distance result is shown in LabelResults.From my tests it seems the request is refused due to the https error mentioned above so we dont get a status return at all so your code never fires.

@rwplummer1yf4f This example works well on my device.

Interesting. It Doesnt work in live test as the response I get is The website or service provider you are trying to reach does not support HTTPS requests.—

The blocks join the error message, then — and then the return status and the returned status is blank so error trapping doesnt work and no value is returned. Does this point to an issue with the WEBAPI calls within thunkable that it works on external devices but not with the live preview tool provided by Thunkable?

I only use Live Preview to check if the app is working at all. I do all the other debugging either on emulators or on devices, and for this reason I don’t have many problem

1 Like

So we are just accepting it doesnt work with the thunkable live or web preview. That’s not the support I was hoping for tbh. Should I raise this further as it appears to be a bug. Tatiang, Can you give me a link to any distancematrix support groups you may know of please and i’ll take it up with them.

THanks

Dont know if you saw my response below. Do you know of any distancematrix forums I could go to for help?

I’m not sure if you’re directing your comment at us or at Thunkable Staff but just to be clear, I’m a customer. I don’t have any affiliation with Thunkable beyond that.

I don’t know of any forums. There may be some. I just recently learned about the distance matrix API myself. As I looked into it, I decided I preferred to use the haversine formula for calculating distance. So I added that to my project and it seems to be working pretty well. It was several hours of work but this was really helpful: Calculate distance travelled

Have you tried using sheets to do the math? You should be able to calculate distances using sheets, right?

1 Like

@jared That’s what I’m doing. I just got it working. The formula I used was:

=ACOS(COS(RADIANS(90-lat1)) *COS(RADIANS(90-lat2)) +SIN(RADIANS(90-lat2)) *SIN(RADIANS(90-lat2)) *COS(RADIANS(lon1-long2))) *3958.756

I replaced the values in bold with actual cell references.

1 Like

The problem I’m having though – not to derail this thread but it is somewhat related – is that when I update a Google Sheet cell, it destroys the formulas in that row. So if I update A2, then the formula in A7 turns into a value rather than a formula.

@tatiang It turns out that you need to rewrite the formula in the cell every time?

You tried to do this: place the formulas in a row that doesn’t change, for example, in row 1, and place the data for it in the cells of other rows 2 and higher.

1 Like

@actech Yeah, that’s actually what I ended up doing. I just moved the data down one row so the header row is row 1 and the data is row 3. My formula is in row 2. But it’s just such a terrible workaround. I know, it works, but it’s not elegant. And I tried two sheets instead – one for the updated data and one for the static data with formula – but Thunkable ignored the “Sheet” value in the update value block. Ugh.