Skip to content

Instantly share code, notes, and snippets.

@thehungrycoder
Last active September 2, 2016 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehungrycoder/28ec6a399bef78ee3f33b269151c6e4d to your computer and use it in GitHub Desktop.
Save thehungrycoder/28ec6a399bef78ee3f33b269151c6e4d to your computer and use it in GitHub Desktop.
LocationService.getCoords()
.then(function (coords) {
console.log(coords);
});
angular.module('myapp.services', [])
.service('LocationService', function ($cordovaGeolocation) {
return {
getCoords: function () {
return $cordovaGeolocation.getCurrentPosition({timeout: 10000, enableHighAccuracy: false})
.then(function (position) {
return position.coords;
});
}
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment