Skip to content

Instantly share code, notes, and snippets.

@choco0908
Created January 7, 2020 02:38
Show Gist options
  • Save choco0908/6a8f00998dfe800a9455085125744eba to your computer and use it in GitHub Desktop.
Save choco0908/6a8f00998dfe800a9455085125744eba to your computer and use it in GitHub Desktop.
현재 내 위치 참조하기 코드
function getLocation() {
if (navigator.geolocation) { // GPS를 지원하면
navigator.geolocation.getCurrentPosition(function(position) {
alert(position.coords.latitude + ' ' + position.coords.longitude);
}, function(error) {
console.error(error);
}, {
enableHighAccuracy: false,
maximumAge: 0,
timeout: Infinity
});
} else {
alert('GPS를 지원하지 않습니다');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment