Phonegap enable GPS/Location at app runtime

后端 未结 2 1286
遥遥无期
遥遥无期 2021-01-04 18:37

I am using jquery-ui-maps and HTML5 geolocation to show to the user a list of locations and I need to leverage the user\'s geolocation.

So, here is the use case,

相关标签:
2条回答
  • 2021-01-04 19:09

    after struggling for a while i found a plugin that was able to help me with the same issue

    https://github.com/nishantsharmajecrc/cordova-dialog-gps

      function calldialog() {
     document.addEventListener("deviceready",function() {
     cordova.dialogGPS("Your GPS is Disabled, this app needs to be enable to          works.",//message
                "Use GPS, with wifi or 3G.",//description
                function(buttonIndex){//callback
                  switch(buttonIndex) {
                    case 0: break;//cancel
                    case 1: break;//neutro option
                    case 2: break;//user go to configuration
                  }},
                  "Please Turn on GPS",//title
                  ["Cancel","Later","Go"]);//buttons
      });
      }
    
    0 讨论(0)
  • 2021-01-04 19:13

    Phonegap does support realtime update of your GPS.

    Here is a direct link:

    http://docs.phonegap.com/en/3.1.0/cordova_geolocation_geolocation.md.html#geolocation.watchPosition

    In general its called "watch position", and you can set the refresh timer yourself.

    Regarding enabling the GPS during runtime.

    Try just to call navigator.geolocation.watchPosition().

    Remember to grant access to geolocation on your config.xml as well, but I guess you know that ;)

    I hope it helped.

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