Skip to content

Instantly share code, notes, and snippets.

@onerinas
Forked from seanbehan/controller.js
Created November 16, 2015 11:26
Show Gist options
  • Save onerinas/96afa233fc4ee300685c to your computer and use it in GitHub Desktop.
Save onerinas/96afa233fc4ee300685c to your computer and use it in GitHub Desktop.
Get user's current GPS, longitude and latitude with PhoneGap and Ionic
// install from command line
// cordova plugin add org.apache.cordova.geolocation
.controller('LocationController', function($scope){
navigator.geolocation.getCurrentPosition(function(position){
coords = [position.coords.latitude, position.coords.longitude].join(',')
get("/places.json?location="+coords).success(function(resp){
$scope.places = resp.places
})
}, function(){
/** error */
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment