진재영

gps api js file uploaded

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Geolocation example - getCurrentPosition()</title>
</head>
<body>
<script type="text/javascript" src="practice.js"></script>
</body>
</html>
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
alert("Your browser is not support geolocation.")//navigator이 현재 브라우저에서 작동하지 않는 경우
}
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude
console.log(`Your latitude is ${latitude} and your longitude is ${longitude}`) // 위도와 경도 값을 console로 알려줌
return (latitude, longitude);
}
function error() {
alert("Can't detect your location. Try again later.") // error function
}
\ No newline at end of file