I am using the Geolocation HTML5 API. I am using angular.js. I am writing a small factory function
myApp.factory("GeolocationService", ['$q', '$window', '$rootScope',
function($q, $window, $rootScope) {
return function() {
var deferred = $q.defer();
if (!$window.navigator) {
$rootScope.$apply(function() {
deferred.reject(new Error("Geolocation is not supported"));
});
} else {
$window.navigator.geolocation.getCurrentPosition(function(position) {
$rootScope.$apply(function() {
deferred.resolve(position);
});
}, function(error) {
$rootScope.$apply(function() {
deferred.reject(error);
});
});
}
return deferred.promise;
}
}
]);
When i use it. It gives me an error
PositionError {message: "Provider of network locations at https://www.googleapis.com/ ': Returned error code 404.", code: 2, PERMISSION_DENIED: 1, POSITION_UNAVAILABLE: 2, TIMEOUT: 3}
Can someone help how to solve it?
source
share