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!
all input is welcome sir
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
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?
@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.
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.
@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.