Forum Archive

Location & Crash

Dann239

https://gist.github.com/PyDann/15f1a5d71254c7efe827

I want to continually display the current information. What am I missing here?

Second. (Unrelated to the code on GitHub) The reverse geocode returns a dictionary. I can't pull out a key. When ask to get 'Thoroughfare' it returns None. The dict displays "u 'Thoroughfare':" how do I ask for that?

ccc

For the github question, you just need to wait a second for the GPS hardware to warm up...

import time

def start():
    time.sleep(1)

If you leave the GPS hardware on all the time like this, your battery will run down fast. See the comments on your gist for a better way to go.

ccc

For your second question, location.reverse_geocode() does not return a dictionary but instead returns a list of dictionaries.

To extract the first dictionary from that list, you can change location.reverse_geocode(loc) to location.reverse_geocode(loc)[0] and then you can get at Thoroughfare in the usual way...

    street = location.reverse_geocode(loc))[0]['Thoroughfare'])

The only downside of this approach is that an exception will be thrown if location.reverse_geocode() returns None or [].

Dann239

Oh ccc, your so knowledgeable. Thank you for your continued help.