Cordova Angularjs ask for GPS -
i program app need gps. if gps off, how can ask user turn on gps, google maps? after while of googleing found nothing compareable... other question is, why "use location? - 2", when gps off? thought, if gps off, $window.navigator.geolocation false?
controller.js
if ($window.navigator && $window.navigator.geolocation) { function success(pos) { $rootscope.position = { x: pos.coords.latitude, y: pos.coords.longitude }; } function fail(error) { alert("use location? - 2"); } $window.navigator.geolocation.getcurrentposition(success, fail, { maximumage: 500000, enablehighaccuracy: true, timeout: 6000 }); } else { alert("use location? - 1"); }
there many plugins promess if gps enable. can ask user change location settings. 1 of them diagnostics plugin https://www.npmjs.com/package/cordova.plugins.diagnostic . using it. (al least call location settings).
Comments
Post a Comment