omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    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.


    module location doesn't seem to work

    Pythonista
    2
    3
    1517
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • upwart
      upwart last edited by

      I am new to Pythonista and learning every day more about this wonderful app.

      I am trying to use location.get_location(), but all I get is None.
      I know that I should allow Pythonista to use the location, but I never got the question for permission. Also, I can't see Pythonista in the list of apps with/without access to location services in Privacy/Location Services setting.

      Please advise.

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        Does this work?

        import location, time
        
        def getLocation():
            location.start_updates()
            time.sleep(1)  # give GPS hardware a second to wake up
            currLoc = location.get_location()
            location.stop_updates()  # stop GPS hardware ASAP to save battery
            return currLoc
        
        print(getLocation())
        
        1 Reply Last reply Reply Quote 0
        • upwart
          upwart last edited by

          Yes, this works! Thank you very much.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors