javascript - Why getCurrentPosition() fails after unlocking gps acces in googleChromeAndroid -


i'm implementing welcome messages site show @ beginning if user hasn't enabled gps.

the thing after enabling gps via chrome ui js still can't access gps postion (keep getting unables alerts on web page). if page reloaded can.

is there way update state of blocking/nonblocking option without refreshing whole web page ?

<script>      var button = document.getelementbyid("button");      button.onclick = function() {          var geosuccess = function (position) {             var startpos = position;             alert("longlat" + startpos.coords.longitude);         };         var geoerror = function (error) {              alert("unable");         };          navigator.geolocation.getcurrentposition(geosuccess, geoerror);  };  </script> 

please check out link :- gps not know whether asked can tell .it might please forgive me if irrelevant. code here :

         <span id="demo" />         <script>           var x = document.getelementbyid("demo");           function getlocation() {           if (navigator.geolocation) {          navigator.geolocation.getcurrentposition(showposition);         } else {        x.innerhtml = "geolocation not supported browser.";         }         }       function showposition(position) {          x.innerhtml = "latitude: " + position.coords.latitude +        "<br>longitude: " + position.coords.longitude;         }     </script> 

the code above following :

  • check if geolocation supported
  • if supported, run getcurrentposition() method. if not, display message user .
  • if getcurrentposition() method successful, returns coordinates object function specified in parameter ( showposition )
  • note : showposition() function gets displays latitude , longitude

Comments

Popular posts from this blog

angularjs - Redirect to a new template in angular js -

Oracle SQL. How to select specific IDs where value of columns specify criteria? -

Desktop Launcher for Python Script Starts Program in Wrong Path (Linux) -