ㅜㅜ 코딩 배우기 시작한 지 2주 돼가는, 어제 프로젝트를 시작하게 된 코린이입니다. 다름이 아니라 제가 웹 접속 위치를 디비에 넣고 누적된 위치값을 불러오는 작업을 맡게 됐는데 어떻게 하는지 모르겠습니다 ㅜㅜ 도와주세요
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<script>
var latitude = 0;
var longitude = 0;
var jobj = new Object();
function getLocation() {
if (navigator.geolocation) { // GPS를 지원하면
navigator.geolocation.getCurrentPosition(function(position) {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
//위도, 경도 변수에 담기는지 확인
alert('위도 : ' + latitude + '경도 : ' + longitude);
}, function(error) {
console.error(error);
}, {
enableHighAccuracy: false,
maximumAge: 0,
timeout: Infinity
});
} else {
alert('GPS를 지원하지 않습니다');
}
}
getLocation(); </script>
</body>
</html>