Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Geolocation doesn't working in emulator, but in web working fine, how to solve?

$
0
0

@waraujo wrote:

.factory('position', function( $rootScope, $cordovaGeolocation ){

    console.log('building position')

    var position = {};
      // 1ST / AUTO GEOLOCATION OF USER
      // displays a popup to indicate current user location - (disabled)
      // onSuccess Callback - This method accepts a Position object, which contains the current GPS coordinates


     // Wait for device API libraries to load
//

     var onSuccess = function(position2) {

          console.log(position2.coords.latitude )
          console.log(position2.coords.longitude)

          position.latitude = position2.coords.latitude;
          position.longitude = position2.coords.longitude;



         $rootScope.$digest()
      };

    function onError(error) { // onError Callback receives a PositionError object
        console.log('error code:', + error.code +'\n')
    };

    //var options = { enableHighAccuracy: true, maximumAge: 15000, timeout: 10000 };
    var options = {maximumAge: 15000, timeout: 30000, enableHighAccuracy:false};

    //var watchID = navigator.geolocation.getCurrentPosition(onSuccess, onError, options);
    navigator.geolocation.watchPosition(onSuccess, onError, options);



  return position;

})

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



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