Skip to content

Instantly share code, notes, and snippets.

@GlauberF
Created November 15, 2018 11:39
Show Gist options
  • Save GlauberF/7714458fa8d6b113bbb8e0b1e738a59e to your computer and use it in GitHub Desktop.
Save GlauberF/7714458fa8d6b113bbb8e0b1e738a59e to your computer and use it in GitHub Desktop.
get location
if ('geolocation' in navigator) {
console.log('Supports HTML geolocation API');
(function () {
var onSuccess = function (location) {
console.log('User location', location);
var userLat = location.coords.latitude,
userLon = location .coords.longitude;
},
onError = function (code, message) {
console.log('Gelocation error', code, message);
};
navigator.geolocation.getCurrentPosition(onSuccess, onError);
})();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment