Last active
February 29, 2016 12:17
-
-
Save seanbehan/6def920ab5c7fb79174e to your computer and use it in GitHub Desktop.
Get user's current GPS, longitude and latitude with PhoneGap and Ionic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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