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.