Created
June 27, 2019 00:14
-
-
Save BetterProgramming/329777574fd63ed07fedc674064ccf3d to your computer and use it in GitHub Desktop.
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
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') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have added an extra
}
in line 14.