Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229110

Button click to turn on mobile gps

$
0
0

hi guys need a help, how to turn on mobile gps on button click…
i need to turn on gps if gps turned off…

here is my code:

this.geolocation.getCurrentPosition().then((resp) => {
      this.lat = resp.coords.latitude;
      this.lng = resp.coords.longitude;
      this.latlong = resp.coords.latitude + ',' + resp.coords.longitude;
      console.log('loaction: ' + this.latlong)
}).catch((error) => {
  console.log('Error getting location', error);
});

this code working fine if gps is on. and not working if gps is off as expected. now i need to show an alert to turn on gps if gps is off like this


Viewing all articles
Browse latest Browse all 229110

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>