Last active
June 12, 2019 04:00
-
-
Save shootacean/0a357770e5a151e5e4f7551435324682 to your computer and use it in GitHub Desktop.
JavaScriptで現在位置を取得する
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
const usableGeolocation = () => { | |
return "geolocation" in navigator; | |
}; | |
window.onload = () => { | |
if (!usableGeolocation()) { | |
console.error('Cannot use geolocation'); | |
return false; | |
} | |
const geoLocation = navigator.geolocation; | |
geoLocation.getCurrentPosition((position) => { | |
console.log(position); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment