This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Reverse Geolocation works on console but not in code
oldCovfefe last edited by ccc
import location location.start_updates() loc_dic = location.get_location() addr_dic = location.reverse_geocode(loc_dic)
Get location works fine, converting it to a friendly street address does not. When I enter the same statement (the last line) in the console, it works just fine and creates a dictionary with all the interesting info. Any ideas what could be going on? Is it a timing issue, meaning I have to wait until it’s populated?
cvp last edited by
@oldCovfefe I'be tried your little script without any error
JonB last edited by
Iirc sometimes it might take a few tried to get a valid location. Maybe try repeating until location returns a non null result
oldCovfefe last edited by
tried that, but it only resulted in a hung loop ... there is something else funky going on, because from the console it works just fine.
mikael last edited by
@oldCovfefe, did you try waiting a bit with ui.delay?
oldCovfefe last edited by oldCovfefe
I finally found the issue. The code works fine on the main level of the app, but has these issue when triggered from a event handler (a function call from an action attribute). The following directive solves the issue:
import location @ui.in_background def button_tapped(sender): location.start_updates() loc_dic = location.get_location() addr_dic = location.reverse_geocode(loc_dic) ...