Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created June 27, 2019 00:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BetterProgramming/8a0cb5eae299a4015f72e85cc2813673 to your computer and use it in GitHub Desktop.
Save BetterProgramming/8a0cb5eae299a4015f72e85cc2813673 to your computer and use it in GitHub Desktop.
if ("geolocation" in navigator) {
// check if geolocation is supported/enabled on current browser
navigator.geolocation.getCurrentPosition(
function success(position) {
// for when getting location is a success
console.log('latitude', position.coords.latitude,
'longitude', position.coords.longitude);
},
function error(error_message) {
// for when getting location results in an error
console.error('An error has occured while retrieving
location', error_message)
ipLookUp()
}
});
} else {
// geolocation is not supported
// get your location some other way
console.log('geolocation is not enabled on this browser')
ipLookUp()
}
@binarytrails
Copy link

@BetterProgramming Extra } on line 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment