페이지 접속자의 위치를 확인 할 수 있는 기능
<script>
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를 지원하지 않습니다');
}
}
getLocation();
</script>
var watchId = navigator.geolocation.watchPosition(function(position) {
console.log(position.coords);
});
accuracy: __
altitude: null
altitudeAccuracy: null
heading: null
latitude: __._____
longitude: ___._______
speed: null
🎈 Document : https://developer.mozilla.org/ko/docs/WebAPI/Using_geolocation