Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49171

If i turn on the location using diagnostic and cannot get geo location instantly

$
0
0

@compfrkz wrote:

Hi i am trying trying to turn on the location using diagnostic and when i try to get geo coordinates instantly its not working its taking around 10 sec if i start the gps and for subsequent calls geo location is got instantly any way to reduce the time for first call?

my code snippet

     if (window.cordova) {
        cordova.plugins.diagnostic.isLocationEnabled(function(enabled) {
           // alert("Location is " + (enabled ? "enabled" : "disabled"));
    		if(!enabled){

    			cordova.plugins.locationAccuracy.request(function (success){
        console.log("Successfully requested accuracy: "+success.message);
     $cordovaGeolocation
   .getCurrentPosition(posOptions)

   .then(function (position) {
      $scope.lat  = position.coords.latitude;
     $scope.lng = position.coords.longitude;
    	});
    }, function (error){
       console.error("Accuracy request failed: error code="+error.code+"; error message="+error.message);
       if(error.code !== cordova.plugins.locationAccuracy.ERROR_USER_DISAGREED){
           if(window.confirm("Failed to automatically set Location Mode to 'High Accuracy'. Would you like to switch to the Location Settings page and do this manually?")){
               cordova.plugins.diagnostic.switchToLocationSettings();
           }
       }
    }, cordova.plugins.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY);
    		}
        }, function(error) {
            alert("The following error occurred: " + error);
        });
    }

it takes around 10 sec when the location is turned on for first time any idea to reduce time on first call?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49171

Trending Articles



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