@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