Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created June 27, 2019 00:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/329777574fd63ed07fedc674064ccf3d to your computer and use it in GitHub Desktop.
Save BetterProgramming/329777574fd63ed07fedc674064ccf3d 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)
}
});
} else {
// geolocation is not supported
// get your location some other way
console.log('geolocation is not enabled on this browser')
}
@AM-77
Copy link

AM-77 commented Jul 6, 2020

You have added an extra } in line 14.

@binarytrails
Copy link

Indeed, extra } on line 14.

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