javascript - Intel XDK Geolocation won't find Lat/Long if location services off -


i using intel xdk develop app testing android (nexus 6p).

i have added cordova geolocation plugin google location services cordova , have tested location services switched on , correctly gets position both plugins.

however, when switch off location services, nothing appears @ all.

here code using location:

document.addeventlistener("deviceready", ondeviceready, false);  function ondeviceready() {      var geo={};      if (navigator.geolocation) {          console.log('started location');          console.log(cordova.plugins.locationservices.geolocation.getcurrentposition(success, error));          //navigator.geolocation.getcurrentposition(success, error, {enablehighaccuracy:true, maximumage:infinity, timeout:100000});      }        //get latitude , longitude;      function success(position) {          console.log('success location');          geo.lat = position.coords.latitude;          geo.lng = position.coords.longitude;          populateheader(geo.lat, geo.lng);      }        function error(){          console.log("geocoder failed");      }        function populateheader(lat, lng){          $('#lat').attr('data-lat', lat);          $('#long').attr('data-long',lng);      }  }

what i'm after, either way of asking user switch on location data, or better location of user without location services being required.

you "when switch off location services" assume mean have gone android settings , disabled "location history" or turned off sharing "location" on device. in case, won't data because user has elected not share information. see warnings in readme both plugins, considered sensitive data and, therefore, android has given users ability control sharing information.

i don't know if there api explicitly tell whether or not data has been disabled user. regardless, should report cannot data need, due variety of reasons:

  • the sharing of location data has been disabled user
  • the device unable retrieve current position @ time
  • the current "location mode" not allowing retrieval of position

and follow advice on change or fix in order allow data collected , used. of course, if user not interested in ever sharing information app you'll have gracefully comply.


edit 23 feb 2017: see comment below reference plugins can identify if location services available.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -