phonegap geolocation always fail on timeout

前端 未结 11 685
遥遥无期
遥遥无期 2020-12-06 01:06

I\'m using sencha-touch 2.0 and phonegap 2.0.0 in my app to retrieve user\'s location. When runing on my locahost, everything works just fine. However, when loading the .apk

相关标签:
11条回答
  • 2020-12-06 01:21

    You just need to add enableHighAccuracy: true, maximumAge: 60000 and then reboot your device.

    0 讨论(0)
  • 2020-12-06 01:22

    Try removing the Phonegap plugin geolocation plugin from your project. You won't need to make any changes to your JavaScript code as your device will fall back on the standard HTML5 navigator.geolocation functionality which has the same method signature.

    Assuming you're using PhoneGap 3.3, you just need to run:

    cordova plugin rm org.apache.cordova.geolocation
    
    0 讨论(0)
  • 2020-12-06 01:24

    If you are running on an emulator, it may be because the device does not have a geolocation set. Try setting the location by running the following, assuming your android emulator is on port 5554:

    telnet localhost 5554
    geo fix -0.001 51.5
    
    0 讨论(0)
  • 2020-12-06 01:31

    I had this happen to a working app after updating PhoneGap to version 3.6.3 from 3.5. After trying many other suggestions Arthur's answer worked. 15 seconds seemed too long to me so I used {timeout: 2000}. I'm guessing the new version is slower as my code worked fine before the update on the same devices. Thought I'd post as well as upvote him as everything I found in Google was about initial setup and mostly irrelevant to my situation.

    0 讨论(0)
  • 2020-12-06 01:36

    It could sound stupid, but, did you activate the "Use Networks" option?

    Go to Settings -> Location and security -> Use networks; and active it. I have passed all the afternoon watching the problem and it was that.

    0 讨论(0)
  • 2020-12-06 01:38

    I restarted and restarted. I reset my phone to factory settings.

    But nothing worked.

    Until I set enablHighAccuracy from true to false.

    And... Tada.... it works.

    So :

    var options;
    
    options = {
        maximumAge: 30000,
        timeout: 5000,
        enableHighAccuracy: false
    };
    

    This used to work fine using PhoneGap 2.6.0. I needed to make this change since I'm now using Phonegap 3.3 - tested on a Wiko Cink+ phone.

    0 讨论(0)
提交回复
热议问题