So, I’m brainstorming some ideas here to get Google Maps working in my app. My thought is to use a web viewer, capture click events, then pass those back to the app via a script. The thing I am unsure of is, how can I get the app to capture those clicks? Is there any way to do that outside of using a database to store the click information and then using an API call or something to grab it? My thought would be to put an API call in an infinite loop until some condition is returned to end the loop.
Anyone done anything or have any ideas on that? Just curious.
If you just want to identify the click location on the map, does this work for you? Maps by Google and Apple - Thunkable Docs (just remove the location sensor block, and connect the onPress event’s lat & long to addMarker)
My problem is the Google Maps component does not work in a published app. I can’t use Apple Maps in an Android app, so I am stuck. I am almost done with my workaround and it is working really well! I just need to figure out how to get the location text back into the app as a number so I can chop decimal places off and then I’m all set. It’s a bit of work, but it’s better than being stuck with blank maps.
So, I load my web page that has my Google Maps script into the map viewer I have created. When a user clicks on that, I use the Receives Message of the map viewer to get a returned message. My web page then returns a JSON with the latitude and longitude of the clicked point on the map. I can then pull this in and use it as a variable in the app. The end result is a working, clickable Google map!
Hi @muneer , do I understand you correctly, that the very basic component “web viewer” from Thunkable is not working in your app? For me it is working on iOS and Android. Some months ago I found out that you have to give the web_viewer component in the “design”-screen a valid URL, preferably a blank page (I use one from my own webspace).
Hi, I think this conversion from a list to an object is not correct:
AFAIK an object is an associative array with key/value pairs, like { “name”: “Mike”, “year”: 2021 }. But in your app you deliver only four values (numbers) without keys. I think you should build an object with 4 key/value pairs (year, month, day, adddays) and pass it to the block “generate JSON from object”. I don’t know why it maybe works on an iPhone, I would say that this block shouldn’t work on either platform…
Thank you for taking the time to look into the issue. I wanted an array ( a list in Thunkable terms) and this is a valid array. I wasn’t looking for an object and therefore your description of the situation assumes an object for no obvious reason.
In the other hand, you are welcome to demonstrate any other simple project having two way communication between the app and an HTML file using the Web Viewer component and have it working using computer, iPhone, Android phone.
I’m not sure why it is doing this. I tried seeing if I could figure it out by duplicating your html file on my server to tweak some things and I get the same result, no matter what I try. Oddly, if I pass the data to an alert(), it displays the information correctly but then updates the label with undefined. The way I worked my maps was to have the script call the postMessage function and return JSON data that I could then work with. Yours should return a string with the date information, but it does, indeed, return undefined when I put it in my Android emulator. I have no idea. The only thing I can ascertain is the the message data is not being passed into the postMessage function, for whatever reason, after it is processed inside the receiveMessage function.
Hmmm… I only described your blocks: on the right side you generate a list with 4 elements. This list is feeded into a block “generate JSON from object” which is in my opinion not correct: the block “generate JSON from object” expects an object, doesn’t it? But you feed it with a list of 4 values. Is this the way you meant to be?
Yes, this is exactly what I meant to do. I could use the JSON structure but even if, for example, you try to save a list to Firebase, it will just save it as a JSON.
In the list is correctly passed to the HTML file and processed correctly. If you try the project in your computer you will see that it calculates the date correctly even if you enter in the number of days field (the last one) 200 days, just press the button and the correct date will be displayed in the text box.
The function works correctly and as intended. The only issue is when run from an Android device it gives undefined for some reason.
Many thanks. I found the problem. Chrome does not allow the return of objects. Only text where as Safari will auto-convert to text. The Date in JavaScript is an object not a text.