Skip to content

Instantly share code, notes, and snippets.

@shootacean
Last active June 12, 2019 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shootacean/0a357770e5a151e5e4f7551435324682 to your computer and use it in GitHub Desktop.
Save shootacean/0a357770e5a151e5e4f7551435324682 to your computer and use it in GitHub Desktop.
JavaScriptで現在位置を取得する
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